From: Thomas Gleixner <tglx@linutronix.de>
To: "chengjian (D)" <cj.chengjian@huawei.com>
Cc: huawei.libin@huawei.com, mingo@redhat.com, peterz@infradead.org,
dvhart@infradead.org, linux-kernel@vger.kernel.org
Subject: Re: a competition when some threads acquire futex
Date: Tue, 5 Sep 2017 21:37:03 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.20.1709052131130.2393@nanos> (raw)
In-Reply-To: <3e497508-876f-6474-3f3d-acab06a63b55@huawei.com>
On Tue, 5 Sep 2017, chengjian (D) wrote:
> int main(int argc, char** argv)
> {
> pthread_t id1;
> pthread_t id2;
>
> printf("main pid = %d\n", getpid( ));
>
> pthread_mutex_init(&mutex, NULL);
So this is a plain mutex, which maps to a plain futex.
> use perf ftrace to shows the graph of the function calls. We found that the
> process 17327 auquire the lock quickly after call futex_wake( ), so the
> process 17328 futex_wait( ) all the time.
The observed functions look correct for that futex type.
> diff --git a/kernel/futex.c b/kernel/futex.c
> index 3d38eaf..0b2d17a 100644
> --- a/kernel/futex.c
> +++ b/kernel/futex.c
> @@ -1545,6 +1545,7 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval,
> struct futex_pi_state *pi_
> spin_unlock(&hb->lock);
> wake_up_q(&wake_q);
> + _cond_resched( );
What's less correct is the placement of the cond_resched() which you patch
into the function:
wake_futex_pi()
wake_futex_pi() is not even remotely involved in this problem, so I have a
hard time to understand how this patch 'solves' it.
Thanks,
tglx
next prev parent reply other threads:[~2017-09-05 19:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-05 1:50 chengjian (D)
2017-09-05 19:37 ` Thomas Gleixner [this message]
2017-09-06 0:27 ` chengjian (D)
2017-09-06 8:36 ` Thomas Gleixner
2017-09-06 8:56 ` Peter Zijlstra
2017-09-06 9:06 ` Peter Zijlstra
2017-09-06 9:09 ` chengjian (D)
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=alpine.DEB.2.20.1709052131130.2393@nanos \
--to=tglx@linutronix.de \
--cc=cj.chengjian@huawei.com \
--cc=dvhart@infradead.org \
--cc=huawei.libin@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--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
all inboxes | Powered by JetHome®