From mboxrd@z Thu Jan 1 00:00:00 1970 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 89815281368 for ; Sun, 16 Nov 2025 20:48:51 +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=1763326133; cv=none; b=puOtwn7TdqkiFLyrr+6cNF2PpmTO+6d7544L8VxObLtvG3Cesg6+t0Tz1M2Xc0XIed66Wy1sbUDxfcqtfsfjONsnzC/1Yg2BN58RQtBspKX+IzTK7WIXdRxhaBZfR1WRq1bC3jwsbajAuTMYnIVdeaSnMRKGqpK1O7EwlW1742U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763326133; c=relaxed/simple; bh=6NMMiQ3m/2gfQmlgdJTCrs+kHt/FL1I049VHc0YeqVY=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=kGizaBbA7D5f9hafBM/f9hpdDuJhHTSmLTTDoxkoBos6LLdTh6m89moWFRtMFYSrCISY3ofdS56/cRezJcuqcZQNbM66GR66alX6yZOTCAffqL7R0j9/g9Q4M/tn/BlC3Lwbk0jm82MghRuokZGtpELYSZ+uTffPxAYrPskguyE= 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=qeBppKZf; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=KjrGC7H6; 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="qeBppKZf"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="KjrGC7H6" Message-ID: <20251104075427.153226202@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1763326130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=c6wklmyXXcTM+63vQlWlcGrC6fyaffTmc+KcD17lbPI=; b=qeBppKZfwQLJBDV9hf58x9P1m+wjcSgLVVpV1eUD56u+4yuccCTn9tny+IkcgS7s7bvZZu GsbXGKMbRd/PgoKiBJMghA1xpUCwtOV5rJL3HzhSU78I54kyfFBDaDyZuBT24qaNAdCEnV 7CM2JvMJg+5fE7lfXoJ811JdxN375WWTPoy/p/e8nhSaNBxTLYMFGL4wIx17FEPWI0X17c 2xb1KeFd5h7uiroV9PNw26Mqd8l4mJDD8PkaCFGTpYk73ec3s4CSswp9e29g6l5pf7magt zHLB7L5VJEj06tZW6URcB+RSnviDLE+pdod6ogo8HxId9FZT/brRcqUs+vh9yw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1763326130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=c6wklmyXXcTM+63vQlWlcGrC6fyaffTmc+KcD17lbPI=; b=KjrGC7H6Xpjs3Wrao6JsLIFUDE87g2v/4iaX5UWQ6MbW4Nr6K7Fgg69EQgxeCZ6Arx3gX1 mPSz4qz6gXMCzeBQ== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Gabriele Monaco , Mathieu Desnoyers , Michael Jeanson , Jens Axboe , "Paul E. McKenney" , "Gautham R. Shenoy" , Florian Weimer , Tim Chen , Yury Norov , Shrikanth Hegde Subject: [patch V4 08/20] sched/mmcid: Use cpumask_weighted_or() References: <20251104075053.700034556@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Sun, 16 Nov 2025 21:48:49 +0100 (CET) Use cpumask_weighted_or() instead of cpumask_or() and cpumask_weight() on the result, which walks the same bitmap twice. Results in 10-20% less cycles, which reduces the runqueue lock hold time. Signed-off-by: Thomas Gleixner Reviewed-by: Mathieu Desnoyers --- kernel/sched/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -10377,6 +10377,7 @@ void call_trace_sched_update_nr_running( static inline void mm_update_cpus_allowed(struct mm_struct *mm, const struct cpumask *affmsk) { struct cpumask *mm_allowed; + unsigned int weight; if (!mm) return; @@ -10387,8 +10388,8 @@ static inline void mm_update_cpus_allowe */ guard(raw_spinlock)(&mm->mm_cid.lock); mm_allowed = mm_cpus_allowed(mm); - cpumask_or(mm_allowed, mm_allowed, affmsk); - WRITE_ONCE(mm->mm_cid.nr_cpus_allowed, cpumask_weight(mm_allowed)); + weight = cpumask_weighted_or(mm_allowed, mm_allowed, affmsk); + WRITE_ONCE(mm->mm_cid.nr_cpus_allowed, weight); } void sched_mm_cid_exit_signals(struct task_struct *t)