public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/7] cpu isolation: infra to block interference to select CPUs
@ 2022-09-08 19:28 Marcelo Tosatti
  2022-09-08 19:29 ` [RFC PATCH 1/7] cpu isolation: basic block interference infrastructure Marcelo Tosatti
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2022-09-08 19:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: Frederic Weisbecker, Juri Lelli, Daniel Bristot de Oliveira,
	Prasad Pandit, Valentin Schneider, Yair Podemsky, Thomas Gleixner

There are a number of codepaths in the kernel that interrupt
code execution in remote CPUs. A subset of such codepaths are
triggered from userspace and can therefore return errors.

Introduce a cpumask named "block interference", writable from userspace.

This cpumask (and associated helpers) can be used by code that executes
code on remote CPUs to optionally return an error.

Note: the word "interference" has been chosen since "interruption" is
often confused with "device interrupt".

To protect readers VS writers of this cpumask, a per-CPU read-write
semaphore is used. This is acceptable since the codepaths which 
trigger such interferences are not (or should not be) hot.

What is proposed is to incrementally modify code that can return errors
in two ways:

1) Introduction of fail variants of the functions that generate 
code execution on remote CPUs. This way the modified code should
look like:

        block_interf_read_lock();

        ret = smp_call_func_single_fail() / stop_machine_fail() / ...

        block_interf_read_unlock();

This is grep friendly (so one can search for smp_call_function_* variants)
and re-uses code.

2) Usage of block interference CPU mask helpers. For certain 
users of smp_call_func_*, stop_machine_* functions it 
is natural to check for block interference CPUs before
calling the functions for remote code execution.

For example if its not desirable to perform error handling at
smp_call_func_* time, or if performing the error handling requires
unjustified complexity. Then:


        block_interf_read_lock();

	if target cpumask intersects with block interference cpumask {
		block_interf_read_unlock();
		return error
	}

	...
        ret = smp_call_function_single / stop_machine() / ...
	...

        block_interf_read_unlock();

Regarding housekeeping flags, it is usually the case that initialization might
require code execution on interference blocked CPUs (for example MTRR 
initialization, resctrlfs initialization, MSR writes, ...). Therefore 
tagging the CPUs after system initialization is necessary, which
is not possible with current housekeeping flags infrastructure.

This patchset converts clockevent and clocksource unbind, perf_event_open
system call, and /proc/mtrr writes, but there are several more users
to convert (eg: MSR reads/writes, resctrlfs, etc).

Sending this as an RFC to know whether folks think this is the
right direction.



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

end of thread, other threads:[~2022-09-08 19:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-08 19:28 [RFC PATCH 0/7] cpu isolation: infra to block interference to select CPUs Marcelo Tosatti
2022-09-08 19:29 ` [RFC PATCH 1/7] cpu isolation: basic block interference infrastructure Marcelo Tosatti
2022-09-08 19:29 ` [RFC PATCH 2/7] introduce smp_call_func_single_fail Marcelo Tosatti
2022-09-08 19:29 ` [RFC PATCH 3/7] introduce _fail variants of stop_machine functions Marcelo Tosatti
2022-09-08 19:29 ` [RFC PATCH 4/7] clockevent unbind: use smp_call_func_single_fail Marcelo Tosatti
2022-09-08 19:29 ` [RFC PATCH 5/7] timekeeping_notify: use stop_machine_fail when appropriate Marcelo Tosatti
2022-09-08 19:29 ` [RFC PATCH 6/7] perf_event_open: check for block interference CPUs Marcelo Tosatti
2022-09-08 19:29 ` [RFC PATCH 7/7] mtrr_add_page/mtrr_del_page: " Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox