linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Miaohe Lin <linmiaohe@huawei.com>
To: Muchun Song <songmuchun@bytedance.com>,
	"Huang, Ying" <ying.huang@intel.com>,
	Qian Cai <quic_qiancai@quicinc.com>
Cc: <akpm@linux-foundation.org>, <david@redhat.com>,
	<linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] mm/swapfile: fix possible data races of inuse_pages
Date: Tue, 21 Jun 2022 14:40:49 +0800	[thread overview]
Message-ID: <c5bc3625-48a2-6b8d-b6f4-b3e8c18d11d7@huawei.com> (raw)
In-Reply-To: <YrE9jxTAvLjeBTiT@FVFYT0MHHV2J.usts.net>

On 2022/6/21 11:39, Muchun Song wrote:
> On Tue, Jun 21, 2022 at 09:14:00AM +0800, Huang, Ying wrote:
>> Qian Cai <quic_qiancai@quicinc.com> writes:
>>
>>> On Mon, Jun 20, 2022 at 10:20:07PM +0800, Muchun Song wrote:
>>>> The lock does not protect the read sides. So the write side should be
>>>> fixed by WRITTE_ONCE().
>>>
>>> https://lwn.net/Articles/816854/
>>>
>>> "Unmarked writes (aligned and up to word size) can be treated as if they had
>>> used WRITE_ONCE() by building with
>>> CONFIG_KCSAN_ASSUME_PLAIN_WRITES_ATOMIC=y (also selected by default).
> 
> All right, CONFIG_KCSAN_ASSUME_PLAIN_WRITES_ATOMIC help us avoid KCSAN
> complaining.
> 
>>> Experience has shown that compilers are much less likely to destructively
>>> optimize in-kernel writes than reads. Some developers might therefore
>>> choose to use READ_ONCE() but omit the corresponding WRITE_ONCE(). Other
>>> developers might prefer the documentation benefits and long-term peace of
>>> mind accruing from explicit use of WRITE_ONCE()..."
>>
>> Thanks for pointing me to this great article.  So although not required
>> by KCSAN strictly, WRITE_ONCE() is still good for documentation, etc.
>> Just like we have done for swap_info_struct->highest_bit, etc.
>>
> 
> +1

I tend to agree with Muchun & Huang, Ying. Thanks all of you.

> 
>> Best Regards,
>> Huang, Ying
>>
> .
> 



  reply	other threads:[~2022-06-21  6:40 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-08 14:40 [PATCH v2 0/3] A few cleanup and fixup patches for swap Miaohe Lin
2022-06-08 14:40 ` [PATCH v2 1/3] mm/swapfile: make security_vm_enough_memory_mm() work as expected Miaohe Lin
2022-06-17  7:33   ` David Hildenbrand
2022-06-18  2:43     ` Miaohe Lin
2022-06-18  7:10       ` David Hildenbrand
2022-06-18  7:31         ` Miaohe Lin
2022-06-20  7:31   ` Huang, Ying
2022-06-20 12:12     ` Miaohe Lin
2022-06-21  1:35       ` Huang, Ying
2022-06-21  7:37         ` Miaohe Lin
2022-06-21  7:42           ` Huang, Ying
2022-06-21  8:20             ` Miaohe Lin
2022-06-08 14:40 ` [PATCH v2 2/3] mm/swapfile: fix possible data races of inuse_pages Miaohe Lin
2022-06-20  7:54   ` Huang, Ying
2022-06-20  9:04     ` Miaohe Lin
2022-06-20  9:23       ` Muchun Song
2022-06-20 12:23         ` Miaohe Lin
2022-06-20 12:32           ` Miaohe Lin
2022-06-20 13:46             ` Qian Cai
2022-06-20 14:20               ` Muchun Song
2022-06-20 21:36                 ` Qian Cai
2022-06-21  1:14                   ` Huang, Ying
2022-06-21  3:39                     ` Muchun Song
2022-06-21  6:40                       ` Miaohe Lin [this message]
2022-06-08 14:40 ` [PATCH v2 3/3] mm/swap: remove swap_cache_info statistics Miaohe Lin
2022-06-08 15:16   ` David Hildenbrand
2022-06-20  8:08   ` Huang, Ying
2022-06-20  9:05     ` Miaohe Lin
2022-06-20  9:30   ` Muchun Song
2022-06-17  2:37 ` [PATCH v2 0/3] A few cleanup and fixup patches for swap Andrew Morton
2022-06-17  3:00   ` Miaohe Lin

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=c5bc3625-48a2-6b8d-b6f4-b3e8c18d11d7@huawei.com \
    --to=linmiaohe@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=quic_qiancai@quicinc.com \
    --cc=songmuchun@bytedance.com \
    --cc=ying.huang@intel.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