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]
Message-ID: <CA+55aFw9g1A77L0hXY1PiwY0Anibx7suAu8i0C90mEbOEr_uqw@mail.gmail.com>
Date:	Mon, 6 Jun 2016 17:58:53 -0700
From:	Linus Torvalds <torvalds@...ux-foundation.org>
To:	Al Viro <viro@...iv.linux.org.uk>
Cc:	Dave Hansen <dave.hansen@...el.com>,
	"Chen, Tim C" <tim.c.chen@...el.com>,
	Ingo Molnar <mingo@...hat.com>,
	Davidlohr Bueso <dbueso@...e.de>,
	"Peter Zijlstra (Intel)" <peterz@...radead.org>,
	Jason Low <jason.low2@...com>,
	Michel Lespinasse <walken@...gle.com>,
	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
	Waiman Long <waiman.long@...com>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: performance delta after VFS i_mutex=>i_rwsem conversion

On Mon, Jun 6, 2016 at 5:40 PM, Al Viro <viro@...iv.linux.org.uk> wrote:
>
> static struct dentry *next_positive(struct dentry *parent,
>                                     struct dentry *child, int count)
> {
>         struct list_head *p = child ? &child->d_child : &parent->d_subdirs;

>From your description, you seem to be very confused about what "child
== NULL" means. Here it means that it's a cursor to the beginning, but
in your commentary on move_cursor(), you say "moves cursor immediately
past child *or* to the very end if child is NULL".

That's very confusing. Is NULL beginning or end?

I really think you'd be better off having a special ERR_PTR value for
end, possibly as a flag value in the cursor dentry.

The whole "what does NULL mean" confusion exists inside that
"next_positive" too:

>         unsigned *seq = &parent->d_inode->i_dir_seq, n;
>         do {
>                 int i = count;
>                 n = smp_load_acquire(seq) & ~1;
>                 rcu_read_lock();
>                 do {
>                         p = p->next;
>                         if (p == &parent->d_subdirs) {
>                                 child = NULL;
>                                 break;
>                         }

look, here you return NULL for "end" again. Even though it meant
beginning at the start of the function. Nasty.

Also, may I suggest that there is a very trivial special case for
"next_positive()" that needs no barriers or sequence checking or
anything else: at the very beginning, just load the "->next" pointer,
and if it's a positive entry, you're done. That's going to be the
common case when there _isn't_ crazy multi-threaded readdirs going on,
so it's worth handling separately.

In fact, if you have a special value for the case of "cursor is at
end" situation, then for the small directory case that can be handled
with a single getdents call, you'll *never* set the cursor in the
child list at all, which means that the above special case for
next_positive() is actually the common case even for the threaded
situation.

                Linus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ