Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1415979lqp; Mon, 15 Apr 2024 06:09:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUYB+CREZsKw9gLjT78DsnuJk0WLEPTKzOxtlgJUjBLuLzgNpL1qnszeLFkJ0ML2TEgAo5cvLv8cU04t9EfaCTauNzRHhI/lmt+q1w69w== X-Google-Smtp-Source: AGHT+IHDVaZ2zdHr4Iv3oWshIpGpjkU5zBTxdzmbGfTxPOM2KtxflbdPCR8JmATTwbcYNS7+hrlo X-Received: by 2002:a05:6808:310:b0:3c7:682:4d3 with SMTP id i16-20020a056808031000b003c7068204d3mr5042519oie.7.1713186571523; Mon, 15 Apr 2024 06:09:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713186571; cv=pass; d=google.com; s=arc-20160816; b=MOUp7h+zzA/vkb3QpkqOLN2RnZfvoK2a7N69bVjsDj5KHgaX86ky7FEDH2kRuCCQgT AqMvCF6my8DQ4KM/9XoD+GmdWcm9YFcVigKTMmO9Gref1IFS9zL+85PMsjTTs8DfS7/t uX/Gg0/uL9oivCrEmhzqEv46fJ+qE9liuKbhCAc6YLH03/uu46s25wHDvJW4EA1m04LE Fhh3etT3E57s+tQbw3jZdBtSP/4hCaF5wNLuSEjLDdh11msq2vvc6nHm/uZLswt5qLG7 BWBamzjUCpcHNO4vVlc/CHKQuuq1xDgS9vu7Wxxe0kgNlQkpoMiIHJYZBxaKpS3E6YQU u7VQ== 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=KlFFCKgCLq3IdXd4piu6Vty9Z/uniiLlM9wZ0cSFqtM=; fh=bcmFkZ3wvNSJcdrobxJ4d6z8RfOrfo621CmoyRZC9d4=; b=Fa2BAlmhkSLT87Cwf/qK2Tbbjs1LXwd2p5lYptzY7eH72TMxaxyv5bIuciLwSqQBeK 4iLduTPUT5ScdvYT4ZmH+fPW9dnmuxnZllHbv2jmVG1aKI+6oA/yD9CGAQwlolaKL/+B eISlOtezrf+gAI0Emd/v544kspOaBxbjE55qd5At+2xAnE6kF9gIp+DXvvq7H1t1ewJD h8a8+z7Zdk7D6Gk8H+qrQG0ofuFnpt95dDWRrqfGBfg91Ao0H0chwCOD/JN0rj+ME25V u2AJUg1b2+SMPHqBsFSBjJUeif2sxje6/Dha2l/iy/JEtv9PuQUcahVO1l386mf74kS5 95sg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=X2KOyKSr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-145175-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145175-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c6-20020a05622a024600b00436a43d98a9si7161948qtx.23.2024.04.15.06.09.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 06:09:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145175-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=X2KOyKSr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-145175-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145175-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A35811C2230D for ; Mon, 15 Apr 2024 13:08:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B6BA7316E; Mon, 15 Apr 2024 12:51:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X2KOyKSr" 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 5A0E573163; Mon, 15 Apr 2024 12:51:43 +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=1713185503; cv=none; b=JHCFBclIMFrqJB5INbP/C7vTsAeQoPMUaZlsQ2vViKYhgrp9AtnLrEacl4FgCGTd727tepvSTfpc5fYcQKn6kYeqe7wwSNcLT3h1VqT5o1B5yQs/dctW0grloSma2ATp8Mqwqi+fAUbqkfPx6CTc+mXe2IVRRL1HUA9Mw1lH3u8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713185503; c=relaxed/simple; bh=jYX09rpdrm93G+82PrvfVTaDeGwVFz87SiF1eL4uh4c=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=SPNvGCgYOzPmCLL+wACLZmu+o7fPu56/k8BBnS3IFTMuolw9IP9zyOboNnHV8O6A2T53gRyyTutmtGNvKHykrNrhAkDwR7fZUhTzZsYZnvTUBOawo7wtclMdfWX/iaoMVNEuIg/n6QGqXZy7jiHbgQu0P5GCft+rNalPctzPiNo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X2KOyKSr; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CEC8C113CC; Mon, 15 Apr 2024 12:51:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713185503; bh=jYX09rpdrm93G+82PrvfVTaDeGwVFz87SiF1eL4uh4c=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=X2KOyKSrplY3TQ4q9SahVWs6oObdsfm/oET5Ojm9a/yiX+Vr9aBmPSpc14PXj5UCK ntBzkaUVg5iooN/jydrxGrgMMl7jipjzJRfJs3MrizMt2uW8+9fGeuDEZxjmkRUi1m ZAqN4D+rTd34QSKZdRStpxcrZNhbDMhTJMfo15qa1/ype+RgrIaS2/Sx4sViDooTQ9 UERyYrIsubkhpyGYFPYCnFqCG71NMOvoA2LDeMeaG9CT2/ncoYfFWyejLUphbcOYkn y8gZWT7SA55m7VvRNk2WK94Y5/T4GKaVyeX+CcwR3Wyw3p84a9VR4xy1i7LFDW9HpO v84WXL6ILkZfA== Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-5a9ef9ba998so844111eaf.1; Mon, 15 Apr 2024 05:51:43 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCXypDsMF8kshtuXYczEur+J57TQDYT9rm+NuIYmKjy9FNI3lFyAvg6n0GwB5zvDt0tau0xPRFKF3zJDsrHJJ6UpGeEpBl/kgiVUU03GzK+c27XoqzZQ2/zK1aRFAFxUfwsGWigF4JZVCP63qOaiirNOD/xbXE1T2FEGCVpFguW5xXWsoRqQ7aFA4df5ol4SLQxweABTmZQMwbpbB7p8kQ== X-Gm-Message-State: AOJu0YwOcVnmcxATbirisS35WWH0GwR6AlxppOKXSuSsy8AZ/qkb1d1R Dx1hyUhyVuABiCvrgb8cGIw+6iJ3w1RY/ioNrFWdMS4uoFfdPcHzVUkS8Ssllsw4fwUnOHptY3b jUVDn0zXt4tFa1ExnzE5oWna6ogQ= X-Received: by 2002:a05:6870:7a6:b0:22e:e006:e5ae with SMTP id en38-20020a05687007a600b0022ee006e5aemr11158428oab.0.1713185502514; Mon, 15 Apr 2024 05:51:42 -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> <87bk6ez4hj.ffs@tglx> In-Reply-To: From: "Rafael J. Wysocki" Date: Mon, 15 Apr 2024 14:51:27 +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: Salil Mehta Cc: Thomas Gleixner , "Russell King (Oracle)" , "Rafael J. Wysocki" , Jonathan Cameron , "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" , Miguel Luis , James Morse , Jean-Philippe Brucker , Catalin Marinas , Will Deacon , Linuxarm , "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 1:51=E2=80=AFPM Salil Mehta wrote: > > Hello, > > > From: Thomas Gleixner > > Sent: Friday, April 12, 2024 9:55 PM > > > > On Fri, Apr 12 2024 at 21:16, Russell King (Oracle) wrote: > > > On Fri, Apr 12, 2024 at 08:30:40PM +0200, Rafael J. Wysocki wrote: > > >> 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 cod= e > > >> runs after the processor driver has loaded AFAICS. > > > > > > It is over this that I walked away from progressing this code, becau= se > > > I don't think it's quite as simple as you make it out to be. > > > > > > Yes, acpi_map_cpu() and acpi_unmap_cpu() are already arch > > implemented > > > functions, so Arm64 can easily provide stubs for these that do nothi= ng. > > > That never caused me any concern. > > > > > > What does cause me great concern though are the finer details. For > > > example, above you seem to drop the evaluation of _STA for the > > > "make_present" case - I've no idea whether that is something that > > > should be deleted or not (if it is something that can be deleted, th= en > > > why not delete it now?) > > > > > > As for the cpu locking, I couldn't find anything in > > > arch_register_cpu() that depends on the cpu_maps_update stuff nor > > > needs the cpus_write_lock being taken - so I've no idea why the > > > "make_present" case takes these locks. > > > > Anything which updates a CPU mask, e.g. cpu_present_mask, after early > > boot must hold the appropriate write locks. Otherwise it would be poss= ible > > to online a CPU which just got marked present, but the registration ha= s not > > completed yet. > > > > > Finally, the "pr->flags.need_hotplug_init =3D 1" thing... it's not > > > obvious that this is required - remember that with Arm64's "enabled" > > > toggling, the "processor" is a slice of the system and doesn't > > > actually go away - it's just "not enabled" for use. > > > > > > Again, as "processors" in Arm64 are slices of the system, they have = to > > > be fully described in ACPI before the OS boots, and they will be > > > marked as being "present", which means they will be enumerated, and > > > the driver will be probed. Any processor that is not to be used will > > > not have its enabled bit set. It is my understanding that every > > > processor will result in the ACPI processor driver being bound to it > > > whether its enabled or not. > > > > > > The difference between real hotplug and Arm64 hotplug is that real > > > hotplug makes stuff not-present (and thus unenumerable). Arm64 > > hotplug > > > makes stuff not-enabled which is still enumerable. > > > > Define "real hotplug" :) > > > > Real physical hotplug does not really exist. That's at least true for = x86, where > > the physical hotplug support was chased for a while, but never ended u= p in > > production. > > > > Though virtualization happily jumped on it to hot add/remove CPUs to/f= rom > > a guest. > > > > There are limitations to this and we learned it the hard way on X86. A= t the > > end we came up with the following restrictions: > > > > 1) All possible CPUs have to be advertised at boot time via firmwa= re > > (ACPI/DT/whatever) independent of them being present at boot ti= me > > or not. > > > > That guarantees proper sizing and ensures that associations > > between hardware entities and software representations and the > > resulting topology are stable for the lifetime of a system. > > > > It is really required to know the full topology of the system a= t > > boot time especially with hybrid CPUs where some of the cores > > have hyperthreading and the others do not. > > > > > > 2) Hot add can only mark an already registered (possible) CPU > > present. Adding non-registered CPUs after boot is not possible. > > > > The CPU must have been registered in #1 already to ensure that > > the system topology does not suddenly change in an incompatible > > way at run-time. > > > > The same restriction would apply to real physical hotplug. I don't thi= nk that's > > any different for ARM64 or any other architecture. > > > There is a difference: > > 1. ARM arch does not allows for any processor to be NOT present. Hence,= because of > this restriction any of its related per-cpu components must be present an= d enumerated > at the boot time as well (exposed by firmware and ACPI). This means all t= he enumerated > processors will be marked as 'present' but they might exist in NOT enable= d (_STA.enabled=3D0) > state. > > There was one clear difference and please correct me if I'm wrong here, = for x86, the LAPIC > associated with the x86 core can be brought online later even after boot? > > But for ARM Arch, processors and its corresponding per-cpu components lik= e redistributors > all need to be present and enumerated during the boot time. Redistributor= s are part of > ALWAYS-ON power domain. OK So what exactly is the problem with this and what does acpi_processor_add() have to do with it? Do you want the per-CPU structures etc. to be created from the acpi_processor_add() path? This plain won't work because acpi_processor_add(), as defined in the mainline kernel today (and the Jonathan's patches don't change that AFAICS), returns an error for processor devices with the "enabled" bit clear in _STA (it returns an error if the "present" bit is clear too, but that's obvious), so it only gets to calling arch_register_cpu() if *both* "present" and "enabled" _STA bits are set for the given processor device. That, BTW, is why I keep saying that from the ACPI CPU enumeration code perspective, there is no difference between "present" and "enabled". > 2. Agreed regarding the topology. Are you suggesting that we must call a= rch_register_cpu() > during boot time for all the 'present' CPUs? Even if that's the case, we = might still want to defer > registration of the cpu device (register_cpu() API) with the Linux device= model. Later is what > we are doing to hide/unhide the CPUs from the user while STA.Enabled Bit = is toggled due to > CPU (un)plug action. There are two ways to approach this IMV, and both seem to be valid in princ= iple. One would be to treat CPUs with the "enabled" bit clear as not present and create all of the requisite data structures for them when they become available (in analogy with the "real hot-add" case). The alternative one is to create all of the requisite data structures for the CPUs that you find during boot, but register CPU devices for those having the "enabled" _STA bit set. It looks like you have chosen the second approach, which is fine with me (although personally, I would rather choose the first one), but then your arch code needs to arrange for the requisite CPU data structures etc. to be set up before acpi_processor_add() gets called because, as per the above, the latter just rejects CPUs with the "enabled" _STA bit clear. Thanks!