linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC] get_write_access()/deny_write_access() without inode->i_lock
Date: Mon, 20 Jun 2011 09:22:32 -0700	[thread overview]
Message-ID: <BANLkTikUi9M1Mx4L54vJOP0SK0P3yAz=uQ@mail.gmail.com> (raw)
In-Reply-To: <20110620161352.GT11521@ZenIV.linux.org.uk>

On Mon, Jun 20, 2011 at 9:13 AM, Al Viro <viro@zeniv.linux.org.uk> wrote:
>
> Er...  The current mainline does atomic_read() followed by atomic_inc(),
> so we get the same thing (plus the spin_lock()/spin_unlock()), don't we?

Yes. Unless the spinlock is in the same cacheline. No reason not to
fix that, though.

Of course, if the "ETXTBUSY" case is the common case (which I doubt),
then not doing the write at all would be the optimal case. But I doubt
that case is even worth really worrying about ;)

> For get_write_access() it's probably the right assumption for everything but
> /dev/tty*; for deny_write_access() it's not - a lot of binaries are run by
> more than one process...

Note the fact that EVEN IF WE GUESS INCORRECTLY, performance is likely
better by guessing rather than reading, unless you know the thing is
already in the local CPU cache.

Doing the loop twice instead of once is still *much* faster than an
extra cache transaction that goes to the bus (or L3 or whatever).

> FWIW, I wonder what will the things look like on ll/sc architectures;

There are no ll/sc architectures worth worrying about, so I don't
think that's the primary concern.  That said, I don't disagree with
creating a "atomic_inc_unless_negative()" helper.

                     Linus

  reply	other threads:[~2011-06-20 16:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-19 23:51 [RFC] get_write_access()/deny_write_access() without inode->i_lock Al Viro
2011-06-20 12:47 ` David Howells
2011-06-20 12:47   ` David Howells
2011-06-20 13:18   ` Al Viro
2011-06-20 13:18     ` Al Viro
2011-06-20 13:20 ` David Howells
2011-06-20 13:20   ` David Howells
2011-06-20 13:21 ` Frantisek Hrbata
2011-06-20 14:15   ` Al Viro
2011-06-20 15:55 ` Linus Torvalds
2011-06-20 15:55   ` Linus Torvalds
2011-06-20 16:13   ` Al Viro
2011-06-20 16:22     ` Linus Torvalds [this message]
2011-06-20 16:22       ` Linus Torvalds
2011-06-20 16:42       ` Al Viro
2011-06-20 16:42         ` Al Viro
2011-06-20 17:03         ` Al Viro
2011-06-20 19:47 ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='BANLkTikUi9M1Mx4L54vJOP0SK0P3yAz=uQ@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).