From: Nick Piggin <npiggin@suse.de>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Nick Piggin <npiggin@suse.de>, Andrew Morton <akpm@osdl.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [patch 1/2] atomic_add_unless sadness
Date: Wed, 18 Jan 2006 18:10:46 +0100 [thread overview]
Message-ID: <20060118171046.GF28418@wotan.suse.de> (raw)
In-Reply-To: <Pine.LNX.4.64.0601180842440.3240@g5.osdl.org>
On Wed, Jan 18, 2006 at 08:48:01AM -0800, Linus Torvalds wrote:
>
>
> On Wed, 18 Jan 2006, Nick Piggin wrote:
> >
> > For some reason gcc 4 on at least i386 and ppc64 (that I have tested with)
> > emit two cmpxchges for atomic_add_unless unless we put branch hints in.
> > (it is unlikely for the "unless" case to trigger, and it is unlikely for
> > cmpxchg to fail).
>
> Irrelevant. If "atomic_add_unless()" is in a hot path and inlined, we're
> doing something else wrong anyway. It's not a good op to use. Just think
> of it as being very expensive.
>
I don't think it is quite irrelevant. Regardless of where it is used, it
doesn't hurt to make something smaller and more efficient.
> The _only_ user of "atomic_add_unless()" is "dec_and_lock()", which isn't
> even inlined. The fact that gcc ends up "unrolling" the loop once is just
> fine.
>
dec_and_lock is not exactly a slow path. Maybe unrolling doesn't slow it
down in the traditional sense, but you're the one (rightly, I gather)
always talking about icache. In fact it unrolls an exceedingly rare second
iteration into the main code path.
> Please keep it that way.
>
fs/file_table.c uses it as well (inc_not_zero).
Nick
prev parent reply other threads:[~2006-01-18 17:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-18 6:36 [patch 1/2] atomic_add_unless sadness Nick Piggin
2006-01-18 6:39 ` [patch 2/2] powerpc: native atomic_add_unless Nick Piggin
2006-01-18 17:11 ` Joel Schopp
2006-01-18 17:28 ` Nick Piggin
2006-01-18 21:05 ` Joel Schopp
2006-01-19 14:04 ` Nick Piggin
2006-01-18 16:48 ` [patch 1/2] atomic_add_unless sadness Linus Torvalds
2006-01-18 17:10 ` Nick Piggin [this message]
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=20060118171046.GF28418@wotan.suse.de \
--to=npiggin@suse.de \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.