Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp298243ioo; Thu, 26 May 2022 04:04:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHVDV+wa+HsgY75QP9GqirrbsKIvtw/8By6HAxgWfzuYV1NegnmBFzeehu8wPHKOM7695S X-Received: by 2002:a17:90a:d3d4:b0:1e0:a6a7:6ef with SMTP id d20-20020a17090ad3d400b001e0a6a706efmr2031972pjw.17.1653563058972; Thu, 26 May 2022 04:04:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653563058; cv=none; d=google.com; s=arc-20160816; b=Sftao6zJhmRlMgXUddpaMk2cNIvUFc7FXgvd/12ZE190iyH1EX5+DKPRYVLSqz+eZW TZoGcrZ4FnLZ4SKXEEhZRS7OySgYr/pPfS+BrZZgwJA5Yw2Hn23tqhIpeu8kJe6LGNGO RVUPZPRrkNvEcKgc7FzRdeILRer/8Cz1yggYN/ZYFwI24h9RWcEOYWqgDMqcwnRYn/Qo nqbxSEVuTEKGYPiyKk+yZpnLZtHvEgLLQMblxkxpuAcJYCodT9F/Lj+hwk8kUEj5FVLW zjM+6xgp0XfdZR1eGmsN/288waOb12ODpIxzhbTSfMV1QRuROHdnYnSesl754mGDWsqG DTdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=oibYPAPXB3rxchD26NN1if0CqTbEEBbCmYMLu9cS348=; b=deGnhRAdFEoo82DOwGpX/wOFz8i5SKRpTcneoZVyUvuC/YCYMgBo78Bck7P7bJ1yXZ XijDv+zg4TSaQdfvYHmDj4ZNQPhaDkPvSXiYtbYuuiWNJjitYHgHszcFMjkbDoAOhqUk iCDXWCqqd9mXpv12IFZCFwypQfRrHw0R3A1DbTcpQVD83SEMMtoMCzlDkbtuu+LS4bxH 4icatu+7+JSH4rtp9a5eKdhqn0/o5qOoHkTBZvtCACuD17XHpnklFPjCN0zH9NQxzMw/ LBr6+UddemWEfIAulNfJph25VasV4enjoK7Y0CSdCLu/XI8239HL36L1DzWQzjMJcVM/ 0KzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ii2M3SMS; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i9-20020a17090332c900b0016381c7e28dsi834308plr.67.2022.05.26.04.04.03; Thu, 26 May 2022 04:04:18 -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=@redhat.com header.s=mimecast20190719 header.b=ii2M3SMS; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245155AbiEYPMa (ORCPT + 99 others); Wed, 25 May 2022 11:12:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245153AbiEYPMJ (ORCPT ); Wed, 25 May 2022 11:12:09 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1E0DCB225B for ; Wed, 25 May 2022 08:12:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653491520; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=oibYPAPXB3rxchD26NN1if0CqTbEEBbCmYMLu9cS348=; b=ii2M3SMSGsupnBRCYku1bw/wjL2Hg9Ab/UZoqj5tesYI3dvlvPeQ3bE+s+L1wMktYC5j6J 0e9TxrYWWggW/SL0yufuPY/5ZQkHevLu61QH3HJedGj/V4+xZR6i9T8qtCflf8WSUc3v/Z 94mAWRQktWbwJhBqxSlDM1lhTq3oD/M= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-650-3WVS63MGNry6uCXFElI4tQ-1; Wed, 25 May 2022 11:11:58 -0400 X-MC-Unique: 3WVS63MGNry6uCXFElI4tQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 88DED811E81; Wed, 25 May 2022 15:11:58 +0000 (UTC) Received: from lorien.usersys.redhat.com (unknown [10.39.192.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C943F112131B; Wed, 25 May 2022 15:11:56 +0000 (UTC) Date: Wed, 25 May 2022 11:11:52 -0400 From: Phil Auld To: Valentin Schneider Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Peter Zijlstra Subject: Re: [PATCH] cpuhp: make target_store() a nop when target == state Message-ID: References: <20220523144728.32414-1-pauld@redhat.com> <20220525133133.GA5500@pauld.bos.csb> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,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 Wed, May 25, 2022 at 04:09:29PM +0100 Valentin Schneider wrote: > On 25/05/22 09:31, Phil Auld wrote: > > On Wed, May 25, 2022 at 10:48:31AM +0100 Valentin Schneider wrote: > >> > >> Yeah it would be neater to not even enter cpu_{up, down}(), but my paranoia > >> makes me think we need the comparison to happen with at least the > >> cpu_add_remove_lock held to make sure st->state isn't moving under our > >> feet, otherwise we may still end up with target == state in _cpu_down() and > >> hit the bug you're describing. > >> > > > > This is what I was originally doing before I tried to "optimize" it: > > > > if (st->state < target) > > ret = cpu_up(dev->id, target); > > else if (st->state > target) > > ret = cpu_down(dev->id, target); > > > > This does the check under the lock and just falls through if state==target. > > I think I'll go back to that version. > > > > I also noticed while testing that the boot cpu does not get its target set. > > It's got state 233 but target 0. So reading that out and writing it back > > on offlines cpu0. I'll try to find where that is not getting set. > > > > If I had to guess I'd say it's because the boot CPU doesn't go through the > regular hotplug machinery and sets its state straight to CPUHP_ONLINE > Yes, that was my thought. > /me digs > > Maybe around this? > > void __init boot_cpu_hotplug_init(void) > { > this_cpu_write(cpuhp_state.booted_once, true); > this_cpu_write(cpuhp_state.state, CPUHP_ONLINE); > } > Right, just found that too. Probably should set the target there as well. Cheers, Phil --