mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: "Li Zhe" <lizhe.67@bytedance.com>
Cc: <tglx@kernel.org>, <mingo@redhat.com>, <bp@alien8.de>,
	<dave.hansen@linux.intel.com>, <hpa@zytor.com>, <x86@kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86/lib: make clean_cache_range() zero-size safe
Date: Thu, 3 Sep 2026 09:29:06 -0700	[thread overview]
Message-ID: <20260903092906.764a9098663aaae3e4e8fa48@linux-foundation.org> (raw)
In-Reply-To: <20260903071125.1946-1-lizhe.67@bytedance.com>

On Thu,  3 Sep 2026 15:11:25 +0800 "Li Zhe" <lizhe.67@bytedance.com> wrote:

> clean_cache_range() writes back each cache line in the range
> [addr, addr + size). A zero-size range is empty and should not perform
> any cache maintenance operation.
> 
> As pointed out by Sashiko [1], clean_cache_range(addr, 0) currently can
> still execute one CLWB when addr is not cache-line aligned. With size 0,
> vend is equal to addr. However, the loop starts from the
> cacheline-aligned address containing addr. If addr is not cacheline
> aligned, that rounded-down start is below vend, so the loop can execute
> one CLWB even though the requested range is empty.
> 
> That gives zero-size callers observable side effects. For example,
> arch_wb_cache_pmem(addr, 0) should not write back any cache line, and
> memcpy_flushcache(dst, src, 0) should preserve the usual zero-length
> copy semantics. If the rounded-down line is not mapped, the stray CLWB
> can also fault.
> 
> Return immediately from clean_cache_range() for size 0.

Thanks.  Sashiko might have found a few similar issues in there:
	https://sashiko.dev/#/patchset/20260903071125.1946-1-lizhe.67@bytedance.com

  reply	other threads:[~2026-09-03 16:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03  7:11 Li Zhe
2026-09-03 16:29 ` Andrew Morton [this message]
2026-09-04  7:54   ` Li Zhe

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=20260903092906.764a9098663aaae3e4e8fa48@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizhe.67@bytedance.com \
    --cc=mingo@redhat.com \
    --cc=tglx@kernel.org \
    --cc=x86@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®