Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2790272pxp; Tue, 22 Mar 2022 06:15:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzP6u/W2I+P7QJRnMfkssoj5uER9iEH//TdLzx73irVzQh81vl99ORwpHMO9pep/m1KPZNU X-Received: by 2002:a17:907:6d9b:b0:6db:8eab:94e0 with SMTP id sb27-20020a1709076d9b00b006db8eab94e0mr25055235ejc.687.1647954924319; Tue, 22 Mar 2022 06:15:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647954924; cv=none; d=google.com; s=arc-20160816; b=HQbJesiHJBQyWOY7xEYmnNIwpyoi/AF50xRRMJaz2A9AYy23m7Yc6n6sf07iO9FPwU fu/IDeYJHEd+t7G1oCIX4V9pdX6wwnjtA1AcVM6nXO+zPymWfasZsP5sfmXOcMQhATNz hm/3kvxgzr4DX8fYy+6P/o56Wt76ExexhWRraSuSHidm2kqLfjagMj5TpeI5PeMZYSZM 3cOVzsGXwqnwx2nqoZE8w3RysEIBHQ+rTcv2FJZ7WKTMJN2o6qSyuhrFX7WNYXyeLBa4 0VQzsw/cciGccX77B4ZIOcj3cbBsrCTa8V/Rm/hRrekDC8RLUPLcB2J+dErYhAsBcKfs Bg0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=E5qZ3JijcNBrvYYjCh38GEwbvAbTHUBMmZvkwQ7m9SY=; b=LEVzEEnmzvim2Ymj6laFpCvSVIjnlqt0NX1sUBUIgl3SyfWYC4lCeGCJiS0OBtbuWi 3kXefhWb1PGapylxJlt6QHZ8yHX3PrPtfKR5dkN86kf23OorGZQlmOAcohuXuOh8jWBN MGtduP1WKPQXSCY4O6FgpmNYejfuPpScFdrQbjJtVW4ri3ChWzqbv/onftzyhMiDnpae MrafQlg/3qaqDSOwsiND23KuDugZc54JjRHqoSJjtbUPToM00J1t9uqO+NpnTovsjQI2 sayoHCCcKjFrULWHdXu0knQ922ma+MA2+0H/YkcaHEmXe5vDId1nbHAFSWwDN4UmkgoO gZRQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jw14-20020a170906e94e00b006df7cd0f19bsi8399036ejb.817.2022.03.22.06.14.56; Tue, 22 Mar 2022 06:15:24 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234279AbiCVLjn (ORCPT + 99 others); Tue, 22 Mar 2022 07:39:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232890AbiCVLjk (ORCPT ); Tue, 22 Mar 2022 07:39:40 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CE69BB66 for ; Tue, 22 Mar 2022 04:38:12 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 95691153B; Tue, 22 Mar 2022 04:38:12 -0700 (PDT) Received: from [10.57.21.112] (unknown [10.57.21.112]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E5DE83F66F; Tue, 22 Mar 2022 04:38:10 -0700 (PDT) Message-ID: <6bc9d1d5-ed33-cc9b-274f-d894c2e2044e@arm.com> Date: Tue, 22 Mar 2022 11:38:09 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v2] cpu/hotplug: Set st->cpu earlier Content-Language: en-US To: Steven Price , Peter Zijlstra , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, Baokun Li , Dongli Zhang , Randy Dunlap , Yuan ZhaoXiong , YueHaibing , Dietmar Eggemann References: <20220316153637.288199-1-steven.price@arm.com> From: Vincent Donnefort In-Reply-To: <20220316153637.288199-1-steven.price@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On 16/03/2022 15:36, Steven Price wrote: > Setting the 'cpu' member of struct cpuhp_cpu_state in cpuhp_create() is > too late as other callbacks can be made before that point. In particular > if one of the earlier callbacks fails and triggers a rollback that > rollback will be done with st->cpu==0 causing CPU0 to be erroneously set > to be dying, causing the scheduler to get mightily confused and throw > its toys out of the pram. > > Move the assignment earlier before any callbacks have a chance to run. > > Fixes: 2ea46c6fc945 ("cpumask/hotplug: Fix cpu_dying() state tracking") > Signed-off-by: Steven Price > CC: Dietmar Eggemann > --- > Changes since v1[1]: > > * Added a Fixes: tag. > * Moved the assignment to just before cpuhp_set_state() which is the > first place it is needed. > > [1]: https://lore.kernel.org/r/20220225134918.105796-1-steven.price%40arm.com > > kernel/cpu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/cpu.c b/kernel/cpu.c > index 407a2568f35e..c1324c8677cf 100644 > --- a/kernel/cpu.c > +++ b/kernel/cpu.c > @@ -720,7 +720,6 @@ static void cpuhp_create(unsigned int cpu) > > init_completion(&st->done_up); > init_completion(&st->done_down); > - st->cpu = cpu; > } > > static int cpuhp_should_run(unsigned int cpu) > @@ -1351,6 +1350,7 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen, enum cpuhp_state target) > > cpuhp_tasks_frozen = tasks_frozen; > > + st->cpu = cpu; > cpuhp_set_state(st, target); > /* > * If the current CPU state is in the range of the AP hotplug thread, Reviewed-by: Vincent Donnefort I also gave a try with LISA's HotplugRollback test.