lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 2 Apr 2012 00:31:54 +0300
From:	Alexey Dobriyan <adobriyan@...il.com>
To:	Eric Dumazet <eric.dumazet@...il.com>
Cc:	akpm@...ux-foundation.org, viro@...iv.linux.org.uk,
	torvalds@...ux-foundation.org, drepper@...il.com,
	linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH] nextfd(2)

On Sun, Apr 01, 2012 at 05:43:25PM +0200, Eric Dumazet wrote:
> On Sun, 2012-04-01 at 15:57 +0300, Alexey Dobriyan wrote:
> 
> > +
> > +/* Return first opened file descriptor which is >= than the argument. */
> > +SYSCALL_DEFINE1(nextfd, unsigned int, fd)
> > +{
> > +	struct files_struct *files = current->files;
> > +	struct fdtable *fdt;
> > +
> > +	rcu_read_lock();
> > +	fdt = files_fdtable(files);
> > +	while (fd < fdt->max_fds) {
> > +		struct file *file;
> > +
> > +		file = rcu_dereference_check_fdtable(files, fdt->fd[fd]);
> > +		if (file) {
> > +			rcu_read_unlock();
> > +			return fd;
> > +		}
> > +		fd++;
> > +	}
> > +	rcu_read_unlock();
> > +	return -ESRCH;
> > +}
> 
> Interesting idea but what about using fdt->open_fds bitmap to have a
> fast search and less cache pollution ?
> 
> alloc_fd(start, flags) uses find_next_zero_bit(), you could use
> find_next_bit().

Indeed.
I've copied code from /proc/*/fd implementation which does loop.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ