Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp563181pxb; Thu, 24 Mar 2022 02:38:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgxlT70tlNeUfoDrOIyTalW4b3iSHilpfFD5o13yvotX060mZ4887HNZiOHSLMxIHAHA9z X-Received: by 2002:a05:6402:2806:b0:418:e956:129d with SMTP id h6-20020a056402280600b00418e956129dmr5545448ede.263.1648114736755; Thu, 24 Mar 2022 02:38:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648114736; cv=none; d=google.com; s=arc-20160816; b=Iy5mU+uZ/ll4HTXPi0U0SIIPjEePirQgeBtXnZqgTkJr92eeRQ8ABteIjZgcNx+6dz s3aS2TYeoxSwGXVZXGb5DyMpq7sqSFgQSdG3WNeDmmi5ZBKgDi46dfRioPlvDbGiUTb1 pNC0Q0WPMx/achMS1/WuyL2rPBQE4B2+8ZLuWwUI1CDj2UnPypfvV0Nxq7FTIyPWTqge SGn1eaa3yQejaINW3j9k4lSV72onRoxHeiHeuHEvzGiCyu4CyB5hBsFpB2y9JmgiOs6x EH1U+eELN0RuXbtp6SJUa9Eh+m134LSey319NoL4Rmhf9Skql6Hg04vfdpffB0ZHD1pf ltDw== 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=NBY+7TyO0PsBuj2bTfbsdeRYiNgW2tgY2xvFNgm5g5U=; b=lslFyyL8/T1Qh2dMaxRgsM8EOB0E0rYnYeIcWPSs/jr8Sz9pdHpwGcfT4kP9HeXMO8 ILOMYRKoTNusgzhHK9sGoPyuWQmmYmO2s/IVZ/vhr+5RAPc01s23lwXSBQjZnCDPFqWN 4gBRWfz8NAf8FjxyHO+XRXkSqeapuB2e9iJcWu/Bz0PJzm8eXwQnYtEuiQI1VDB0zL3K qjWVUuhHcody22caXRcPximaLU1ItwCHWUnMLrALk+vTJCqY31dOdWM6zZPlvK3TaIrJ p/JlnDtMJXMe+d557U1hygeA2CDiygw0gWM3/p1EzMJcCgFftPqUapfXZMHTAsUq5rqa a+MA== 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 v1-20020a17090651c100b006df76385c89si15271279ejk.297.2022.03.24.02.38.30; Thu, 24 Mar 2022 02:38:56 -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 S234789AbiCWKMW (ORCPT + 99 others); Wed, 23 Mar 2022 06:12:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230102AbiCWKMV (ORCPT ); Wed, 23 Mar 2022 06:12:21 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5A0987666C for ; Wed, 23 Mar 2022 03:10:50 -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 B0DD823A; Wed, 23 Mar 2022 03:10:49 -0700 (PDT) Received: from [10.57.39.153] (unknown [10.57.39.153]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 29DB73F73B; Wed, 23 Mar 2022 03:10:48 -0700 (PDT) Message-ID: Date: Wed, 23 Mar 2022 10:10:46 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v2] cpu/hotplug: Set st->cpu earlier Content-Language: en-GB To: Thomas Gleixner , Vincent Donnefort , Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Baokun Li , Dongli Zhang , Randy Dunlap , Valentin Schneider , Yuan ZhaoXiong , YueHaibing , Dietmar Eggemann References: <20220316153637.288199-1-steven.price@arm.com> <878rt2atre.ffs@tglx> <87wngla932.ffs@tglx> From: Steven Price In-Reply-To: <87wngla932.ffs@tglx> Content-Type: text/plain; charset=UTF-8 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 Thanks for taking a look at this. On 22/03/2022 22:58, Thomas Gleixner wrote: > On Tue, Mar 22 2022 at 15:59, Vincent Donnefort wrote: >> On 22/03/2022 15:31, Thomas Gleixner wrote: >>> On Wed, Mar 16 2022 at 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. >>> >>> What? >>> >>> CPUHP_OFFLINE = 0, >>> CPUHP_CREATE_THREADS, >>> >>> The create threads callback is the very first callback which is invoked >>> for a to be plugged CPU on the control CPU. So which earlier callback >>> can be invoked and fail? >>> >>> Thanks, >>> >>> tglx >> >> >> CPUHP_CREATE_THREADS itself can fail, before st->cpu is set. > > Sure. But that does not explain the problem. > >> Also, that value is used outside of the callbacks (cpuhp_set_state() >> in _cpu_up()). > > And why on earth is this not spelled out in the changelog? I apologies for that, I'm not very familiar with the code and I have to admit I have been struggling to identify exactly what is going on here. The actual issue I saw was if the callback fails then the rollback code leaves things in a messed up state. By the looks of things that callback that fails is indeed the first (CPUHP_CREATE_THREADS). >> But indeed this description could be refined a bit. > > Indeed. But the description is not the only problem here: > > It's completely uncomprehensible from the code in _cpu_up() _WHY_ this > > st->cpu = cpu; > > assignment has to be there. > > It's non-sensical if you really think about it, right? I entirely agree, and I did ask in my v1 posting[1] if anyone could point me to a better place to do the assignment. Vincent suggested moving it earlier in _cpu_up() which is this v2. But it still seems out-of-place to me. I've just had a go at simply removing the 'cpu' member and it doesn't look too bad. I'll post that patch as a follow up. I'm open to other suggestions for the best way to fix this. Thanks, Steve [1] https://lore.kernel.org/all/20220225134918.105796-1-steven.price@arm.com/ > That said, I'm pretty sure you can come up with: > > - a proper one time initialization of @st which solves your problem > > - a proper changelog which explains it > > Thanks, > > tglx