mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Zi Yan" <ziy@nvidia.com>
To: "Dennis Zhou" <dennis@kernel.org>, "Tejun Heo" <tj@kernel.org>,
	"Christoph Lameter" <cl@gentwo.org>,
	"Andrew Morton" <akpm@linux-foundation.org>
Cc: "Christoph Lameter" <cl@linux.com>, <linux-mm@kvack.org>,
	<linux-kernel@vger.kernel.org>,
	"Sashiko" <sashiko-bot@kernel.org>, "Zi Yan" <ziy@nvidia.com>
Subject: Re: [PATCH] mm/percpu-km: fix bitmap overflow and accounting in pcpu_create_chunk()
Date: Mon, 20 Jul 2026 15:20:31 -0400	[thread overview]
Message-ID: <DK3N4FET9ORM.327QYW7L79VOK@nvidia.com> (raw)
In-Reply-To: <20260709-fix-pcpu_create_chunk-in-percpu-km-v1-1-1f64745a84cc@nvidia.com>

On Thu Jul 9, 2026 at 3:12 PM EDT, Zi Yan wrote:
> In pcpu_create_chunk(), nr_pages is the total contiguous backing
> allocation, i.e., nr_units * pcpu_unit_pages, but pcpu_chunk_populated()
> uses it to set chunk->populated, whose size is pcpu_unit_pages, bitmap.
> Since bit N in chunk->populated means page offset N inside every unit is
> backed. When nr_units > 1, the function writes beyond chunk->populated. Fix
> it by using chunk->nr_pages.
>
> It also fixes the global pcpu_nr_empty_pop_pages accounting, since
> pcpu_balance_free() only iterates up to chunk->nr_pages.
>
> Commit a63d4ac4ab609 ("percpu: make percpu-km set chunk->populated bitmap
> properly") introduced the bitmap overflow issue. Later,
> commit b539b87fed37f ("percpu: implmeent pcpu_nr_empty_pop_pages and
> chunk->nr_populated") added pcpu_nr_empty_pop_pages and caused the
> accounting issue.

A gentle ping on this patch. It would be great to get some feedback.
Thanks.

>
> Fixes: a63d4ac4ab609 ("percpu: make percpu-km set chunk->populated bitmap properly")
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/patchset/20260703-keep-subpage-private-zero-at-free-v2-0-2970fe777dd6%40nvidia.com?part=1
> Assisted-by: Codex:GPT-5
> Signed-off-by: Zi Yan <ziy@nvidia.com>
> ---
> To make nr_units > 1 in percpu-km, we need SMP && !MMU && NEED_PER_CPU_KM.
> RISC-V can have SMP && !MMU. SH J2 can have it too. The kconfig analysis is
> done by Codex.
> ---
>  mm/percpu-km.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/percpu-km.c b/mm/percpu-km.c
> index 7ffe84adadb9d..65fd5580e4472 100644
> --- a/mm/percpu-km.c
> +++ b/mm/percpu-km.c
> @@ -75,7 +75,7 @@ static struct pcpu_chunk *pcpu_create_chunk(gfp_t gfp)
>  	chunk->base_addr = page_address(pages);
>  
>  	spin_lock_irqsave(&pcpu_lock, flags);
> -	pcpu_chunk_populated(chunk, 0, nr_pages);
> +	pcpu_chunk_populated(chunk, 0, chunk->nr_pages);
>  	spin_unlock_irqrestore(&pcpu_lock, flags);
>  
>  	pcpu_stats_chunk_alloc();
>
> ---
> base-commit: 59e34180e138a293260301c139cf7ee800978533
> change-id: 20260709-fix-pcpu_create_chunk-in-percpu-km-6dfa8f28b175
>
> Best regards,




-- 
Best Regards,
Yan, Zi


  reply	other threads:[~2026-07-20 19:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 19:12 Zi Yan
2026-07-20 19:20 ` Zi Yan [this message]
2026-07-20 22:16   ` Dennis Zhou

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=DK3N4FET9ORM.327QYW7L79VOK@nvidia.com \
    --to=ziy@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@gentwo.org \
    --cc=cl@linux.com \
    --cc=dennis@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sashiko-bot@kernel.org \
    --cc=tj@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®