Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1373498lqp; Mon, 15 Apr 2024 04:53:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXDJ9i0z6yl8fnMjihCPPqwgurjXz8Wkih7JH751PzGLplxj+1eay8fwLJpl71KIHw4u+Z9iUYu7DoR/4EFemaEAYzjwdY0xQRfwpfr9Q== X-Google-Smtp-Source: AGHT+IGe/4hxAJwh2BhMPmiLkjko097Ih5xQehxN9siHZBPeI8dCd1SWQ5leE+8IkqagXmx2LtXp X-Received: by 2002:a17:902:e542:b0:1e4:320b:4311 with SMTP id n2-20020a170902e54200b001e4320b4311mr5712153plf.34.1713182038307; Mon, 15 Apr 2024 04:53:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713182038; cv=pass; d=google.com; s=arc-20160816; b=cTVpUZrNMvH28eQ1bgn8fZLz8VRX1Z4RAiVAjIRlTuAkGVtV2CUySb1YkjoX9ZU9yw C9LpbmlMHsMR91Fh1GrSvtuVO6a2MR/qUjVzkmsnzwBjk2kS9bEj0SwGEcAwTuclHNnh 62YwJ44SNc83widVg+Ly/goRx+2F0sSkV3wLbelz82ybNN4+VSqryyANzQEe2YQg4ZNo tlFzoVeF6/O9d6xLBgMYijFDrF722lck8hvMfdF+7Htse0+eLHnIlZKdDTllvzRh3g9B A0dBHiC/62a8cO1+4mCU77W62QeGEoYSeSxG/WK9IEnUfgUTITEqID4+iZcVMZikyHdS TkDg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=qV9bgXVPZiIXiVoN/jcd+sudxeLiYXQ6VE2cyK79slU=; fh=VjMpH9A+xj2X7VORj0yy++O2RNkEkhvH58Zdm1Syly8=; b=lFW/vaiwVTUAT/eq32JLMDsCCnQDhu4OeUU8lB4dvuqX1MTAqNKUIjIaC1ZALK5LjY R/4cr+zQTzGimR668wpC/m13V0NezZt9JoflfXgPxapGovAL5jRF4OiFXl3YWvz6gakY 7tGPUqsKNjXerCpgmTWberrf3Y2RVjr0fxTfbeXpHNbbCLP56CghvEEZBvBHx5bbtB9C 5G5Jk4LFR1b2PCJyw4L+O/LaWGqkW/vfgYG75/mgQhh9CEvd/8bK997CmE/62+NdW/o6 f4CiNdD+YgcxA9yzNEbYefN1NYxdnjoZvGjxr7jKg4yYAtU/71kl1OAaMDjkfgkEUx29 lxEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oIBNFBEq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-145012-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145012-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d4-20020a170902cec400b001e503e6dbb4si7814940plg.167.2024.04.15.04.53.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 04:53:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145012-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oIBNFBEq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-145012-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145012-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B6B5AB20D5F for ; Mon, 15 Apr 2024 11:53:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ACA716774E; Mon, 15 Apr 2024 11:52:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oIBNFBEq" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 82A27664AB; Mon, 15 Apr 2024 11:52:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713181969; cv=none; b=jYd+LheeuNwheZp/FZAGIh/gquUblaQCQdfrlZAmJziPE4d8asnN7aRN3GD2DXtGTJxnGfaxVV7x583zjKhVxtXK9w5J36rJhUpRWOd3R5ZEfVeLJHFokLUebkWjExs2VUsU5yFJelMqiooD9BgOtR7Ks+oZUW6Dt+3ki1ibIuo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713181969; c=relaxed/simple; bh=KDOa3WMhDZdCJkFOdWTeMccO2m7M+we4CfSTwKFdtC8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Ra1Fcbi+nlF1ttI1df1p8rauowE0yAkqMXh6EBuegRyZqtLknFEIquBzjFFEr1oKa43JHavxZRG3hC8db+joT+u8Hj31G+AAugjIAm+6J0FtejSMHDU9VVGL7g8rsXkG9y/otJIPbNDDktn/iEis0RuzXlgyjcbBdwaVjCkuFMI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oIBNFBEq; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34221C4AF08; Mon, 15 Apr 2024 11:52:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713181969; bh=KDOa3WMhDZdCJkFOdWTeMccO2m7M+we4CfSTwKFdtC8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=oIBNFBEqx27wE7YnGIQL5va6oghRoZsIBk7dZ6Y5YkGZkdDFq4eDbeUPvBrLFcHn4 g5NJ7sRS4UXG4ffu2FelF0itZGK5ioO5lI3bMll3lxU1khEN2T5lW3rgtIOrN4ZeXf TJwahAR67LD6xbc3xp9ohfJnvmGcu68Qva+e6KZQiiqao8LrBDnKwqX7kJtZzFdb0b /HMr7hn7XF/tO/Isb1UBK2KM8WEDXrc+UD0L8n+VDZ/QnuFX+f6s1RgaJGUSt4Kpzu Qoaucfj4WbGqk5fQy/mxpDk0TDnsX4JMuDMlNS5sSPFw04yeHQv2hVUpa6NJVWAMKe ut7WP5Mi6Hu4Q== Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3c6febc1506so339349b6e.1; Mon, 15 Apr 2024 04:52:49 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCVVC97vZ/pAjRm847xsihsorRTnYhSn/LM47mIY3aLwMAlIsb7j/k1bP3OLBD6fO24xWlnDmISG1bCuSevirthGVvYqIpPg3J6sCP4L0md0Z3i0lgL4wZkL9amTVL76a7CtfSx/jsSPdMrz0kBgPY+HG/wrpUOIU9sxOBPDxNskWMFQBKRZGxvwK2QW1EYsbiKOy+ZegbSIDNH6wjcI8A== X-Gm-Message-State: AOJu0YzLCQAgka9iUqnh8IP35OZbh1kvyLhHne9gIFZ7PYRFvU3yc/Um B6hhrWxoqGQW2lYAAeRYEiF4AafJ5muuSc+b6VtwRKWXDc19mbPhgxtmMuLtynAaCFsOClWMKmr fYQH692beLNeazPWn/8zK7CK1cDI= X-Received: by 2002:a05:6871:460a:b0:22e:d06b:5d8f with SMTP id nf10-20020a056871460a00b0022ed06b5d8fmr11074172oab.3.1713181968497; Mon, 15 Apr 2024 04:52:48 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240412143719.11398-1-Jonathan.Cameron@huawei.com> <20240412143719.11398-4-Jonathan.Cameron@huawei.com> <20240415115203.0000011b@Huawei.com> In-Reply-To: <20240415115203.0000011b@Huawei.com> From: "Rafael J. Wysocki" Date: Mon, 15 Apr 2024 13:52:33 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 03/18] ACPI: processor: Register deferred CPUs from acpi_processor_get_info() To: Jonathan Cameron Cc: "Rafael J. Wysocki" , 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, kvmarm@lists.linux.dev, x86@kernel.org, Russell King , Miguel Luis , James Morse , Salil Mehta , Jean-Philippe Brucker , Catalin Marinas , Will Deacon , linuxarm@huawei.com, justin.he@arm.com, jianyong.wu@arm.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Apr 15, 2024 at 12:52=E2=80=AFPM Jonathan Cameron wrote: > > On Fri, 12 Apr 2024 20:30:40 +0200 > "Rafael J. Wysocki" wrote: > > > On Fri, Apr 12, 2024 at 4:38=E2=80=AFPM Jonathan Cameron > > wrote: > > > > > > From: James Morse > > > > > > The arm64 specific arch_register_cpu() call may defer CPU registratio= n > > > until the ACPI interpreter is available and the _STA method can > > > be evaluated. > > > > > > If this occurs, then a second attempt is made in > > > acpi_processor_get_info(). Note that the arm64 specific call has > > > not yet been added so for now this will never be successfully > > > called. > > > > > > Systems can still be booted with 'acpi=3Doff', or not include an > > > ACPI description at all as in these cases arch_register_cpu() > > > will not have deferred registration when first called. > > > > > > This moves the CPU register logic back to a subsys_initcall(), > > > while the memory nodes will have been registered earlier. > > > Note this is where the call was prior to the cleanup series so > > > there should be no side effects of moving it back again for this > > > specific case. > > > > > > [PATCH 00/21] Initial cleanups for vCPU HP. > > > https://lore.kernel.org/all/ZVyz%2FVe5pPu8AWoA@shell.armlinux.org.uk/ > > > > > > e.g. 5b95f94c3b9f ("x86/topology: Switch over to GENERIC_CPU_DEVICES"= ) > > > > > > Signed-off-by: James Morse > > > Reviewed-by: Gavin Shan > > > Tested-by: Miguel Luis > > > Tested-by: Vishnu Pajjuri > > > Tested-by: Jianyong Wu > > > Signed-off-by: Russell King (Oracle) > > > Co-developed-by: Jonathan Cameron > > > Signed-off-by: Joanthan Cameron > > > --- > > > v5: Update commit message to make it clear this is moving the > > > init back to where it was until very recently. > > > > > > No longer change the condition in the earlier registration point > > > as that will be handled by the arm64 registration routine > > > deferring until called again here. > > > --- > > > drivers/acpi/acpi_processor.c | 12 ++++++++++++ > > > 1 file changed, 12 insertions(+) > > > > > > diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_proces= sor.c > > > index 93e029403d05..c78398cdd060 100644 > > > --- a/drivers/acpi/acpi_processor.c > > > +++ b/drivers/acpi/acpi_processor.c > > > @@ -317,6 +317,18 @@ static int acpi_processor_get_info(struct acpi_d= evice *device) > > > > > > c =3D &per_cpu(cpu_devices, pr->id); > > > ACPI_COMPANION_SET(&c->dev, device); > > > + /* > > > + * Register CPUs that are present. get_cpu_device() is used t= o skip > > > + * duplicate CPU descriptions from firmware. > > > + */ > > > + if (!invalid_logical_cpuid(pr->id) && cpu_present(pr->id) && > > > + !get_cpu_device(pr->id)) { > > > + int ret =3D arch_register_cpu(pr->id); > > > + > > > + if (ret) > > > + return ret; > > > + } > > > + > > > /* > > > * Extra Processor objects may be enumerated on MP systems w= ith > > > * less than the max # of CPUs. They should be ignored _iff > > > -- > > > > I am still unsure why there need to be two paths calling > > arch_register_cpu() in acpi_processor_get_info(). > > I replied further down the thread, but the key point was to maintain > the strong distinction between 'what' was done in a real hotplug > path vs one where onlining was all. We can relax that but it goes > contrary to the careful dance that was needed to get any agreement > to the ARM architecture aspects of this. This seems to go beyond technical territory. As a general rule, we tend to combine code paths that look similar instead of making them separate on purpose. Especially with a little to no explanation of the technical reason. > > > > Just below the comment partially pulled into the patch context above, > > there is this code: > > > > if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) { > > int ret =3D acpi_processor_hotadd_init(pr); > > > > if (ret) > > return ret; > > } > > > > For the sake of the argument, fold acpi_processor_hotadd_init() into > > it and drop the redundant _STA check from it: > > If we combine these, the _STA check is necessary because we will call thi= s > path for delayed onlining of ARM64 CPUs (if the earlier registration code > call or arch_register_cpu() returned -EPROBE defer). That's the only way > we know that a given CPU is online capable but firmware is saying we can'= t > bring it online yet (it may be be vHP later). Ignoring the above as per the other message. > > > > if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) { > > if (invalid_phys_cpuid(pr->phys_id)) > > return -ENODEV; > > > > cpu_maps_update_begin(); > > cpus_write_lock(); > > > > ret =3D acpi_map_cpu(pr->handle, pr->phys_id, pr->acpi_id, &pr->= id); > > I read that call as > acpi_map_cpu_for_physical_cpu_hotplug() > but we could make it equivalent of. > acpi_map_cpu_for_whatever_cpu_hotplug() Yes. > (I'm not proposing those names though ;) Sure. > in which case it is fine to just stub it out on ARM64. > > if (ret) { > > cpus_write_unlock(); > > cpu_maps_update_done(); > > return ret; > > } > > ret =3D arch_register_cpu(pr->id); > > if (ret) { > > acpi_unmap_cpu(pr->id); > > > > cpus_write_unlock(); > > cpu_maps_update_done(); > > return ret; > > } > > pr_info("CPU%d has been hot-added\n", pr->id); > > pr->flags.need_hotplug_init =3D 1; > This one needs more careful handling because we are calling this > for non hotplug cases on arm64 in which case we end up setting this > for initially online CPUs - thus if we offline and online them > again via sysfs /sys/bus/cpu/device/cpuX/online it goes through the > hotplug path and should not. > > So I need a way to detect if we are hotplugging the cpu or not. > Is there a standard way to do this? If you mean physical hot-add, I don't think so. What exactly do you need to do differently in the two cases? > I haven't figured out how to use flags in drivers to communicate this st= ate. > > > > > cpus_write_unlock(); > > cpu_maps_update_done(); > > } > > > > so I'm not sure why this cannot be combined with the new code. > > > > Say acpi_map_cpu) / acpi_unmap_cpu() are turned into arch calls. > > What's the difference then? The locking, which should be fine if I'm > > not mistaken and need_hotplug_init that needs to be set if this code > > runs after the processor driver has loaded AFAICS. > > That's the bit that I'm currently finding a challenge. Is there a clean > way to detect that? If you mean the need_hotplug_init flag, I'm currently a bit struggling to convince myself that it is really needed.