From nobody Sat Jun 13 23:11:26 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D921B382394; Tue, 5 May 2026 10:55:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777978541; cv=none; b=a7slg2N9897Da9zNbJNK44f19V65allJD45Mizh+4HhyC/o6pjXiu60Isa2ko6/M3FOU1hT2cVbcVQRltMFsxH/rO/JIGUzUUMO1fY9zd49f1eOQ+s2uOLhxad91QZT4fVzRkcnK/NPyJje/b3MTLl/va/URiQM6iiLX9DJrUrg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777978541; c=relaxed/simple; bh=bVssichLw6qdjysZfvD+I7341lWXmCabWSTwidzB3Yc=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=jt/KbcyyPyqoBIINe+ggqDQLL72DGeNwWEt2BnaN6BmHJyKycBGq1FmHBw5UbvC7JYzhvvZu3L8tY+ridCoabsCQ+3DozO/C+Fj8ps0+l4HPPo3ZofR4fDA7e9hpzpvvulYcGyJBGHP43KKqS6iDtLqaOP1z4GFsWWO3TO7No4U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=kkt4OTlY; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=NvesiQeB; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="kkt4OTlY"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="NvesiQeB" Date: Tue, 05 May 2026 10:55:36 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777978538; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cr6DoQhk8/YOV+JMayiRQW+renhdsMMcpDWxCCFnJgk=; b=kkt4OTlYGB7er2kkBMOA8UjgyV8P53eObydJfQVec3h0Ic25EANk+tpWhSUoQJCoRLZAcr REcWCZ6fNACsSgnKEDvD61NE1Ci11YwIghrX6g6KoPjFspQgwYtZne+TH46VXvH8vhKel0 kmpsUOLa355yrVqtKLh02PkOQkIXorkykHMmpRD5ETomxux57Jrz4pcxfZ1FC0fqSX601l ZTejv5nwwSQOAySERXsGB13/BFrdRQX37T/XkVksMk5dzOM5gV+qSLRGHhxgv3RVE/HODD nL2KWxcfEqOmcu/uOCdRHgHuqvBseIV+Mv/csGpoHoZVVyHyvfDI2JfJUBptaQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777978538; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cr6DoQhk8/YOV+JMayiRQW+renhdsMMcpDWxCCFnJgk=; b=NvesiQeBdimNmnGdB2TWuuCz4fIHhMZSDEPI2yYOdLNz4bVpntlTn7I6I0PcoSdHSkJB0n zn3hZ6w2TsRdq2Bg== From: "tip-bot2 for Aniket Gattani" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] sched/membarrier: Modernize membarrier_global_expedited with cleanup guards Cc: Aniket Gattani , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260503212205.3714217-3-aniketgattani@google.com> References: <20260503212205.3714217-3-aniketgattani@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177797853688.424702.1772606465208765988.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the locking/core branch of tip: Commit-ID: a5959728548caf0aa17879342ee6571a29d54574 Gitweb: https://git.kernel.org/tip/a5959728548caf0aa17879342ee6571a2= 9d54574 Author: Aniket Gattani AuthorDate: Sun, 03 May 2026 21:22:04=20 Committer: Peter Zijlstra CommitterDate: Tue, 05 May 2026 12:50:48 +02:00 sched/membarrier: Modernize membarrier_global_expedited with cleanup guards Replace explicit lock/unlock and free calls with scoped guards and automatic cleanup constructs. Signed-off-by: Aniket Gattani Signed-off-by: Peter Zijlstra (Intel) Link: https://patch.msgid.link/20260503212205.3714217-3-aniketgattani@googl= e.com --- kernel/sched/membarrier.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/kernel/sched/membarrier.c b/kernel/sched/membarrier.c index 3d88e90..12b68a7 100644 --- a/kernel/sched/membarrier.c +++ b/kernel/sched/membarrier.c @@ -267,23 +267,19 @@ void membarrier_update_current_mm(struct mm_struct *n= ext_mm) =20 static int membarrier_global_expedited(void) { + cpumask_var_t __free(free_cpumask_var) tmpmask =3D CPUMASK_VAR_NULL; int cpu; - cpumask_var_t tmpmask; =20 if (num_online_cpus() =3D=3D 1) return 0; =20 - /* - * Matches memory barriers after rq->curr modification in - * scheduler. - */ - smp_mb(); /* system call entry is not a mb. */ - if (!zalloc_cpumask_var(&tmpmask, GFP_KERNEL)) return -ENOMEM; =20 + guard(mb)(); SERIALIZE_IPI(); - cpus_read_lock(); + guard(cpus_read_lock)(); + rcu_read_lock(); for_each_online_cpu(cpu) { struct task_struct *p; @@ -319,15 +315,6 @@ static int membarrier_global_expedited(void) smp_call_function_many(tmpmask, ipi_mb, NULL, 1); preempt_enable(); =20 - free_cpumask_var(tmpmask); - cpus_read_unlock(); - - /* - * Memory barrier on the caller thread _after_ we finished - * waiting for the last IPI. Matches memory barriers before - * rq->curr modification in scheduler. - */ - smp_mb(); /* exit from system call is not a mb */ return 0; } =20