linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/mm: Fix log overwrite in CPA check_conflict()
@ 2025-06-19 17:42 Khalid Ali
  2025-06-20  9:01 ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Khalid Ali @ 2025-06-19 17:42 UTC (permalink / raw)
  To: dave.hansen, luto, peterz, tglx, mingo, bp
  Cc: x86, hpa, linux-kernel, Khalid Ali

From: Khalid Ali <khaliidcaliy@gmail.com>

On certain configurations (e.g. custom builds), check_conflict()
may produce a large number of warnings, flooding the kernel log
and overwriting earlier messages.

Observed warning:

  CPA  protect  Rodata RO: 0xffff888022a75000 - 0xffff888022a75fff
        PFN 22a75 req 8000000000000023 prevent 0000000000000002

Rate-limit these messages by replacing pr_warn() with
pr_warn_ratelimited().

Signed-off-by: Khalid Ali <khaliidcaliy@gmail.com>
---
 arch/x86/mm/pat/set_memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index 8834c76f91c9..bc5b62988b40 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -608,7 +608,7 @@ static inline void check_conflict(int warnlvl, pgprot_t prot, pgprotval_t val,
 	if (warnlvl > cpa_warn_level || !conflicts(prot, val))
 		return;
 
-	pr_warn("CPA %8s %10s: 0x%016lx - 0x%016lx PFN %lx req %016llx prevent %016llx\n",
+	pr_warn_ratelimited("CPA %8s %10s: 0x%016lx - 0x%016lx PFN %lx req %016llx prevent %016llx\n",
 		lvltxt[warnlvl], txt, start, end, pfn, (unsigned long long)pgprot_val(prot),
 		(unsigned long long)val);
 }
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/mm: Fix log overwrite in CPA check_conflict()
  2025-06-19 17:42 [PATCH] x86/mm: Fix log overwrite in CPA check_conflict() Khalid Ali
@ 2025-06-20  9:01 ` Peter Zijlstra
  2025-06-20 18:20   ` Khalid Ali
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2025-06-20  9:01 UTC (permalink / raw)
  To: Khalid Ali; +Cc: dave.hansen, luto, tglx, mingo, bp, x86, hpa, linux-kernel

On Thu, Jun 19, 2025 at 05:42:41PM +0000, Khalid Ali wrote:
> From: Khalid Ali <khaliidcaliy@gmail.com>
> 
> On certain configurations (e.g. custom builds), check_conflict()
> may produce a large number of warnings, flooding the kernel log
> and overwriting earlier messages.
> 
> Observed warning:
> 
>   CPA  protect  Rodata RO: 0xffff888022a75000 - 0xffff888022a75fff
>         PFN 22a75 req 8000000000000023 prevent 0000000000000002

That's not good. Your system is sick, limiting the warns isn't making
that better.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/mm: Fix log overwrite in CPA check_conflict()
  2025-06-20  9:01 ` Peter Zijlstra
@ 2025-06-20 18:20   ` Khalid Ali
  0 siblings, 0 replies; 3+ messages in thread
From: Khalid Ali @ 2025-06-20 18:20 UTC (permalink / raw)
  To: peterz; +Cc: dave.hansen, luto, tglx, mingo, bp, x86, hpa, linux-kernel

> > From: Khalid Ali <khaliidcaliy@gmail.com>
> > 
> > On certain configurations (e.g. custom builds), check_conflict()
> > may produce a large number of warnings, flooding the kernel log
> > and overwriting earlier messages.
> > 
> > Observed warning:
> > 
> >   CPA  protect  Rodata RO: 0xffff888022a75000 - 0xffff888022a75fff
> >         PFN 22a75 req 8000000000000023 prevent 0000000000000002

> That's not good. Your system is sick, limiting the warns isn't making
>that better.

There is nothing wrong. It is just misconfiguration, however i don't see why 
it is neccessary this warning to spam the dmesg log. Maybe it is better idea 
to limit printing warning instead of warning for every page in a section (i.e Rodata in my case)
would make sense. So by limiting logs in anyways is good. 

There is also overhead by logging if that happens. 

Thanks
Khalid Ali

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-20 18:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-19 17:42 [PATCH] x86/mm: Fix log overwrite in CPA check_conflict() Khalid Ali
2025-06-20  9:01 ` Peter Zijlstra
2025-06-20 18:20   ` Khalid Ali

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).