From nobody Mon Dec 1 22:38:59 2025 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 265371DF261 for ; Thu, 27 Nov 2025 12:53:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764248030; cv=none; b=NxUoAguLS3hvdUSmAS+GJn8ag4pbPuoFCk4nUss9GLnV+myX2Zyt/GW19ts5IsrWii4FLK0KyAdtWkycSxzzIxHTif+4MjZBoDyyjGxWudbJcCpb+15nN0NLmy72gK0KvKRm1r4r2bgMamGGqzJvAZx+3CabvHaCoD5/lp0J51E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764248030; c=relaxed/simple; bh=2ZrRnf7stY83G4Y0lqiUHbFDbs2NG+SjOJBTsZJMl/s=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KoSx7DYaajmaApqEteZ3kZvH0PzJM2v99Ley9jIS3qCvQyHWD6z76EtHp8j9K4curCh3W2MmPfrquPIX0ZnxwtPPA7TB1Lql9qFfyLEeK/VZXRE3UZlziRV5EbWAF8Lveq1bGW4Iwum5ObouPErYla0Z7PRgX8hAUAUUNbxQE90= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=QtnFyBv4; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="QtnFyBv4" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-29558061c68so11649445ad.0 for ; Thu, 27 Nov 2025 04:53:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1764248024; x=1764852824; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=yk19cubzYI59vS2m7ARmuI6dwPXbjagJNzaP0UWxsjY=; b=QtnFyBv4iWZF/IZR4PYPheT5IrDGUlc43sQUAAMyI3b0+BHS7keXUM32KzCeiF1xyb qqC1l/fZZnQNqzrwqRtq55DIcmo7VzczY2goaEpxs2qF/7xuq6VSMAEX4ar3OFbxWOq2 +G+OQLTTKxMUWqnMY/t8gazEOPwEfOg1EUQe+o7579S1AONPDq9j8Weuw8JS6+6xDWZr zKyXl6bYl6mPf7eTGVbKgjHkN7nFGFFLJHTZWE9/b9EReUBApUzYY7rtxwgcMFZ9bMbB 4yJ/4iDCRgxtPe2J97LW0lriYjK3YWfPYCOyBWUJ4566SWCBl2JuTP0H4FzBFdghWP5n TjRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764248024; x=1764852824; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=yk19cubzYI59vS2m7ARmuI6dwPXbjagJNzaP0UWxsjY=; b=mwTRixTr4STt1l7XkvSyPeThl1HwbKbaGpDLhPov/HzTFRmJPHMqc+pun+kK+rhMyt t49lJHd5H6HGNgCoLG2T2QmKPd2vU8U8udAouFr6za+s/ipFx7Oc/UR3GV/pp2hmcTH6 uNUP6LHx8hQTCaLGg+528mQyWXh1tE44zbHC7Grznf0MGuK9A1DOl+LlyyK9a6my87qZ 4znOLiWX5u321mJlhNQA4pwrDnKPzoVlWfR9jSmMEGowoRv51AnK/B0FzaqX6nFPT50U iSOsHEw3By3etKbVGNyubebFIYuQ7CnSMoQQ6b1/lOGh8Gb0mrtPGyKZVPSqM1EZTQRm Inxw== X-Forwarded-Encrypted: i=1; AJvYcCW1fkVDCE0Oqb/4NKadlEIhXRJAqmRIcg+GExhF6/UkqCZ13haoKW+la/uS3/+qYyEtdRU+ABY3ttdljiY=@vger.kernel.org X-Gm-Message-State: AOJu0Yy4DokD8lHs+3pZAgGeknxN56KzvmGG1A2h2ds3RUXrSjWpS7oz dCd6QAo3reg46ekDC67beoly9YMFN8imLmnPCbsnPjr4H1d8K/uxw8rAJiBcwhkQdto= X-Gm-Gg: ASbGncvdHOur53iOITijTyxbHprtJes+cngQFbKiEMEn+YVPXh7VIJriWZK9XmliIEL N0rWwBbimQ9BLZZ0tbRhPpUdYaB9gpqmQXx4sSDx7LHHXCAHHFludJcASoGb4HpkF7ZSTcZl5UR u6JVVrNkFeJz7JCoxNQawmozq3HH+0hfYpgmHdlSkfbhnXZ0c/c8VVqHi8ustDqYTwAHiaW6KDO nAUWSHVjFHPpbaPqujx1XK7TnKuIa8HO5QAxWrl6Sbn65qD9ejUlhpnFb4KNJbRK/nbdZtyQALL HZjxHb7J6QqOj9uV/COC9OJrDijeWwcOba4YccvRaVZ+oT/ubzAD1bvAoQUrWSNep6N8uKX48D7 gU5So4M9h6S06fa50nKyEPABrvZWMQ9lGYjZtPiA4+jRlSJnswwTnVLRhr/x2zY0X0siLmpkFQ6 8M/Y827n50Dbf/iaRE5B6FRtUHrMeItMhZk1VPKqiGbks5b6s5Co/qSQI= X-Google-Smtp-Source: AGHT+IFWj/Ge/LlTmUk4BGvK2jv7sYmbYypwkakcaLNVvSYRcxAzMelD2Tv37gWsl3Gu0g8hT2LecA== X-Received: by 2002:a17:903:98d:b0:297:fec4:1557 with SMTP id d9443c01a7336-29b6bfaf6c0mr239034795ad.60.1764248023704; Thu, 27 Nov 2025 04:53:43 -0800 (PST) Received: from L6YN4KR4K9.bytedance.net ([139.177.225.225]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29bce470347sm17771255ad.41.2025.11.27.04.53.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Nov 2025 04:53:43 -0800 (PST) From: Yunhui Cui To: conor@kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, cuiyunhui@bytedance.com, luxu.kernel@bytedance.com, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, jassisinghbrar@gmail.com, conor.dooley@microchip.com, valentina.fernandezalanis@microchip.com, catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, timothy.hayes@arm.com, lpieralisi@kernel.org, arnd@arndb.de, kees@kernel.org, tglx@linutronix.de, viresh.kumar@linaro.org, boqun.feng@gmail.com, linux-arm-kernel@lists.infradead.org, cleger@rivosinc.com, atishp@rivosinc.com, ajones@ventanamicro.com Subject: [PATCH v3 3/8] smp: move num_other_online_cpus() into smp.h Date: Thu, 27 Nov 2025 20:53:00 +0800 Message-Id: <20251127125305.89961-4-cuiyunhui@bytedance.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: <20251127125305.89961-1-cuiyunhui@bytedance.com> References: <20251127125305.89961-1-cuiyunhui@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove duplicate definitions from arm64/riscv, add unified implementation in smp.h. Signed-off-by: Yunhui Cui --- arch/arm64/kernel/smp.c | 11 ----------- arch/riscv/kernel/smp.c | 11 ----------- include/linux/smp.h | 11 +++++++++++ 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 68cea3a4a35ca..2d1e7839dc9b0 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -1171,17 +1171,6 @@ void tick_broadcast(const struct cpumask *mask) } #endif =20 -/* - * The number of CPUs online, not counting this CPU (which may not be - * fully online and so not counted in num_online_cpus()). - */ -static inline unsigned int num_other_online_cpus(void) -{ - unsigned int this_cpu_online =3D cpu_online(smp_processor_id()); - - return num_online_cpus() - this_cpu_online; -} - void smp_send_stop(void) { static unsigned long stop_in_progress; diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c index 9dbcb9a06a96d..669325e68a21a 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -272,17 +272,6 @@ void smp_send_stop(void) } =20 #ifdef CONFIG_KEXEC_CORE -/* - * The number of CPUs online, not counting this CPU (which may not be - * fully online and so not counted in num_online_cpus()). - */ -static inline unsigned int num_other_online_cpus(void) -{ - unsigned int this_cpu_online =3D cpu_online(smp_processor_id()); - - return num_online_cpus() - this_cpu_online; -} - void crash_smp_send_stop(void) { static int cpus_stopped; diff --git a/include/linux/smp.h b/include/linux/smp.h index 18e9c918325e5..5300c5c14232b 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h @@ -275,6 +275,17 @@ static inline int get_boot_cpu_id(void) #define get_cpu() ({ preempt_disable(); __smp_processor_id(); }) #define put_cpu() preempt_enable() =20 +/* + * The number of CPUs online, not counting this CPU (which may not be + * fully online and so not counted in num_online_cpus()). + */ +static inline unsigned int num_other_online_cpus(void) +{ + unsigned int this_cpu_online =3D cpu_online(smp_processor_id()); + + return num_online_cpus() - this_cpu_online; +} + /* * Callback to arch code if there's nosmp or maxcpus=3D0 on the * boot command line: --=20 2.39.5