From: Andrew Morton <akpm@linux-foundation.org>
To: mt4022@columbia.edu
Cc: Mani Tofigh via B4 Relay <devnull+mt4022.columbia.edu@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
tz2294@columbia.edu
Subject: Re: [PATCH] mm: annotate lockless accesses to vm_committed_as_batch
Date: Sun, 15 Nov 2026 11:38:51 -0800 [thread overview]
Message-ID: <20261115113851.f809d47b8356755c229278c2@linux-foundation.org> (raw)
In-Reply-To: <20261027-kcsan-mm-v1-1-66757485b917@columbia.edu>
On Tue, 27 Oct 2026 16:09:01 -0400 Mani Tofigh via B4 Relay <devnull+mt4022.columbia.edu@kernel.org> wrote:
> From: Mani Tofigh <mt4022@columbia.edu>
>
> vm_committed_as_batch is read without a lock, and it's only a hint for
> how often the per-CPU counts get folded, so racing with an update is
> harmless. Annotate the accesses.
>
> [ 0.953509] BUG: KCSAN: data-race in __vm_enough_memory / mm_compute_batch
>
> [ 0.953645] write to 0xffffffff825165d8 of 4 bytes by task 1 on cpu 0:
> [ 0.953692] mm_compute_batch+0xc2/0x120
> [ 0.953781] mm_compute_batch_init+0x1c/0x20
> ...
>
> [ 0.954325] read to 0xffffffff825165d8 of 4 bytes by task 41 on cpu 1:
> [ 0.954373] __vm_enough_memory+0x24/0x2b0
> [ 0.954444] shmem_inode_acct_blocks+0x1b3/0x230
> ...
>
> [ 0.955288] value changed: 0x00000020 -> 0x00005003
>
> Found with KCSAN while fuzzing under a deterministic hypervisor that's
> currently under development.
>
> ...
>
> --- a/include/linux/mman.h
> +++ b/include/linux/mman.h
> @@ -75,7 +75,8 @@ unsigned long vm_memory_committed(void);
>
> static inline void vm_acct_memory(long pages)
> {
> - percpu_counter_add_batch(&vm_committed_as, pages, vm_committed_as_batch);
> + percpu_counter_add_batch(&vm_committed_as, pages,
> + data_race(vm_committed_as_batch));
> }
ok, that'll squish the KCSAN report. A reasonable change as long as
we're sure this is not-a-bug.
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -211,7 +211,7 @@ void mm_compute_batch(int overcommit_policy)
> else
> memsized_batch = min_t(u64, ram_pages/nr/4, INT_MAX);
>
> - vm_committed_as_batch = max_t(s32, memsized_batch, batch);
> + WRITE_ONCE(vm_committed_as_batch, max_t(s32, memsized_batch, batch));
> }
But why this change?
prev parent reply other threads:[~2026-11-15 19:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 20:09 Mani Tofigh via B4 Relay
2026-11-15 19:38 ` Andrew Morton [this message]
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=20261115113851.f809d47b8356755c229278c2@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=devnull+mt4022.columbia.edu@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mt4022@columbia.edu \
--cc=rppt@kernel.org \
--cc=tz2294@columbia.edu \
/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®