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 B9EC725EFAE for ; Wed, 19 Nov 2025 03:35:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763523326; cv=none; b=ptnuGWF36ZJbHuzPWVHo6a9vspIE9mdaOCxPFYCc4MikqJW6E461M7PAK37tqer6uvYP0HGy6ZAb8emAiwPo2A1W5cu2GNUx/rR2n5kCPhDywHnJb3qn3ZgyfwLGQVg4RkPqyGi/1ZIYx6U0+iA5UcdWl9QDiIpQUOwKGymFDRc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763523326; c=relaxed/simple; bh=FJS/HClEJ1jtK+rxMOC89uUQdfj4wsNu+wSDk1ZBbSw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Yt/2vI1RcaW4hG6QqFIntrafdakAsfw8k0fSBDDIoq9vOWawNOBJSyeqFoaNFGuS5sRRdvpl0lOY0z2A/Xt9f0r8V4iSiwHVALXQ0sE4lENtJYCJuct0CZ39KUFcvFJhu7/9BUF+zUjjXOqcSiegAhvxdyjDVAoo+Gd+fzexPHk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=AjIjCpgh; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=TOE38+1I; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AjIjCpgh"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="TOE38+1I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763523321; 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=uvuRIi2ziKsR6xTkpv20Bt95OlEm10rLUXNQns1uoJU=; b=AjIjCpgh2+eub8Mv5FG9vS2j3tlm6qWjObxsvwRRXxDou+WE6rx6m28LiIU/y0+cTWrXvb a3VMOWMMRNBnJhXcv+J271S+UJpPDHOyfdz93+pFpCe7hCoXxLOEAw/t+8SpAiHfyzT74G By5JwANDv8kc166KR+TbcaBURjBAwpg= 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-39-zX_HE6_bNCOXVZc0MT9CBA-1; Tue, 18 Nov 2025 22:35:19 -0500 X-MC-Unique: zX_HE6_bNCOXVZc0MT9CBA-1 X-Mimecast-MFC-AGG-ID: zX_HE6_bNCOXVZc0MT9CBA_1763523318 Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-297f587dc2eso115788955ad.2 for ; Tue, 18 Nov 2025 19:35:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1763523318; x=1764128118; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=uvuRIi2ziKsR6xTkpv20Bt95OlEm10rLUXNQns1uoJU=; b=TOE38+1I/JvwjYlvlL37OcRoGP3ktbHm0NNUYwPwr9+th4fgEeqOqoBDQWxdhPNWcQ oY1V6S47BENPO7iGyiCAYQQaSWuvievXNgRGME3/Y6oxWb4pOtNqp7a9Hy2nyq0uu6bZ 98x1CC+paqCyoBmxBkMwm1bgJutrVXjfA/LlH74SlqJj+VCI/wrX4HK7h88Ui+tyjFiw YyXh8nZHVXR1yCgpkOrGw6IbKPFXih+IBTDIfTiedjqa4LfjZiHT9sKRwkCUcyYThvEG tdB4EdgV1dLphfvJ4aIyLAvpCr/jIQ0rt8Myk+pEpMYqQhPp6rV5wOOzqzeeaO9tG8X0 Id3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763523318; x=1764128118; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uvuRIi2ziKsR6xTkpv20Bt95OlEm10rLUXNQns1uoJU=; b=Q2iWTsJlH5EJswjYy+4SSy7m5Qr1yI0+qI+lFR2QP+cAfZ/eiuUNWL5gZz5owLweKO C+qRbpc9VnwS3q1g/fTmBRU0IbKUdRVBu3C6+XTKepxtiYWcYRy9t84/WS+rlJa2jCJ7 WJ/5vdjLtMX4Yem5hNe6yPOv7+7jrtzj+2w5xf1qHKBm1H+WN7QpiENWKQZhfNa+FOzB TfQHjy0gzf/SRlDzzSXZ4wtF6WBcXabiNbok5dSdbzu6fko8RXbPeXlH7ZfzcIGFIeKg QeDy6bHe9PIrU9B1daXPQvZWbbS+hw+St6dklS+4z3zWq60+toZooUEYhbseqvyCG0uB R/0g== X-Forwarded-Encrypted: i=1; AJvYcCWCtbwWMi8499bMvzWff3A714/U+F4RE3ZYzXCniKA6fqmVnjg3wuR93oniLAOEZOIPMQiaYzo+vz3QajY=@vger.kernel.org X-Gm-Message-State: AOJu0YyKoRcRMRDGd6V9AhHO7Mxx7M7xfFW/I6ZvIrnKt3N4fasZTAPL NRAlqHv7UG1+oBAEyOIFpL8bfqD0eaPKsZL26x1GHqaP7r+mm4chqStroRxNDHWBxQrU0BnM5TW fSm9DTOaALeyav4nWcNihtPyqsFtQhHPeTNw8yZ46r+/qnFTm4iA97F1HEEu1nLijbw== X-Gm-Gg: ASbGnctf3nvvBvEeJR6yNVOyr8mp9HR65weOy0su89M592sEecmqxTRZ/bBOohWOqZX QXvEmbl70qGxuA0OVenlwyAx9LPevfOpQpSfL1vsvPau6L9CgsuUG+C93WQuHY3OXmBclMfO6bS iRRuNZ2i9SdOylkWxH40bxZ9FpAz83i/HmWjqIOaB4spDGuw11nK9DVlxZSdd3LDHIC48Wtw5jS yq2oLXrGgQr3pLe1zYsID1myrtvI0GEFcKJ5s7/VECEoXVJCvXc9uEv+nneXlCkLJORYvWRAtCp fIUl4J34O8z21e6r3UjfB/TGbkIuisf/Hpco7w2F9SiCL/G+gaYNEDqdc0/SM2Ugq//zjppTFBZ JtWVSfqAeWcb5iG9X/SnjvjLJsJN+v1PUMlmV0kslXfjuuFUdHg== X-Received: by 2002:a17:902:ebd2:b0:294:fc1d:9d0 with SMTP id d9443c01a7336-2986a750101mr236282095ad.40.1763523318216; Tue, 18 Nov 2025 19:35:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IE3FthsHiIYHA1hbqE2+ofewwVDvuKvv9vofOfVLsaX5rxLiZRjK5scHiZUaUDJ/yZF94bAvA== X-Received: by 2002:a17:902:ebd2:b0:294:fc1d:9d0 with SMTP id d9443c01a7336-2986a750101mr236281645ad.40.1763523317726; Tue, 18 Nov 2025 19:35:17 -0800 (PST) Received: from [192.168.68.51] (n175-34-62-5.mrk21.qld.optusnet.com.au. [175.34.62.5]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2985c2346b8sm189887835ad.16.2025.11.18.19.35.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Nov 2025 19:35:17 -0800 (PST) Message-ID: <455c577a-2c6b-4d57-9547-8f55bfe1c126@redhat.com> Date: Wed, 19 Nov 2025 13:35:03 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 01/34] ACPI / PPTT: Add a helper to fill a cpumask from a processor container To: Ben Horgan , james.morse@arm.com Cc: amitsinght@marvell.com, baisheng.gao@unisoc.com, baolin.wang@linux.alibaba.com, bobo.shaobowang@huawei.com, carl@os.amperecomputing.com, catalin.marinas@arm.com, dakr@kernel.org, dave.martin@arm.com, david@redhat.com, dfustini@baylibre.com, fenghuay@nvidia.com, gregkh@linuxfoundation.org, guohanjun@huawei.com, jeremy.linton@arm.com, jonathan.cameron@huawei.com, kobak@nvidia.com, lcherian@marvell.com, lenb@kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, lpieralisi@kernel.org, peternewman@google.com, quic_jiles@quicinc.com, rafael@kernel.org, robh@kernel.org, rohit.mathew@arm.com, scott@os.amperecomputing.com, sdonthineni@nvidia.com, sudeep.holla@arm.com, tan.shaopeng@fujitsu.com, will@kernel.org, xhao@linux.alibaba.com, Shaopeng Tan , Zeng Heng References: <20251117170014.4113754-1-ben.horgan@arm.com> <20251117170014.4113754-2-ben.horgan@arm.com> Content-Language: en-US From: Gavin Shan In-Reply-To: <20251117170014.4113754-2-ben.horgan@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Ben, On 11/18/25 2:59 AM, Ben Horgan wrote: > From: James Morse > > The ACPI MPAM table uses the UID of a processor container specified in > the PPTT to indicate the subset of CPUs and cache topology that can > access each MPAM System Component (MSC). > > This information is not directly useful to the kernel. The equivalent > cpumask is needed instead. > > Add a helper to find the processor container by its id, then walk > the possible CPUs to fill a cpumask with the CPUs that have this > processor container as a parent. > > CC: Dave Martin > Reviewed-by: Sudeep Holla > Reviewed-by: Jonathan Cameron > Reviewed-by: Fenghua Yu > Reviewed-by: Gavin Shan > Reviewed-by: Shaopeng Tan > Tested-by: Fenghua Yu > Tested-by: Shaopeng Tan > Tested-by: Peter Newman > Tested-by: Carl Worth > Tested-by: Gavin Shan > Tested-by: Zeng Heng > Signed-off-by: James Morse > Signed-off-by: Ben Horgan > --- > Changes since v4: > Remove blank line > > Changes since v3: > Refer to processor hierarchy in comments (Jonathan) > Fix indent (Jonathan) > --- > drivers/acpi/pptt.c | 84 ++++++++++++++++++++++++++++++++++++++++++++ > include/linux/acpi.h | 3 ++ > 2 files changed, 87 insertions(+) > Since this series may need another respin, a nitpick below... > diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c > index 54676e3d82dd..b8248c0092fe 100644 > --- a/drivers/acpi/pptt.c > +++ b/drivers/acpi/pptt.c > @@ -817,3 +817,87 @@ int find_acpi_cpu_topology_hetero_id(unsigned int cpu) > return find_acpi_cpu_topology_tag(cpu, PPTT_ABORT_PACKAGE, > ACPI_PPTT_ACPI_IDENTICAL); > } > + > +/** > + * acpi_pptt_get_child_cpus() - Find all the CPUs below a PPTT > + * processor hierarchy node > + * > + * @table_hdr: A reference to the PPTT table > + * @parent_node: A pointer to the processor hierarchy node in the > + * table_hdr > + * @cpus: A cpumask to fill with the CPUs below @parent_node > + * > + * Walks up the PPTT from every possible CPU to find if the provided > + * @parent_node is a parent of this CPU. > + */ > +static void acpi_pptt_get_child_cpus(struct acpi_table_header *table_hdr, > + struct acpi_pptt_processor *parent_node, > + cpumask_t *cpus) > +{ > + struct acpi_pptt_processor *cpu_node; > + u32 acpi_id; > + int cpu; > + > + cpumask_clear(cpus); > + The CPU mask has been cleared in its only caller acpi_pptt_get_cpus_from_container(), no need to clear it again. > + for_each_possible_cpu(cpu) { > + acpi_id = get_acpi_id_for_cpu(cpu); > + cpu_node = acpi_find_processor_node(table_hdr, acpi_id); > + > + while (cpu_node) { > + if (cpu_node == parent_node) { > + cpumask_set_cpu(cpu, cpus); > + break; > + } > + cpu_node = fetch_pptt_node(table_hdr, cpu_node->parent); > + } > + } > +} > + > +/** > + * acpi_pptt_get_cpus_from_container() - Populate a cpumask with all CPUs in a > + * processor container > + * @acpi_cpu_id: The UID of the processor container > + * @cpus: The resulting CPU mask > + * > + * Find the specified Processor Container, and fill @cpus with all the cpus > + * below it. > + * > + * Not all 'Processor Hierarchy' entries in the PPTT are either a CPU > + * or a Processor Container, they may exist purely to describe a > + * Private resource. CPUs have to be leaves, so a Processor Container > + * is a non-leaf that has the 'ACPI Processor ID valid' flag set. > + */ > +void acpi_pptt_get_cpus_from_container(u32 acpi_cpu_id, cpumask_t *cpus) > +{ > + struct acpi_table_header *table_hdr; > + struct acpi_subtable_header *entry; > + unsigned long table_end; > + u32 proc_sz; > + > + cpumask_clear(cpus); > + > + table_hdr = acpi_get_pptt(); > + if (!table_hdr) > + return; > + > + table_end = (unsigned long)table_hdr + table_hdr->length; > + entry = ACPI_ADD_PTR(struct acpi_subtable_header, table_hdr, > + sizeof(struct acpi_table_pptt)); > + proc_sz = sizeof(struct acpi_pptt_processor); > + while ((unsigned long)entry + proc_sz <= table_end) { > + if (entry->type == ACPI_PPTT_TYPE_PROCESSOR) { > + struct acpi_pptt_processor *cpu_node; > + > + cpu_node = (struct acpi_pptt_processor *)entry; > + if (cpu_node->flags & ACPI_PPTT_ACPI_PROCESSOR_ID_VALID && > + !acpi_pptt_leaf_node(table_hdr, cpu_node) && > + cpu_node->acpi_processor_id == acpi_cpu_id) { > + acpi_pptt_get_child_cpus(table_hdr, cpu_node, cpus); > + break; > + } > + } > + entry = ACPI_ADD_PTR(struct acpi_subtable_header, entry, > + entry->length); > + } > +} > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > index 5ff5d99f6ead..4752ebd48132 100644 > --- a/include/linux/acpi.h > +++ b/include/linux/acpi.h > @@ -1541,6 +1541,7 @@ int find_acpi_cpu_topology(unsigned int cpu, int level); > int find_acpi_cpu_topology_cluster(unsigned int cpu); > int find_acpi_cpu_topology_package(unsigned int cpu); > int find_acpi_cpu_topology_hetero_id(unsigned int cpu); > +void acpi_pptt_get_cpus_from_container(u32 acpi_cpu_id, cpumask_t *cpus); > #else > static inline int acpi_pptt_cpu_is_thread(unsigned int cpu) > { > @@ -1562,6 +1563,8 @@ static inline int find_acpi_cpu_topology_hetero_id(unsigned int cpu) > { > return -EINVAL; > } > +static inline void acpi_pptt_get_cpus_from_container(u32 acpi_cpu_id, > + cpumask_t *cpus) { } > #endif > > void acpi_arch_init(void); Thanks, Gavin