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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTinAY=jbtEEFa0XgYiHs8Lj21Q58FhPpU+TOtWnf@mail.gmail.com>
Date:	Fri, 12 Nov 2010 08:39:17 -0800
From:	Linus Torvalds <torvalds@...ux-foundation.org>
To:	Nick Piggin <npiggin@...nel.dk>
Cc:	linux-kernel@...r.kernel.org, Al Viro <viro@...iv.linux.org.uk>,
	Ingo Molnar <mingo@...e.hu>,
	Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [patches] seqlock: add barrier-less special cases for seqcounts

On Thu, Nov 11, 2010 at 12:00 AM, Nick Piggin <npiggin@...nel.dk> wrote:
> Add branch annotations for seqlock read fastpath, and introduce
> __read_seqcount_begin and __read_seqcount_end functions, that can avoid
> the smp_rmb() if it is provided with some other barrier. Read barriers
> have non trivial cost on many architectures.
>
> These will be used by store-free path walking algorithm, where
> performance is critical and seqlocks are widely used.

A couple of questions:

 - what are the barriers in question? IOW, describe some normal use.

 - do we really want the "repeat until seqlock is even" code in the
__read_seqcount_begin() code for those kinds of internal cases?

That second one is very much a question for the use-case like the
pathname walk where you have a fall-back that uses "real" locking
rather than the optimistic sequence locks. I have a suspicion that if
seq_locks are used as an "optimistic lockless path with a locking
fallback", then if we see an odd value at the beginning we should
consider it a hint that the sequence lock is contended and the
optimistic path should be aborted early.

In other words, I kind of suspect that anybody that wants to use some
internal sequence lock function like __read_seqcount_begin() would
also want to do its own decision about what happens when the seqlock
is already in the middle of having an active writer.

So the interface seems a bit broken: if we really want to expose these
kinds of internal helper functions, then I suspect not only the
smp_rmb(), but also the whole "loop until even" should be in the
normal "read_seqcount_begin()" function, and __read_seqcount_begin()
would _literally_ just do the single sequence counter access.

I dunno. Just a gut feel. Added Al, Ingo and Thomas to the Cc - the
whole "loop in begin" was added by Ingo and Thomas a few years ago to
avoid a live-lock, but that live-lock issue really isn't an issue if
you end up falling back on a locking algorithm and have a "early
failure" case for the __read_seqcount_begin() the same way we have the
final failure case for [__]read_seqcount_retry().

             Linus
--
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