From: Alex Elder <aelder@sgi.com>
To: Dave Chinner <david@fromorbit.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 5/5] percpu_counter: only disable preemption if needed in add_unless_lt()
Date: Wed, 29 Dec 2010 10:29:38 -0600 [thread overview]
Message-ID: <1293640178.1961.62.camel@doink> (raw)
In-Reply-To: <20101223063138.GF18264@dastard>
On Thu, 2010-12-23 at 17:31 +1100, Dave Chinner wrote:
> On Wed, Dec 22, 2010 at 09:56:42PM -0600, Alex Elder wrote:
> > In __percpu_counter_add_unless_lt() we don't need to disable
> > preemption unless we're manipulating a per-cpu variable. That only
> > happens in a limited case, so narrow the scope of that preemption to
> > surround that case. This makes the "out" label rather unnecessary,
> > so replace a couple "goto out" calls to just return.
. . .
>
> Regardless of the other changes, this is not valid. That is:
You're right. I was thinking about updates to fbc->count
being protected by the spinlock, but that doesn't address
the cached value getting stale if this CPU gets preempted
and another thread passes through this code before the
first one gets resumed.
I'm also looking at the other patches and your responses
and will be done with it today. I don't want to hold
up your pull request any longer.
If you found anything of value in the little series I posted
feel free to incorporate it into your own changes.
-Alex
> amount = -1;
> count = fbc->count;
> .....
>
> <get preempted>
>
> <other operations may significantly change fbc->count (i.e
> lots more than error will catch), so the current value of
> count in this context is wrong and cannot be trusted>
>
> <start running again>
>
> if (count - error + amount > threshold) {
> <not valid to run this lockless optimisation based
> on a stale count value>
>
> ....
> }
>
> Effectively, if we want to be able to use lockless optimisations, we
> need to ensure that the value of the global counter that we read
> remains within the given error bounds until we have finished making
> the lockless modification. That is done via disabling preemption
> across the entire function...
>
> Cheers,
>
> Dave.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2010-12-29 16:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-23 3:56 [PATCH 5/5] percpu_counter: only disable preemption if needed in add_unless_lt() Alex Elder
2010-12-23 6:31 ` Dave Chinner
2010-12-29 16:29 ` Alex Elder [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=1293640178.1961.62.camel@doink \
--to=aelder@sgi.com \
--cc=david@fromorbit.com \
--cc=xfs@oss.sgi.com \
/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