public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Frederic Weisbecker <frederic@kernel.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Daniel Bristot de Oliveira <bristot@kernel.org>,
	Prasad Pandit <ppandit@redhat.com>,
	Valentin Schneider <vschneid@redhat.com>,
	Yair Podemsky <ypodemsk@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Marcelo Tosatti <mtosatti@redhat.com>
Subject: [RFC PATCH 2/7] introduce smp_call_func_single_fail
Date: Thu, 08 Sep 2022 16:29:01 -0300	[thread overview]
Message-ID: <20220908195111.710559374@redhat.com> (raw)
In-Reply-To: 20220908192859.546633738@redhat.com

Introduce smp_call_func_single_fail, which checks if
the target CPU is tagged as a "block interference" CPU,
and returns an error if so.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: linux-2.6/include/linux/smp.h
===================================================================
--- linux-2.6.orig/include/linux/smp.h
+++ linux-2.6/include/linux/smp.h
@@ -50,6 +50,9 @@ extern unsigned int total_cpus;
 int smp_call_function_single(int cpuid, smp_call_func_t func, void *info,
 			     int wait);
 
+int smp_call_func_single_fail(int cpuid, smp_call_func_t func, void *info,
+			     int wait);
+
 void on_each_cpu_cond_mask(smp_cond_func_t cond_func, smp_call_func_t func,
 			   void *info, bool wait, const struct cpumask *mask);
 
Index: linux-2.6/kernel/smp.c
===================================================================
--- linux-2.6.orig/kernel/smp.c
+++ linux-2.6/kernel/smp.c
@@ -25,6 +25,7 @@
 #include <linux/nmi.h>
 #include <linux/sched/debug.h>
 #include <linux/jump_label.h>
+#include <linux/sched/isolation.h>
 
 #include "smpboot.h"
 #include "sched/smp.h"
@@ -782,6 +783,30 @@ int smp_call_function_single(int cpu, sm
 }
 EXPORT_SYMBOL(smp_call_function_single);
 
+/*
+ * smp_call_func_single_fail - Run a function on a specific CPU,
+ * failing if any target CPU is marked as "no ipi".
+ * @func: The function to run. This must be fast and non-blocking.
+ * @info: An arbitrary pointer to pass to the function.
+ * @wait: If true, wait until function has completed on other CPUs.
+ *
+ * Returns 0 on success, else a negative status code.
+ */
+int smp_call_func_single_fail(int cpu, smp_call_func_t func, void *info,
+			     int wait)
+{
+	int err;
+
+	block_interf_assert_held();
+	if (block_interf_cpu(cpu))
+		return -EPERM;
+
+	err = smp_call_function_single(cpu, func, info, wait);
+
+	return err;
+}
+EXPORT_SYMBOL(smp_call_func_single_fail);
+
 /**
  * smp_call_function_single_async() - Run an asynchronous function on a
  * 			         specific CPU.



  parent reply	other threads:[~2022-09-08 19:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Marcelo Tosatti [this message]
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

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=20220908195111.710559374@redhat.com \
    --to=mtosatti@redhat.com \
    --cc=bristot@kernel.org \
    --cc=frederic@kernel.org \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ppandit@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=vschneid@redhat.com \
    --cc=ypodemsk@redhat.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