Re: max_fd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 23, 2005 at 07:03:45PM +0200, Frank van Maarseveen wrote:
> On Fri, Sep 23, 2005 at 09:25:10PM +0530, Dipankar Sarma wrote:
> > On Fri, Sep 23, 2005 at 02:37:51PM +0200, Pablo Fernandez wrote:
> > Just do - 
> > 
> > 	struct fdtable *fdt;
> > 
> > 	rcu_read_lock();
> > 	fdt = files_fdtable(files_struct);
> > 	if (fdt->max_fds......
> > 	...
> > 	rcu_read_unlock();
> 
> In include/linux/file.h I see this:
> 
>  #define files_fdtable(files) (rcu_dereference((files)->fdt))
> 
> looks better to me unless you really want to update the
> struct fdtable.

I would much rather have it my way :)

Well, the main reason is that if that code is somehow copied
by to a lock-free critical section, it could cause problems.
If you dereference ->fdt multiple times in a lock-free
section, you could see two different pointers due to
a concurrent update.

I would advise sticking to the same convention everywhere.

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

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux