From: Chris Mason <chris.mason@oracle.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>,
axboe@kernel.dk, linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC] reduce runqueue lock contention
Date: Thu, 20 May 2010 18:21:54 -0400 [thread overview]
Message-ID: <20100520222154.GC20946@think> (raw)
In-Reply-To: <1274389786.1674.1653.camel@laptop>
On Thu, May 20, 2010 at 11:09:46PM +0200, Peter Zijlstra wrote:
> On Thu, 2010-05-20 at 16:48 -0400, Chris Mason wrote:
> >
> > This is more of a starting point than a patch, but it is something I've
> > been meaning to look at for a long time. Many different workloads end
> > up hammering very hard on try_to_wake_up, to the point where the
> > runqueue locks dominate CPU profiles.
>
> Right, so one of the things that I considered was to make p->state an
> atomic_t and replace the initial stage of try_to_wake_up() with
> something like:
>
> int try_to_wake_up(struct task *p, unsigned int mask, wake_flags)
> {
> int state = atomic_read(&p->state);
>
> do {
> if (!(state & mask))
> return 0;
>
> state = atomic_cmpxchg(&p->state, state, TASK_WAKING);
> } while (state != TASK_WAKING);
>
> /* do this pending queue + ipi thing */
>
> return 1;
> }
>
> Also, I think we might want to put that atomic single linked list thing
> into some header (using atomic_long_t or so), because I have a similar
> thing living in kernel/perf_event.c, that needs to queue things from NMI
> context.
So I've done three of these cmpxchg lists recently...but they have all
been a little different. I went back and forth a bunch of times about
using a list_head based thing instead to avoid the walk for list append.
I really don't like the walk.
But, what makes this one unique is that I'm using a cmpxchg on the list
pointer in the in task struct to take ownership of this task struct.
It is how I avoid concurrent lockless enqueues.
Your fiddling with the p->state above would let me avoid that.
-chris
next prev parent reply other threads:[~2010-05-20 22:23 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-20 20:48 [PATCH RFC] reduce runqueue lock contention Chris Mason
2010-05-20 21:09 ` Peter Zijlstra
2010-05-20 21:23 ` Peter Zijlstra
2010-05-20 22:17 ` Chris Mason
2010-05-20 22:21 ` Chris Mason [this message]
2010-06-04 10:56 ` Stijn Devriendt
2010-06-04 12:00 ` Peter Zijlstra
2010-06-05 9:37 ` Stijn Devriendt
2010-06-21 10:02 ` Peter Zijlstra
2010-06-21 10:54 ` Peter Zijlstra
2010-06-21 13:04 ` Peter Zijlstra
2010-06-22 13:33 ` Peter Zijlstra
2010-06-22 21:11 ` Ingo Molnar
2010-06-23 9:10 ` Peter Zijlstra
2010-12-01 23:13 ` Frank Rowand
2010-12-02 1:17 ` Frank Rowand
2010-12-02 7:36 ` Peter Zijlstra
2010-12-14 2:41 ` Frank Rowand
2010-12-14 3:42 ` Mike Galbraith
2010-12-14 21:42 ` Frank Rowand
2010-12-15 18:59 ` Oleg Nesterov
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=20100520222154.GC20946@think \
--to=chris.mason@oracle.com \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox