From: Rik van Riel <riel@surriel.com>
To: Nadav Amit <nadav.amit@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
kernel-team@meta.com, Dave Hansen <dave.hansen@linux.intel.com>,
luto@kernel.org, peterz@infradead.org,
Borislav Petkov <bp@alien8.de>,
the arch/x86 maintainers <x86@kernel.org>,
Sean Christopherson <seanjc@google.com>,
Thomas Gleixner <tglx@linutronix.de>,
Yu-cheng Yu <yu-cheng.yu@intel.com>
Subject: Re: [RFC PATCH v3 5/7] x86/mm: Introduce Remote Action Request
Date: Thu, 05 Jun 2025 15:40:27 -0400 [thread overview]
Message-ID: <2666b165d262a3bad73a3a4d886fa6d16bced03c.camel@surriel.com> (raw)
In-Reply-To: <9290E368-A0E1-4429-B14C-9AEF8DC71672@gmail.com>
On Thu, 2025-06-05 at 21:54 +0300, Nadav Amit wrote:
> Just few small things that jump out…
>
> > On 5 Jun 2025, at 19:35, Rik van Riel <riel@surriel.com> wrote:
> >
> > +void rar_cpu_init(void)
> > +{
> > + u64 r;
> > + u8 *bitmap;
> > + int max_payloads;
> > + int this_cpu = smp_processor_id();
> > +
> > + cpumask_clear(&per_cpu(rar_cpu_mask, this_cpu));
> > +
> > + /* The MSR contains N defining the max [0-N] rar payload
> > slots. */
> > + rdmsrl(MSR_IA32_RAR_INFO, r);
> > + max_payloads = (r >> 32) + 1;
> > +
> > + /* If this CPU supports less than RAR_MAX_PAYLOADS, lower
> > our limit. */
> > + if (max_payloads < rar_max_payloads)
> > + rar_max_payloads = max_payloads;
>
> Unless I am missing something, this looks very racy.
>
All the CPUs in the system should support the same
number rar_max_payloads, since they share the same
rar_action table.
> BTW: should rar_max_payloads be ro_after_init?
>
> > + pr_info_once("RAR: support %d payloads\n", max_payloads);
> > +
> > + bitmap = (u8 *)per_cpu(rar_action, this_cpu);
>
> this_cpu_ptr() would be cleaner (here and when using rar_cpu_mask).
A CPU cannot start using the rar_action table until
the wrmsl below.
That should ensure there is no race here.
Thank you for the cleanup ideas. I'll apply those for v4.
> > + /*
> > + * Allow RAR events to be processed while interrupts are
> > disabled on
> > + * a target CPU. This prevents "pileups" where many CPUs
> > are waiting
> > + * on one CPU that has IRQs blocked for too long, and
> > should reduce
> > + * contention on the rar_payload table.
> > + */
> > + r = RAR_CTRL_ENABLE | RAR_CTRL_IGNORE_IF;
>
> Do we really need r ?
I suppose not. The original code added another
value into r, but that hangs hard with today's
microcode :)
>
> > + wrmsrl(MSR_IA32_RAR_CTRL, r);
> > +}
>
>
--
All Rights Reversed.
next prev parent reply other threads:[~2025-06-05 19:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-05 16:35 [RFC PATCH v3 0/7] Intel RAR TLB invalidation Rik van Riel
2025-06-05 16:35 ` [RFC PATCH v3 1/7] x86/mm: Introduce Remote Action Request MSRs Rik van Riel
2025-06-05 16:35 ` [RFC PATCH v3 2/7] x86/mm: enable BROADCAST_TLB_FLUSH on Intel, too Rik van Riel
2025-06-05 16:35 ` [RFC PATCH v3 3/7] x86/mm: Introduce X86_FEATURE_RAR Rik van Riel
2025-06-05 16:35 ` [RFC PATCH v3 4/7] x86/apic: Introduce Remote Action Request Operations Rik van Riel
2025-06-05 16:35 ` [RFC PATCH v3 5/7] x86/mm: Introduce Remote Action Request Rik van Riel
2025-06-05 18:54 ` Nadav Amit
2025-06-05 19:40 ` Rik van Riel [this message]
2025-06-05 22:45 ` Nadav Amit
2025-06-06 0:03 ` Rik van Riel
2025-06-06 19:58 ` Nadav Amit
2025-06-05 16:35 ` [RFC PATCH v3 6/7] x86/mm: use RAR for kernel TLB flushes Rik van Riel
2025-06-05 16:35 ` [RFC PATCH v3 7/7] x86/mm: userspace & pageout flushing using Intel RAR Rik van Riel
2025-06-05 16:50 ` [RFC PATCH v3 0/7] Intel RAR TLB invalidation Sean Christopherson
2025-06-05 16:58 ` Dave Hansen
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=2666b165d262a3bad73a3a4d886fa6d16bced03c.camel@surriel.com \
--to=riel@surriel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=nadav.amit@gmail.com \
--cc=peterz@infradead.org \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yu-cheng.yu@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