[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aV7d7JTp_YX_4BRt@agluck-desk3>
Date: Wed, 7 Jan 2026 14:27:56 -0800
From: "Luck, Tony" <tony.luck@...el.com>
To: Reinette Chatre <reinette.chatre@...el.com>
CC: Borislav Petkov <bp@...en8.de>, Fenghua Yu <fenghuay@...dia.com>,
"Wieczor-Retman, Maciej" <maciej.wieczor-retman@...el.com>, Peter Newman
<peternewman@...gle.com>, James Morse <james.morse@....com>, Babu Moger
<babu.moger@....com>, Drew Fustini <dfustini@...libre.com>, Dave Martin
<Dave.Martin@....com>, "Chen, Yu C" <yu.c.chen@...el.com>, "x86@...nel.org"
<x86@...nel.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "patches@...ts.linux.dev"
<patches@...ts.linux.dev>
Subject: Re: [PATCH v17 13/32] x86,fs/resctrl: Add an architectural hook
called for each mount
On Wed, Jan 07, 2026 at 02:09:35PM -0800, Reinette Chatre wrote:
> Hi Tony,
> > If these DO_ONCE macros are ever used heavily in run-time code, it might
> > be better for once_lock and once_mutex to be statically defined in each
> > invocation of the DO_ONCE() and DO_ONCE_SLEEPABLE() macros. But the fact
> > that the static key protects the spinlock/mutex from being called may
> > mean that it is practically hard to hit problems.
>
> Which problems do you have in mind? One problem I see is that since these "once"
> functions are globally forced to be serialized this may cause unnecessary delays,
> for example during initialization. I do not think this impacts the resctrl intended
> usage since resctrl_arch_pre_mount() is not called during initialization and is
> already ok with delays (it is on a "slow" path).
Reinette
Yes. Unnecessary delays due to serialization. But that only happens if
the first call to a DO_ONCE*() instance overlaps with another first
call. It might be quite hard to hit that during boot unless there are
many uses of DO_ONCE*()
Looking at this some more, DO_ONCE() is overkill for mounting resctrl. The
static key part is there so that DO_ONCE*() can be safely used in some
hot code path without adding overhead of checking some "bool done" type
variable and branching around it. I don't see anyone except validation
executing resctrl mounts at multiple times per second.
But it does make the code easier to read with a single line with obvious
meaning instead of multiple lines with declarations, initializations,
and if () conditions.
-Tony
Powered by blists - more mailing lists