From: Qian Cai <cai@lca.pw>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Marco Elver <elver@google.com>, Will Deacon <will@kernel.org>,
Ingo Molnar <mingo@redhat.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"paul E. McKenney" <paulmck@kernel.org>
Subject: Re: [PATCH] locking/osq_lock: fix a data race in osq_wait_next
Date: Mon, 27 Jan 2020 22:12:58 -0500 [thread overview]
Message-ID: <2E13BFD2-A2E5-4CAA-B0D0-0DF2F5529F1B@lca.pw> (raw)
In-Reply-To: <20200123093604.GT14914@hirez.programming.kicks-ass.net>
> On Jan 23, 2020, at 4:36 AM, Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Wed, Jan 22, 2020 at 11:38:51PM +0100, Marco Elver wrote:
>
>> If possible, decode and get the line numbers. I have observed a data
>> race in osq_lock before, however, this is the only one I have recently
>> seen in osq_lock:
>>
>> read to 0xffff88812c12d3d4 of 4 bytes by task 23304 on cpu 0:
>> osq_lock+0x170/0x2f0 kernel/locking/osq_lock.c:143
>>
>> while (!READ_ONCE(node->locked)) {
>> /*
>> * If we need to reschedule bail... so we can block.
>> * Use vcpu_is_preempted() to avoid waiting for a preempted
>> * lock holder:
>> */
>> --> if (need_resched() || vcpu_is_preempted(node_cpu(node->prev)))
>> goto unqueue;
>>
>> cpu_relax();
>> }
>>
>> where
>>
>> static inline int node_cpu(struct optimistic_spin_node *node)
>> {
>> --> return node->cpu - 1;
>> }
>>
>>
>> write to 0xffff88812c12d3d4 of 4 bytes by task 23334 on cpu 1:
>> osq_lock+0x89/0x2f0 kernel/locking/osq_lock.c:99
>>
>> bool osq_lock(struct optimistic_spin_queue *lock)
>> {
>> struct optimistic_spin_node *node = this_cpu_ptr(&osq_node);
>> struct optimistic_spin_node *prev, *next;
>> int curr = encode_cpu(smp_processor_id());
>> int old;
>>
>> node->locked = 0;
>> node->next = NULL;
>> --> node->cpu = curr;
>>
>
> Yeah, that's impossible. This store happens before the node is
> published, so no matter how the load in node_cpu() is shattered, it must
> observe the right value.
Marco, any thought on how to do something about this? The worry is that
too many false positives like this will render the tool usefulness as a
general debug option.
next prev parent reply other threads:[~2020-01-28 3:13 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-22 16:38 Qian Cai
2020-01-22 16:59 ` Will Deacon
2020-01-22 17:08 ` Qian Cai
2020-01-22 22:38 ` Marco Elver
2020-01-22 23:54 ` Qian Cai
2020-01-23 9:39 ` Peter Zijlstra
2020-01-28 3:11 ` Qian Cai
2020-01-28 11:46 ` Marco Elver
2020-01-28 12:53 ` Qian Cai
2020-01-28 16:52 ` Peter Zijlstra
2020-01-28 16:56 ` Peter Zijlstra
2020-01-29 0:22 ` Paul E. McKenney
2020-01-29 15:29 ` Marco Elver
2020-01-29 18:40 ` Peter Zijlstra
2020-01-30 13:39 ` Marco Elver
2020-01-30 13:48 ` Peter Zijlstra
2020-01-31 3:32 ` Qian Cai
2020-01-29 18:49 ` Peter Zijlstra
2020-01-29 19:26 ` Paul E. McKenney
2020-01-23 9:36 ` Peter Zijlstra
2020-01-28 3:12 ` Qian Cai [this message]
2020-01-28 8:18 ` Marco Elver
2020-01-28 10:10 ` Qian Cai
2020-01-28 10:29 ` Marco Elver
2020-01-22 17:09 ` Peter Zijlstra
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=2E13BFD2-A2E5-4CAA-B0D0-0DF2F5529F1B@lca.pw \
--to=cai@lca.pw \
--cc=elver@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=will@kernel.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®