Re: [PATCH v17 13/32] x86,fs/resctrl: Add an architectural hook called for each mount
From: Luck, Tony
Date: Mon Jan 05 2026 - 14:39:43 EST
On Mon, Jan 05, 2026 at 08:17:11PM +0100, Borislav Petkov wrote:
> On Wed, Dec 17, 2025 at 09:21:00AM -0800, Tony Luck wrote:
> > +void resctrl_arch_pre_mount(void)
> > +{
> > + static atomic_t only_once = ATOMIC_INIT(0);
> > + int old = 0;
> > +
> > + if (!atomic_try_cmpxchg(&only_once, &old, 1))
> > + return;
> > +}
>
> There's
>
> #define DO_ONCE(func, ...)
>
> Can't use that?
Learn something new every day. Yes, <linux/once.h> looks possible here.
Though I believe I'll need the DO_ONCE_SLEEPABLE() version since
resctrl_arch_pre_mount() grabs a mutex and various called functions
allocate memory using kmalloc().
-Tony