From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F24D20FC for ; Mon, 18 Sep 2023 03:48:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695008936; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tf1afM7/bTwRaF6MhWk6NmsY4pxpFUisMFOko6iFoOg=; b=FLZUGeW9Mbxhb+kIOs743Mp42E7hnmSAGBEp9F95zONVpTdCNw0VaX8reHPWonnAUvr9PI H9oUxF42485wfRmEspAXUtgVDoq3+2su6WQdxv6SyQaTV0VzNTBuzfNkN0L4E6TcDa8Sos CHuFe6JRtChFCjmTWeQR3Td3m1wd/FA= Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-621-kWQCSBIZOYCN8g8xe_T1Gw-1; Sun, 17 Sep 2023 23:48:55 -0400 X-MC-Unique: kWQCSBIZOYCN8g8xe_T1Gw-1 Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-1c443fdfedbso14898025ad.2 for ; Sun, 17 Sep 2023 20:48:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695008934; x=1695613734; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tf1afM7/bTwRaF6MhWk6NmsY4pxpFUisMFOko6iFoOg=; b=MGOalvxtkzk1ahTpgldcMYncgBxyqGE34p7DMIVGnWD9jHjasQRcLQO82u+k9osSXe i7eTd/K8ZyGo+8R+Vg1h/1OWAKaFCf5b75Ws/USXCRNF+8TFzhaw9IdfHxmKG5q1YNr6 u5x1SeLJHFmYOjHnoXjEaumHYhB98Ra/tpG2ZnFfu3er6i9cLqIhMZUCyN0hc323phoE Eb9Cwnv3OZYR3FMER1zp34AzRBT3rwUTX2Wq9JpYLHxWJtSDuDbmz5AKlb1hPFaUjn67 sTlY+EEuQgAKTIu3x740a2K3u2+Tm45FUkqi1NyxG74d6/YDj6RCqxi+JKXddK9AIWoc EseQ== X-Gm-Message-State: AOJu0Yxqgnq3qzmZ+QDM1Zuv6vfrhTXcbalo6JgtPZj/xOmLpnKFgQ5X y8IlRqmr9D0wmwTSaexAQKHpZ1YuI9ekLUadmnb08hw3cIUy07y2nFQvIg/LSogUDfCfrZXLV/Q Of4R6G97LSBCcJ0x1MrWk X-Received: by 2002:a17:902:e551:b0:1c4:16f7:d95b with SMTP id n17-20020a170902e55100b001c416f7d95bmr8120391plf.63.1695008934604; Sun, 17 Sep 2023 20:48:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHU+J6/1r/Ic+5ZZYMQ4fGS+99Vl+z2dkdnv17BDJt0rP24HSwlnxKPxSwy3c72dz81jLm2Bg== X-Received: by 2002:a17:902:e551:b0:1c4:16f7:d95b with SMTP id n17-20020a170902e55100b001c416f7d95bmr8120381plf.63.1695008934370; Sun, 17 Sep 2023 20:48:54 -0700 (PDT) Received: from ?IPV6:2001:8003:e5b0:9f00:dbbc:1945:6e65:ec5? ([2001:8003:e5b0:9f00:dbbc:1945:6e65:ec5]) by smtp.gmail.com with ESMTPSA id n10-20020a170902d2ca00b001bbf7fd354csm7284723plc.213.2023.09.17.20.48.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 17 Sep 2023 20:48:53 -0700 (PDT) Message-ID: <4f368470-83c1-4140-9d0f-e64db3402865@redhat.com> Date: Mon, 18 Sep 2023 13:48:47 +1000 Precedence: bulk X-Mailing-List: loongarch@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [RFC PATCH v2 07/35] x86: intel_epb: Don't rely on link order To: James Morse , linux-pm@vger.kernel.org, loongarch@lists.linux.dev, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, kvmarm@lists.linux.dev Cc: x86@kernel.org, Salil Mehta , Russell King , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com References: <20230913163823.7880-1-james.morse@arm.com> <20230913163823.7880-8-james.morse@arm.com> From: Gavin Shan In-Reply-To: <20230913163823.7880-8-james.morse@arm.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 9/14/23 02:37, James Morse wrote: > intel_epb_init() is called as a subsys_initcall() to register cpuhp > callbacks. The callbacks make use of get_cpu_device() which will return > NULL unless register_cpu() has been called. register_cpu() is called > from topology_init(), which is also a subsys_initcall(). > > This is fragile. Moving the register_cpu() to a different > subsys_initcall() leads to a NULL derefernce during boot. ^^^^^^^^^^ s/derefernce/dereference Reported by ./scripts/checkpatch.pl --codespell > > Make intel_epb_init() a late_initcall(), user-space can't provide a > policy before this point anyway. > > Signed-off-by: James Morse > --- > subsys_initcall_sync() would be an option, but moving the register_cpu() > calls into ACPI also means adding a safety net for CPUs that are online > but not described properly by firmware. This lives in subsys_initcall_sync(). > --- > arch/x86/kernel/cpu/intel_epb.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/cpu/intel_epb.c b/arch/x86/kernel/cpu/intel_epb.c > index e4c3ba91321c..f18d35fe27a9 100644 > --- a/arch/x86/kernel/cpu/intel_epb.c > +++ b/arch/x86/kernel/cpu/intel_epb.c > @@ -237,4 +237,4 @@ static __init int intel_epb_init(void) > cpuhp_remove_state(CPUHP_AP_X86_INTEL_EPB_ONLINE); > return ret; > } > -subsys_initcall(intel_epb_init); > +late_initcall(intel_epb_init); Thanks, Gavin