lkml.org 
[lkml]   [2005]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] removes filp_count_lock and changes nr_files type to atomic_t
From
Date
On Thu, 2005-08-25 at 10:45 +0200, Eric Dumazet wrote:
> This patch removes filp_count_lock spinlock, used to protect files_stat.nr_files.
>
> Just use atomic_t type and atomic_inc()/atomic_dec() operations.
>
> This patch assumes that atomic_read() is a plain {return v->counter;} on all
> architectures. (keywords : sysctl, /proc/sys/fs/file-nr, proc_dointvec)
>

this patch adds atomic ops where there were none before
> static inline void file_free(struct file *f)
> @@ -70,7 +62,7 @@
> /*
> * Privileged users can go above max_files
> */
> - if (files_stat.nr_files >= files_stat.max_files &&
> + if (atomic_read(&files_stat.nr_files) >= files_stat.max_files &&
> !capable(CAP_SYS_ADMIN))
> goto over;
>

here

> @@ -94,10 +86,10 @@
>
> over:
> /* Ran out of filps - report that */
> - if (files_stat.nr_files > old_max) {
> + if (atomic_read(&files_stat.nr_files) > old_max) {
> printk(KERN_INFO "VFS: file-max limit %d reached\n",
> files_stat.max_files);
> - old_max = files_stat.nr_files;
> + old_max = atomic_read(&files_stat.nr_files);
> }
> goto fail;

and here

for those architectures that need atomics for read (parisc? arm?)

however.. wouldn't it be better to make this a per cpu variable for
write, and for read iterate or do something smart otherwise?


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-08-25 11:08    [W:0.057 / U:2.680 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site