Thread (10 messages) 10 messages, 4 authors, 2021-10-06

Re: [PATCH v2 2/2] x86/hyperv: remove on-stack cpumask from hv_send_ipi_mask_allbutself

From: Wei Liu <wei.liu@kernel.org>
Date: 2021-09-11 15:24:34
Also in: lkml

On Sat, Sep 11, 2021 at 03:09:50PM +0000, Michael Kelley wrote:
From: Wei Liu <wei.liu@kernel.org> Sent: Friday, September 10, 2021 11:57 AM
[...]
quoted
-static bool __send_ipi_mask(const struct cpumask *mask, int vector)
+static bool __send_ipi_mask(const struct cpumask *mask, int vector,
+		bool exclude_self)
 {
-	int cur_cpu, vcpu;
+	int cur_cpu, vcpu, this_cpu = smp_processor_id();
 	struct hv_send_ipi ipi_arg;
 	u64 status;
+	unsigned int weight;

 	trace_hyperv_send_ipi_mask(mask, vector);

-	if (cpumask_empty(mask))
+	weight = cpumask_weight(mask);
+
+	/*
+	 * Do nothing if
+	 *   1. the mask is empty
+	 *   2. the mask only contains self when exclude_self is true
+	 */
+	if (weight == 0 ||
+	    (exclude_self && weight == 1 && cpumask_first(mask) == this_cpu))
Nit:  cpumask_test_cpu(this_cpu, mask) would seem to be a better fit for this
use case than cpumask_first().  But either works.
I will adjust the code when I commit this patch.

Wei.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help