linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] arm64/PPTT ACPI 6.3 thread flag support
@ 2019-05-23 22:40 Jeremy Linton
  2019-05-23 22:40 ` [PATCH 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag Jeremy Linton
  2019-05-23 22:40 ` [PATCH 2/2] arm64: topology: Use PPTT to determine if PE is a thread Jeremy Linton
  0 siblings, 2 replies; 8+ messages in thread
From: Jeremy Linton @ 2019-05-23 22:40 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-acpi, catalin.marinas, will.deacon, rjw, lenb,
	sudeep.holla, Jeremy Linton

ACPI 6.3 adds a flag to the CPU node to indicate whether
the given CPU is a thread. Add a function to return that
information for a given linux logical CPU and then utilize
it while building the arm64 topology.

Jeremy Linton (2):
  ACPI/PPTT: Add support for ACPI 6.3 thread flag
  arm64: topology: Use PPTT to determine if PE is a thread

 arch/arm64/kernel/topology.c |  8 ++++--
 drivers/acpi/pptt.c          | 53 +++++++++++++++++++++++++++++++++++-
 include/linux/acpi.h         |  5 ++++
 3 files changed, 62 insertions(+), 4 deletions(-)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag
  2019-05-23 22:40 [PATCH 0/2] arm64/PPTT ACPI 6.3 thread flag support Jeremy Linton
@ 2019-05-23 22:40 ` Jeremy Linton
  2019-06-07 10:03   ` Sudeep Holla
  2019-05-23 22:40 ` [PATCH 2/2] arm64: topology: Use PPTT to determine if PE is a thread Jeremy Linton
  1 sibling, 1 reply; 8+ messages in thread
From: Jeremy Linton @ 2019-05-23 22:40 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-acpi, catalin.marinas, will.deacon, rjw, lenb,
	sudeep.holla, Jeremy Linton

ACPI 6.3 adds a flag to the CPU node to indicate whether
the given PE is a thread. Add a function to return that
information for a given linux logical CPU.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 drivers/acpi/pptt.c  | 53 +++++++++++++++++++++++++++++++++++++++++++-
 include/linux/acpi.h |  5 +++++
 2 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
index b72e6afaa8fb..6f43a0c05f61 100644
--- a/drivers/acpi/pptt.c
+++ b/drivers/acpi/pptt.c
@@ -517,6 +517,43 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag)
 	return retval;
 }
 
+/**
+ * check_acpi_cpu_flag() - Determine if CPU node has a flag set
+ * @cpu: Kernel logical CPU number
+ * @rev: The PPTT revision defining the flag
+ * @flag: The flag itself
+ *
+ * Check the node representing a CPU for a given flag.
+ *
+ * Return: -ENOENT if the PPTT doesn't exist, the CPU cannot be found or
+ *	   the table revision isn't new enough.
+ * Otherwise returns flag value
+ */
+static int check_acpi_cpu_flag(unsigned int cpu, int rev, u32 flag)
+{
+	struct acpi_table_header *table;
+	acpi_status status;
+	u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu);
+	struct acpi_pptt_processor *cpu_node = NULL;
+	int ret = -ENONET;
+
+	status = acpi_get_table(ACPI_SIG_PPTT, 0, &table);
+	if (ACPI_FAILURE(status)) {
+		acpi_pptt_warn_missing();
+		return ret;
+	}
+
+	if (table->revision >= rev)
+		cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
+
+	if (cpu_node)
+		ret = cpu_node->flags & flag;
+
+	acpi_put_table(table);
+
+	return ret;
+}
+
 /**
  * acpi_find_last_cache_level() - Determines the number of cache levels for a PE
  * @cpu: Kernel logical CPU number
@@ -581,6 +618,21 @@ int cache_setup_acpi(unsigned int cpu)
 	return status;
 }
 
+/**
+ * acpi_pptt_cpu_is_thread() - Determine if logical CPU is a thread
+ * @cpu: Kernel logical CPU number
+ *
+ *
+ * Return: 1, a thread
+ *         0, not a thread
+ *         -ENOENT if the PPTT doesn't exist, the CPU cannot be found or
+ *         the table revision isn't new enough.
+ */
+int acpi_pptt_cpu_is_thread(unsigned int cpu)
+{
+	return check_acpi_cpu_flag(cpu, 2, ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD);
+}
+
 /**
  * find_acpi_cpu_topology() - Determine a unique topology value for a given CPU
  * @cpu: Kernel logical CPU number
@@ -641,7 +693,6 @@ int find_acpi_cpu_cache_topology(unsigned int cpu, int level)
 	return ret;
 }
 
-
 /**
  * find_acpi_cpu_topology_package() - Determine a unique CPU package value
  * @cpu: Kernel logical CPU number
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 98440df7fe42..513833233c65 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -1314,10 +1314,15 @@ static inline int lpit_read_residency_count_address(u64 *address)
 #endif
 
 #ifdef CONFIG_ACPI_PPTT
+int acpi_pptt_cpu_is_thread(unsigned int cpu);
 int find_acpi_cpu_topology(unsigned int cpu, int level);
 int find_acpi_cpu_topology_package(unsigned int cpu);
 int find_acpi_cpu_cache_topology(unsigned int cpu, int level);
 #else
+static inline int acpi_pptt_cpu_is_thread(unsigned int cpu)
+{
+	return -EINVAL;
+}
 static inline int find_acpi_cpu_topology(unsigned int cpu, int level)
 {
 	return -EINVAL;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] arm64: topology: Use PPTT to determine if PE is a thread
  2019-05-23 22:40 [PATCH 0/2] arm64/PPTT ACPI 6.3 thread flag support Jeremy Linton
  2019-05-23 22:40 ` [PATCH 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag Jeremy Linton
@ 2019-05-23 22:40 ` Jeremy Linton
  2019-06-06  8:49   ` John Garry
  1 sibling, 1 reply; 8+ messages in thread
From: Jeremy Linton @ 2019-05-23 22:40 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-acpi, catalin.marinas, will.deacon, rjw, lenb,
	sudeep.holla, Jeremy Linton

ACPI 6.3 adds a thread flag to represent if a CPU/PE is
actually a thread. Given that the MPIDR_MT bit may not
represent this information consistently on homogeneous machines
we should prefer the PPTT flag if its available.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 arch/arm64/kernel/topology.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
index 0825c4a856e3..cbbedb53cf06 100644
--- a/arch/arm64/kernel/topology.c
+++ b/arch/arm64/kernel/topology.c
@@ -346,11 +346,9 @@ void remove_cpu_topology(unsigned int cpu)
  */
 static int __init parse_acpi_topology(void)
 {
-	bool is_threaded;
+	int is_threaded;
 	int cpu, topology_id;
 
-	is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK;
-
 	for_each_possible_cpu(cpu) {
 		int i, cache_id;
 
@@ -358,6 +356,10 @@ static int __init parse_acpi_topology(void)
 		if (topology_id < 0)
 			return topology_id;
 
+		is_threaded = acpi_pptt_cpu_is_thread(cpu);
+		if (is_threaded < 0)
+			is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK;
+
 		if (is_threaded) {
 			cpu_topology[cpu].thread_id = topology_id;
 			topology_id = find_acpi_cpu_topology(cpu, 1);
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] arm64: topology: Use PPTT to determine if PE is a thread
  2019-05-23 22:40 ` [PATCH 2/2] arm64: topology: Use PPTT to determine if PE is a thread Jeremy Linton
@ 2019-06-06  8:49   ` John Garry
  2019-06-07 19:21     ` Jeremy Linton
  0 siblings, 1 reply; 8+ messages in thread
From: John Garry @ 2019-06-06  8:49 UTC (permalink / raw)
  To: Jeremy Linton, linux-arm-kernel
  Cc: linux-acpi, catalin.marinas, will.deacon, rjw, lenb,
	sudeep.holla, Linuxarm, Guohanjun (Hanjun Guo),
	wanghuiqiang, yaohongbo

On 23/05/2019 23:40, Jeremy Linton wrote:
> ACPI 6.3 adds a thread flag to represent if a CPU/PE is
> actually a thread. Given that the MPIDR_MT bit may not
> represent this information consistently on homogeneous machines
> we should prefer the PPTT flag if its available.
>

Hi Jeremy,

I was just wondering if we should look to get this support backported 
(when merged)?

I worry about the case of a system with the CPU having MT bit in the 
MPIDR (while not actually threaded), i.e. the system for which these 
PPTT flags were added (as I understand).

> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>  arch/arm64/kernel/topology.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
> index 0825c4a856e3..cbbedb53cf06 100644
> --- a/arch/arm64/kernel/topology.c
> +++ b/arch/arm64/kernel/topology.c
> @@ -346,11 +346,9 @@ void remove_cpu_topology(unsigned int cpu)
>   */
>  static int __init parse_acpi_topology(void)
>  {
> -	bool is_threaded;
> +	int is_threaded;
>  	int cpu, topology_id;
>
> -	is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK;
> -
>  	for_each_possible_cpu(cpu) {
>  		int i, cache_id;
>
> @@ -358,6 +356,10 @@ static int __init parse_acpi_topology(void)
>  		if (topology_id < 0)
>  			return topology_id;
>
> +		is_threaded = acpi_pptt_cpu_is_thread(cpu);
> +		if (is_threaded < 0)
> +			is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK;
> +
>  		if (is_threaded) {
>  			cpu_topology[cpu].thread_id = topology_id;

For described above scenario, this seems wrong.

>  			topology_id = find_acpi_cpu_topology(cpu, 1);
>

BTW, we did test an old kernel with 6.3 PPTT bios for this on D06 (some 
versions have MT bit set), and it looked ok. But I am still a bit skeptical.

Thanks,
John



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag
  2019-05-23 22:40 ` [PATCH 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag Jeremy Linton
@ 2019-06-07 10:03   ` Sudeep Holla
  0 siblings, 0 replies; 8+ messages in thread
From: Sudeep Holla @ 2019-06-07 10:03 UTC (permalink / raw)
  To: Jeremy Linton
  Cc: linux-arm-kernel, linux-acpi, catalin.marinas, will.deacon, rjw,
	lenb, Sudeep Holla

On Thu, May 23, 2019 at 05:40:14PM -0500, Jeremy Linton wrote:
> ACPI 6.3 adds a flag to the CPU node to indicate whether
> the given PE is a thread. Add a function to return that
> information for a given linux logical CPU.
> 
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>  drivers/acpi/pptt.c  | 53 +++++++++++++++++++++++++++++++++++++++++++-
>  include/linux/acpi.h |  5 +++++
>  2 files changed, 57 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
> index b72e6afaa8fb..6f43a0c05f61 100644
> --- a/drivers/acpi/pptt.c
> +++ b/drivers/acpi/pptt.c
> @@ -517,6 +517,43 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag)
>  	return retval;
>  }
>  
> +/**
> + * check_acpi_cpu_flag() - Determine if CPU node has a flag set
> + * @cpu: Kernel logical CPU number
> + * @rev: The PPTT revision defining the flag
> + * @flag: The flag itself
> + *
> + * Check the node representing a CPU for a given flag.
> + *
> + * Return: -ENOENT if the PPTT doesn't exist, the CPU cannot be found or
> + *	   the table revision isn't new enough.
> + * Otherwise returns flag value
> + */
> +static int check_acpi_cpu_flag(unsigned int cpu, int rev, u32 flag)

Initially, I thought we already have similar function, but I was wrong.

> +{
> +	struct acpi_table_header *table;
> +	acpi_status status;
> +	u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu);
> +	struct acpi_pptt_processor *cpu_node = NULL;
> +	int ret = -ENONET;


Unfortunately even ENONET is defined and will silently compile fine, but
I assume you need ENOENT as mentioned in the comment/doc.
> +
> +	status = acpi_get_table(ACPI_SIG_PPTT, 0, &table);
> +	if (ACPI_FAILURE(status)) {
> +		acpi_pptt_warn_missing();
> +		return ret;
> +	}
> +
> +	if (table->revision >= rev)
> +		cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
> +
> +	if (cpu_node)
> +		ret = cpu_node->flags & flag;
> +
> +	acpi_put_table(table);
> +
> +	return ret;
> +}
> +
>  /**
>   * acpi_find_last_cache_level() - Determines the number of cache levels for a PE
>   * @cpu: Kernel logical CPU number
> @@ -581,6 +618,21 @@ int cache_setup_acpi(unsigned int cpu)
>  	return status;
>  }
>  
> +/**
> + * acpi_pptt_cpu_is_thread() - Determine if logical CPU is a thread
> + * @cpu: Kernel logical CPU number
> + *
> + *
> + * Return: 1, a thread
> + *         0, not a thread
> + *         -ENOENT if the PPTT doesn't exist, the CPU cannot be found or
> + *         the table revision isn't new enough.
> + */
> +int acpi_pptt_cpu_is_thread(unsigned int cpu)
> +{
> +	return check_acpi_cpu_flag(cpu, 2, ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD);
> +}
> +
>  /**
>   * find_acpi_cpu_topology() - Determine a unique topology value for a given CPU
>   * @cpu: Kernel logical CPU number
> @@ -641,7 +693,6 @@ int find_acpi_cpu_cache_topology(unsigned int cpu, int level)
>  	return ret;
>  }
>  
> -

Spurious ?

>  /**
>   * find_acpi_cpu_topology_package() - Determine a unique CPU package value
>   * @cpu: Kernel logical CPU number
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 98440df7fe42..513833233c65 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -1314,10 +1314,15 @@ static inline int lpit_read_residency_count_address(u64 *address)
>  #endif
>  
>  #ifdef CONFIG_ACPI_PPTT
> +int acpi_pptt_cpu_is_thread(unsigned int cpu);
>  int find_acpi_cpu_topology(unsigned int cpu, int level);
>  int find_acpi_cpu_topology_package(unsigned int cpu);
>  int find_acpi_cpu_cache_topology(unsigned int cpu, int level);
>  #else
> +static inline int acpi_pptt_cpu_is_thread(unsigned int cpu)
> +{
> +	return -EINVAL;
> +}
>  static inline int find_acpi_cpu_topology(unsigned int cpu, int level)
>  {
>  	return -EINVAL;
> -- 
> 2.21.0
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] arm64: topology: Use PPTT to determine if PE is a thread
  2019-06-06  8:49   ` John Garry
@ 2019-06-07 19:21     ` Jeremy Linton
  2019-06-10  8:30       ` John Garry
  0 siblings, 1 reply; 8+ messages in thread
From: Jeremy Linton @ 2019-06-07 19:21 UTC (permalink / raw)
  To: John Garry, linux-arm-kernel
  Cc: linux-acpi, catalin.marinas, will.deacon, rjw, lenb,
	sudeep.holla, Linuxarm, Guohanjun (Hanjun Guo),
	wanghuiqiang, yaohongbo

Hi,

Thanks for testing and looking at this.

On 6/6/19 3:49 AM, John Garry wrote:
> On 23/05/2019 23:40, Jeremy Linton wrote:
>> ACPI 6.3 adds a thread flag to represent if a CPU/PE is
>> actually a thread. Given that the MPIDR_MT bit may not
>> represent this information consistently on homogeneous machines
>> we should prefer the PPTT flag if its available.
>>
> 
> Hi Jeremy,
> 
> I was just wondering if we should look to get this support backported 
> (when merged)?

I imagine that will happen..

> 
> I worry about the case of a system with the CPU having MT bit in the 
> MPIDR (while not actually threaded), i.e. the system for which these 
> PPTT flags were added (as I understand).

I have tested this patch on DAWN which happens to have the MT bit set, 
but isn't threaded, and it appears to work.

> 
>> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
>> ---
>>  arch/arm64/kernel/topology.c | 8 +++++---
>>  1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
>> index 0825c4a856e3..cbbedb53cf06 100644
>> --- a/arch/arm64/kernel/topology.c
>> +++ b/arch/arm64/kernel/topology.c
>> @@ -346,11 +346,9 @@ void remove_cpu_topology(unsigned int cpu)
>>   */
>>  static int __init parse_acpi_topology(void)
>>  {
>> -    bool is_threaded;
>> +    int is_threaded;
>>      int cpu, topology_id;
>>
>> -    is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK;
>> -
>>      for_each_possible_cpu(cpu) {
>>          int i, cache_id;
>>
>> @@ -358,6 +356,10 @@ static int __init parse_acpi_topology(void)
>>          if (topology_id < 0)
>>              return topology_id;
>>
>> +        is_threaded = acpi_pptt_cpu_is_thread(cpu);
>> +        if (is_threaded < 0)
>> +            is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK;
>> +
>>          if (is_threaded) {
>>              cpu_topology[cpu].thread_id = topology_id;
> 
> For described above scenario, this seems wrong.

I'm not sure I understand the concern.

This is going to ignore the MPIDR_MT bit on any machine with a PPTT 
revision > 1. Are you worried about the topology_id assignment?


> 
>>              topology_id = find_acpi_cpu_topology(cpu, 1);
>>
> 
> BTW, we did test an old kernel with 6.3 PPTT bios for this on D06 (some 
> versions have MT bit set), and it looked ok. But I am still a bit 
> skeptical.
> 
> Thanks,
> John
> 
> 


Thanks,

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] arm64: topology: Use PPTT to determine if PE is a thread
  2019-06-07 19:21     ` Jeremy Linton
@ 2019-06-10  8:30       ` John Garry
  2019-06-11 19:02         ` Jeremy Linton
  0 siblings, 1 reply; 8+ messages in thread
From: John Garry @ 2019-06-10  8:30 UTC (permalink / raw)
  To: Jeremy Linton, linux-arm-kernel
  Cc: linux-acpi, catalin.marinas, will.deacon, rjw, lenb,
	sudeep.holla, Linuxarm, Guohanjun (Hanjun Guo),
	wanghuiqiang, yaohongbo

On 07/06/2019 20:21, Jeremy Linton wrote:
> Hi,
>
> Thanks for testing and looking at this.
>
> On 6/6/19 3:49 AM, John Garry wrote:
>> On 23/05/2019 23:40, Jeremy Linton wrote:
>>> ACPI 6.3 adds a thread flag to represent if a CPU/PE is
>>> actually a thread. Given that the MPIDR_MT bit may not
>>> represent this information consistently on homogeneous machines
>>> we should prefer the PPTT flag if its available.
>>>
>>

Hi Jeremy,

>>
>> I was just wondering if we should look to get this support backported
>> (when merged)?
>
> I imagine that will happen..
>
>>
>> I worry about the case of a system with the CPU having MT bit in the
>> MPIDR (while not actually threaded), i.e. the system for which these
>> PPTT flags were added (as I understand).
>
> I have tested this patch on DAWN which happens to have the MT bit set,
> but isn't threaded, and it appears to work.

Can you describe your test?

>
>>
>>> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
>>> ---
>>>  arch/arm64/kernel/topology.c | 8 +++++---
>>>  1 file changed, 5 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
>>> index 0825c4a856e3..cbbedb53cf06 100644
>>> --- a/arch/arm64/kernel/topology.c
>>> +++ b/arch/arm64/kernel/topology.c
>>> @@ -346,11 +346,9 @@ void remove_cpu_topology(unsigned int cpu)
>>>   */
>>>  static int __init parse_acpi_topology(void)
>>>  {
>>> -    bool is_threaded;
>>> +    int is_threaded;
>>>      int cpu, topology_id;
>>>
>>> -    is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK;
>>> -
>>>      for_each_possible_cpu(cpu) {
>>>          int i, cache_id;
>>>
>>> @@ -358,6 +356,10 @@ static int __init parse_acpi_topology(void)
>>>          if (topology_id < 0)
>>>              return topology_id;
>>>
>>> +        is_threaded = acpi_pptt_cpu_is_thread(cpu);
>>> +        if (is_threaded < 0)
>>> +            is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK;
>>> +
>>>          if (is_threaded) {
>>>              cpu_topology[cpu].thread_id = topology_id;
>>
>> For described above scenario, this seems wrong.
>
> I'm not sure I understand the concern.

Maybe I wasn't clear enough previously. I am saying that without this 
patch, then this info would not be correct. Hence the request to 
backport to stable.

cheers,

>
> This is going to ignore the MPIDR_MT bit on any machine with a PPTT
> revision > 1. Are you worried about the topology_id assignment?
>
>
>>
>>>              topology_id = find_acpi_cpu_topology(cpu, 1);
>>>
>>
>> BTW, we did test an old kernel with 6.3 PPTT bios for this on D06
>> (some versions have MT bit set), and it looked ok. But I am still a
>> bit skeptical.
>>
>> Thanks,
>> John
>>
>>
>
>
> Thanks,
>
> .
>



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] arm64: topology: Use PPTT to determine if PE is a thread
  2019-06-10  8:30       ` John Garry
@ 2019-06-11 19:02         ` Jeremy Linton
  0 siblings, 0 replies; 8+ messages in thread
From: Jeremy Linton @ 2019-06-11 19:02 UTC (permalink / raw)
  To: John Garry, linux-arm-kernel
  Cc: linux-acpi, catalin.marinas, will.deacon, rjw, lenb,
	sudeep.holla, Linuxarm, Guohanjun (Hanjun Guo),
	wanghuiqiang, yaohongbo

Hi,

On 6/10/19 3:30 AM, John Garry wrote:
> On 07/06/2019 20:21, Jeremy Linton wrote:
>> Hi,
>>
>> Thanks for testing and looking at this.
>>
>> On 6/6/19 3:49 AM, John Garry wrote:
>>> On 23/05/2019 23:40, Jeremy Linton wrote:
>>>> ACPI 6.3 adds a thread flag to represent if a CPU/PE is
>>>> actually a thread. Given that the MPIDR_MT bit may not
>>>> represent this information consistently on homogeneous machines
>>>> we should prefer the PPTT flag if its available.
>>>>
>>>
> 
> Hi Jeremy,
> 
>>>
>>> I was just wondering if we should look to get this support backported
>>> (when merged)?
>>
>> I imagine that will happen..
>>
>>>
>>> I worry about the case of a system with the CPU having MT bit in the
>>> MPIDR (while not actually threaded), i.e. the system for which these
>>> PPTT flags were added (as I understand).
>>
>> I have tested this patch on DAWN which happens to have the MT bit set,
>> but isn't threaded, and it appears to work.
> 
> Can you describe your test?

The positive test:

Boot machine with/without patch, compare the output of lscpu & lstopo. 
Manually check/compare /sys/devices/system/cpu/cpuX/topology/* and 
/proc/schedstat domain masks. On DAWN we go from a system reporting 2 
cores with 2 thread per core to 4 cores.

I've also built firmware or injected PPTT's with varying versions/etc to 
sanity check cases that aren't representative of the hardware.



> 
>>
>>>
>>>> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
>>>> ---
>>>>  arch/arm64/kernel/topology.c | 8 +++++---
>>>>  1 file changed, 5 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/arch/arm64/kernel/topology.c 
>>>> b/arch/arm64/kernel/topology.c
>>>> index 0825c4a856e3..cbbedb53cf06 100644
>>>> --- a/arch/arm64/kernel/topology.c
>>>> +++ b/arch/arm64/kernel/topology.c
>>>> @@ -346,11 +346,9 @@ void remove_cpu_topology(unsigned int cpu)
>>>>   */
>>>>  static int __init parse_acpi_topology(void)
>>>>  {
>>>> -    bool is_threaded;
>>>> +    int is_threaded;
>>>>      int cpu, topology_id;
>>>>
>>>> -    is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK;
>>>> -
>>>>      for_each_possible_cpu(cpu) {
>>>>          int i, cache_id;
>>>>
>>>> @@ -358,6 +356,10 @@ static int __init parse_acpi_topology(void)
>>>>          if (topology_id < 0)
>>>>              return topology_id;
>>>>
>>>> +        is_threaded = acpi_pptt_cpu_is_thread(cpu);
>>>> +        if (is_threaded < 0)
>>>> +            is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK;
>>>> +
>>>>          if (is_threaded) {
>>>>              cpu_topology[cpu].thread_id = topology_id;
>>>
>>> For described above scenario, this seems wrong.
>>
>> I'm not sure I understand the concern.
> 
> Maybe I wasn't clear enough previously. I am saying that without this 
> patch, then this info would not be correct. Hence the request to 
> backport to stable.
> 
> cheers,
> 
>>
>> This is going to ignore the MPIDR_MT bit on any machine with a PPTT
>> revision > 1. Are you worried about the topology_id assignment?
>>
>>
>>>
>>>>              topology_id = find_acpi_cpu_topology(cpu, 1);
>>>>
>>>
>>> BTW, we did test an old kernel with 6.3 PPTT bios for this on D06
>>> (some versions have MT bit set), and it looked ok. But I am still a
>>> bit skeptical.
>>>
>>> Thanks,
>>> John
>>>
>>>
>>
>>
>> Thanks,
>>
>> .
>>
> 
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-06-11 19:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-23 22:40 [PATCH 0/2] arm64/PPTT ACPI 6.3 thread flag support Jeremy Linton
2019-05-23 22:40 ` [PATCH 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag Jeremy Linton
2019-06-07 10:03   ` Sudeep Holla
2019-05-23 22:40 ` [PATCH 2/2] arm64: topology: Use PPTT to determine if PE is a thread Jeremy Linton
2019-06-06  8:49   ` John Garry
2019-06-07 19:21     ` Jeremy Linton
2019-06-10  8:30       ` John Garry
2019-06-11 19:02         ` Jeremy Linton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).