From nobody Mon Feb 9 20:55:04 2026 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 00DE7328619 for ; Tue, 18 Nov 2025 02:50:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763434257; cv=none; b=T/GyEZJp3s+/neMqI5gV+XAbqoPTC1MhH93BTutg9UQV+tvGgSXmVL4ra2ZCpfFP6pXqy1R1JdlLv3H9l1F6RBFWtjxqDubUSAp2IpaUCTf6GFmCt6LCV0Bm9uCT9dGmW9y5ImJKq/izbsI+XUVzYRjb+0t9f0Y9qJjyEmXcyKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763434257; c=relaxed/simple; bh=2ZrRnf7stY83G4Y0lqiUHbFDbs2NG+SjOJBTsZJMl/s=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JrIZB1xuwXdu2CVLpXiD1ppETEYAJhndwq8WnQzcPfe500WdFUyspZRpO/3YshuLhpwi75nO9DOhHDSsGA0hX1XGullk3EQ4KYi7W0ixds60DlFIT7lpRheOXXJLfGz9FkAAG4CtnHjzFbrnzEHiBUH+mxqf0ta31fn2+CH0pLo= 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=FGzk3slM; arc=none smtp.client-ip=209.85.214.181 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="FGzk3slM" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-297ef378069so47900265ad.3 for ; Mon, 17 Nov 2025 18:50:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1763434255; x=1764039055; 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=FGzk3slMG3+neaY443MeuAuuZlqsMloqmnUbTXZ9xG6//x6F/HshSv18AkiOt913E7 XnJSC1SuqZovDKTW7KeMQK/W16zcFJvfOZDSdVtjD6dUa6JS+wWU82sEbonIGTvYE0Np /6BT3DIN3s9OWHVqrnG0rfw9lwYpI5IWyIclzuzIIX4ftK+sMhqtHA/SMQewvVfSieqg INSboRHp+ojqHQaTeGOZrDhlPjN3reJvbQd552IhC3B8uPQrukzOS4zbamuBkj6plPJs u7i1iBkWR75y69i+yySJt7Kj+PUTleVLsfiV5c1dEMGbjgLh/C/Fit6G7/h5gcqEHg4x I1xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763434255; x=1764039055; 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=Azx2X3TC4yOLqHvEqOV9rvHoCXIXBbWoMRE4hEHFtJGSwI+laoCFtee5xelhb9Tz0l RcVx4JwE6agmN9HvgmvqQ7KeiRM061HnGk2jmezno1dhvQ5M8KWJ5D/rURZzDhL6Ioay Dtk7F0Uye9dx1wdlau46Sk7QM8t6/NlCppeRwvDmdywXrAPUIkp4JCvAxWKYdjzvmbp6 pQIeFPKHvR5arX7uKZEbD1jTHH1LG310zJ7o37CCsPmNWeAppb8t+jzyfQBhgCPz53FX a1Nvt/WrOIXQqXujY2STg/7yRChtnfNql6OR/Cggu02UcidAPg240UMqvGjrlYfEfQE5 sTwA== X-Forwarded-Encrypted: i=1; AJvYcCV+guw9O4TLVdMAS3SS0GQW625Z8/01dbww7wdvfFys9q8+Y4OPSb6qsEbwjPF0psDxecqql15SDyOA7ak=@vger.kernel.org X-Gm-Message-State: AOJu0YzkjFMD/aVl+aHT3V7oC6tEzBafWo8senGbZs7qxsffgjVqzhNp Xa8BzariMCGQLlD4jJnwP0FLQF/9XMsMVjsQl5QQ7cn9c/lJ10ZvtwinqdDRx1i/LE0= X-Gm-Gg: ASbGnctSLvQlmWx8s/yXHKEOieLOhj5UAnWKB21tFiP+r2KUBbpg4o0gq9buomLIv// U8sxFdowIMsvi0YuhViJ7+t3HGxZvIZU58OJrSBkK+Ojute4AII96WSS3DhDaETDl+tqQhsqRf/ bb5jqWijCO+2BmEAgu76pjL1WLdCVUStKKHTDMTuFOMQVui0WDgQMgh4I8AcQrSQfDIxQZoxNU4 V/it/JaOa1JsgqSPDMnWjdTDO1lqjwd/clH7goB0fnG6V7EavpRWc6ozthSV9U4WEyqNikxls/t WgSapbBmm1ewnVFhBnIqWlX/S8RcMWlj8EevSg0F8MavjazNx2WVo1oFq9VEASiBD/yNaWq71Cl yjYuv8embR3+TLANf1BqUjJzIEDUTHas7Kse0T4Z5KYUsVpXtOIRMbiDhMkvPvFMGtd8o9I0tVh nxxkyKL1Oy/ZRdbo4vHgalDxJ4rXsS5HP2SQ== X-Google-Smtp-Source: AGHT+IGDZAMo0ZQv0dHXusB9vvga1W8EiCZHdD/dMDMq4XG4NK+75rIo7LnojyDw0hkA9sDDjE1JTA== X-Received: by 2002:a17:903:4b07:b0:295:9627:8cbd with SMTP id d9443c01a7336-2986a73b6bamr160750285ad.33.1763434255050; Mon, 17 Nov 2025 18:50:55 -0800 (PST) Received: from L6YN4KR4K9.bytedance.net ([139.177.225.241]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2985c234809sm156022065ad.19.2025.11.17.18.50.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 17 Nov 2025 18:50:54 -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 v2 3/8] smp: move num_other_online_cpus() into smp.h Date: Tue, 18 Nov 2025 10:50:10 +0800 Message-Id: <20251118025015.42491-4-cuiyunhui@bytedance.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: <20251118025015.42491-1-cuiyunhui@bytedance.com> References: <20251118025015.42491-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