mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Guo Hui <guohui@uniontech.com>,
	peterz@infradead.org, mingo@redhat.com, will@kernel.org,
	boqun.feng@gmail.com
Cc: linux-kernel@vger.kernel.org, wangxiaohua@uniontech.com
Subject: Re: [PATCH] locking/osq_lock: Fix false sharing of optimistic_spin_node in osq_lock
Date: Wed, 14 Jun 2023 22:57:22 -0400	[thread overview]
Message-ID: <b8ec5185-f167-0b11-b823-51ba4fc3ca4f@redhat.com> (raw)
In-Reply-To: <9f5321f9-0b35-7f85-ee09-247d961e5a79@redhat.com>


On 6/14/23 21:58, Waiman Long wrote:
>> diff --git a/kernel/locking/osq_lock.c b/kernel/locking/osq_lock.c
>> index d5610ad52b92..bdcd216b73c4 100644
>> --- a/kernel/locking/osq_lock.c
>> +++ b/kernel/locking/osq_lock.c
>> @@ -24,7 +24,7 @@ static inline int encode_cpu(int cpu_nr)
>>     static inline int node_cpu(struct optimistic_spin_node *node)
>>   {
>> -    return node->cpu - 1;
>> +    return node->prev_cpu - 1;
>>   }
>
> From the first glance, the patch looks OK. The only issue that I have 
> so far is the "node_cpu" name which is misleading in this case. You 
> should have renamed it to node_prev_cpu() instead as there is only one 
> caller.

One more thing. Unlike node->cpu, node->prev_cpu is subjected to change. 
So you should have use READ_ONCE() to read it to match the WRITE_ONCE() 
that modifies it.

Thanks,
Longman


  reply	other threads:[~2023-06-15  2:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-15  1:24 Guo Hui
2023-06-15  1:58 ` Waiman Long
2023-06-15  2:57   ` Waiman Long [this message]
2023-06-15  8:27     ` Guo Hui

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=b8ec5185-f167-0b11-b823-51ba4fc3ca4f@redhat.com \
    --to=longman@redhat.com \
    --cc=boqun.feng@gmail.com \
    --cc=guohui@uniontech.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=wangxiaohua@uniontech.com \
    --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®