Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4589362rwd; Tue, 23 May 2023 09:34:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4YHN0Ibh4iG/KHdORgIyre/UteoRvzgi2Aa6UbjhekK3BoBcDKcCP13ABrm8Z3ZHoA4vFY X-Received: by 2002:a05:6a00:2e01:b0:64d:3fb3:9ed9 with SMTP id fc1-20020a056a002e0100b0064d3fb39ed9mr17506088pfb.23.1684859654769; Tue, 23 May 2023 09:34:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684859654; cv=none; d=google.com; s=arc-20160816; b=SNQK4Xbjhbi3YNN1uMlp7iROQfIzya6KnuS0T5VT7m5YamK/WQymsn9fJTxlFLqCOA IaH/uVBfAAGeEr+UowicbvUdrov109ag5hNQ78ANaIyuYNsWh/k/qA2bt7jNy22AVE6a +VabwSw9UsNOiPCD6Zc6DL71pSxxb55GYSPS6OPGhKCxPPggblNpe1aUk4skZxMEhPxP nLi9vPW/fnkrrceMaZZ6iQMSFM4qWTvjVkQb9YBYsHHgeEZZyNU4KjCph+CgipPQNUGJ tdsbFNRJ7dep0gi6pzRGJASn2uxT6Vi9+Q2L8zxv0CcvzXqRCeCKf+HxtxBQysAdvrub UVgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=1o3nB3jocoaLuOI5Obrg0Pu8tnjT0B5WS7aKcG30c3Y=; b=GGehjHJIabhrZBXleuHFAdITF6sJpuKCiGAX7+5hBJHKKeIuYXrXAqZH+jA75r2Cj/ peT1RuOSx3UVfTsT0bACzGESXOuOJERV79tx+3vJZS6v2a1MbsVlGDJ0RWVC/L8Y7GTP yXBtcWYNSelz5MD0aiLdvij0CnTQCYrKhMyfXJZ1q8EXoJ9RHtQAYCnKrn7qdlZ8HtuY wzGPqjZKUDlV/TruaZBoQbcITtjYmHc78kUbtcvRKU9nUx2vRKDPUCKkSu01bP02AHa3 7/A+rbcbSuDQnUN8CA/13YD+SQJ36nwhZDEXM3DcB9uEl7fSIyrcI1A9RcREhE+HAseb 3BHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Q4wL1SOb; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="Vmkwzh/2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z15-20020aa79e4f000000b0063d33dc49e8si1347668pfq.363.2023.05.23.09.34.01; Tue, 23 May 2023 09:34:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Q4wL1SOb; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="Vmkwzh/2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236990AbjEWQOD (ORCPT + 99 others); Tue, 23 May 2023 12:14:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236276AbjEWQOC (ORCPT ); Tue, 23 May 2023 12:14:02 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 119B8C2; Tue, 23 May 2023 09:14:00 -0700 (PDT) Date: Tue, 23 May 2023 16:13:57 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684858438; 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=1o3nB3jocoaLuOI5Obrg0Pu8tnjT0B5WS7aKcG30c3Y=; b=Q4wL1SOb9nb9hZJ1ZPygVvgEoQvInC21KXzRQtsc/lO3otIZhyvgiBCTSA1UYwMD16KNrF zrV8is0x6hkvRMom/DUqX56fqXhwg6iBByudcInyhv5xMTOvmRIjq8Y5ry1Di2UuM/Tb47 hM7fWJtDadpsE/FKSCkk4gVJJ7m5ifLyiRnXH7anDyoYRM+xa2i4Tp7TMXibLGmLaVDwsH hEqLP82Rewf2Y6G8wGcqCvnvYokBJR+fPYF1Vg3Ltp6vARkxW90dQzC62i/XioLPljtCgT 9Pz8vWVB4IxhhRSvNE8EYDzlWKBlGngsRkDvTHKQNb+8DW1UJ0cpNZ37lmQbRw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684858438; 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=1o3nB3jocoaLuOI5Obrg0Pu8tnjT0B5WS7aKcG30c3Y=; b=Vmkwzh/2Q4t7kGk6VPI59MRREU6bQWu0aOWjFj/YXYkWApAM2zdfCBYGJvBhBkryOcKayc 2ZenPJQsd0wG1AAw== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: smp/core] cpu/hotplug: Fix off by one in cpuhp_bringup_mask() Cc: Mark Brown , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <87wn10ufj9.ffs@tglx> References: <87wn10ufj9.ffs@tglx> MIME-Version: 1.0 Message-ID: <168485843734.404.16847199234383553669.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the smp/core branch of tip: Commit-ID: 06c6796e0304234da65e70577f354cb194086521 Gitweb: https://git.kernel.org/tip/06c6796e0304234da65e70577f354cb194086521 Author: Thomas Gleixner AuthorDate: Tue, 23 May 2023 01:12:26 +02:00 Committer: Thomas Gleixner CommitterDate: Tue, 23 May 2023 18:06:40 +02:00 cpu/hotplug: Fix off by one in cpuhp_bringup_mask() cpuhp_bringup_mask() iterates over a cpumask and starts all present CPUs up to a caller provided upper limit. The limit variable is decremented and checked for 0 before invoking cpu_up(), which is obviously off by one and prevents the bringup of the last CPU when the limit is equal to the number of present CPUs. Move the decrement and check after the cpu_up() invocation. Fixes: 18415f33e2ac ("cpu/hotplug: Allow "parallel" bringup up to CPUHP_BP_KICK_AP_STATE") Reported-by: Mark Brown Signed-off-by: Thomas Gleixner Tested-by: Mark Brown Link: https://lore.kernel.org/r/87wn10ufj9.ffs@tglx --- kernel/cpu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index 005f863..88a7ede 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1770,9 +1770,6 @@ static void __init cpuhp_bringup_mask(const struct cpumask *mask, unsigned int n for_each_cpu(cpu, mask) { struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu); - if (!--ncpus) - break; - if (cpu_up(cpu, target) && can_rollback_cpu(st)) { /* * If this failed then cpu_up() might have only @@ -1781,6 +1778,9 @@ static void __init cpuhp_bringup_mask(const struct cpumask *mask, unsigned int n */ WARN_ON(cpuhp_invoke_callback_range(false, cpu, st, CPUHP_OFFLINE)); } + + if (!--ncpus) + break; } }