Re: [PATCH RFC/RFT v2 3/8] s390: move cacheinfo sysfs to generic cacheinfo infrastructure

2014-02-18 Thread Heiko Carstens
Hi Sudeep,

> > Please have a look at these two commits which should describe why things
> > are as they are on s390:
> > 
> > 881730ad365130f64b5c70c40904b04eb3b79de3
> >  "s390/cache: expose cpu cache topology via sysfs"
> > 6668022c7bde3fdc96d3d257294a7216c7a46829
> >  "s390/cache: add cpu cache information to /proc/cpuinfo"
> > 
>
> I need your help to get few things clarified.
> 
> IIUC, I see that shared caches are not exposed via sysfs but there are exposed
> through /proc/cpuinfo, right ?

Yes.

> If yes, based on your above statement, shared
> cpus are may not be system-wide, then how can /proc/cpuinfo show shared
> cache info.

/proc/cpuinfo shows the information of the underlying hardware but we
cannot tell which second level (virtual) cpus share which caches.
There simply is no such interface available.

Also, if there would be such an interface, it would be only valid until
the hypervisor decides to schedule a virtual cpu on a different physical
cpu; which in turn would mean that we would have to update the cpu maps
all the time.

In order to avoid all those games, we decided to only expose cpu private
caches via sysfs, so we obviously have static cpu maps.

However since the physical cache information may be of interest for a
guest operating system there is the second interface /proc/cpuinfo
which provides this.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC/RFT v2 3/8] s390: move cacheinfo sysfs to generic cacheinfo infrastructure

2014-02-18 Thread Heiko Carstens
Hi Sudeep,

  Please have a look at these two commits which should describe why things
  are as they are on s390:
  
  881730ad365130f64b5c70c40904b04eb3b79de3
   s390/cache: expose cpu cache topology via sysfs
  6668022c7bde3fdc96d3d257294a7216c7a46829
   s390/cache: add cpu cache information to /proc/cpuinfo
  

 I need your help to get few things clarified.
 
 IIUC, I see that shared caches are not exposed via sysfs but there are exposed
 through /proc/cpuinfo, right ?

Yes.

 If yes, based on your above statement, shared
 cpus are may not be system-wide, then how can /proc/cpuinfo show shared
 cache info.

/proc/cpuinfo shows the information of the underlying hardware but we
cannot tell which second level (virtual) cpus share which caches.
There simply is no such interface available.

Also, if there would be such an interface, it would be only valid until
the hypervisor decides to schedule a virtual cpu on a different physical
cpu; which in turn would mean that we would have to update the cpu maps
all the time.

In order to avoid all those games, we decided to only expose cpu private
caches via sysfs, so we obviously have static cpu maps.

However since the physical cache information may be of interest for a
guest operating system there is the second interface /proc/cpuinfo
which provides this.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC/RFT v2 3/8] s390: move cacheinfo sysfs to generic cacheinfo infrastructure

2014-02-17 Thread Sudeep Holla
Hi Heiko,

On 10/02/14 11:30, Heiko Carstens wrote:
> On Fri, Feb 07, 2014 at 04:49:18PM +, Sudeep Holla wrote:
>> From: Sudeep Holla 
>>
>> This patch removes the redundant sysfs cacheinfo code by making use of
>> the newly introduced generic cacheinfo infrastructure.
>>
>> Signed-off-by: Sudeep Holla 
> 
> [...]
> 
>> -static ssize_t shared_cpu_map_func(struct kobject *kobj, int type, char 
>> *buf)
>> -{
>> -struct cache_index_dir *index;
>> -int len;
>> +this_leaf->level = level + 1;
>> +this_leaf->type = type;
>> +this_leaf->coherency_line_size = ecag(EXTRACT_LINE_SIZE, level, ti);
>> +this_leaf->ways_of_associativity = ecag(EXTRACT_ASSOCIATIVITY,
>> +level, ti);
>> +this_leaf->size = ecag(EXTRACT_SIZE, level, ti);
>> +if (private)
>> +cpumask_set_cpu(cpu, _leaf->shared_cpu_map);
>> +else /* System wide */
>> +cpumask_copy(_leaf->shared_cpu_map, cpu_online_mask);
> 
> FWIW, this also seems to be wrong: on s390 we only expose cpu private
> caches via sysfs. Shared caches are not exposed (and simply saying they are
> system wide would be wrong).
> Please have a look at these two commits which should describe why things
> are as they are on s390:
> 
> 881730ad365130f64b5c70c40904b04eb3b79de3
>  "s390/cache: expose cpu cache topology via sysfs"
> 6668022c7bde3fdc96d3d257294a7216c7a46829
>  "s390/cache: add cpu cache information to /proc/cpuinfo"
> 
>

I need your help to get few things clarified.

IIUC, I see that shared caches are not exposed via sysfs but there are exposed
through /proc/cpuinfo, right ? If yes, based on your above statement, shared
cpus are may not be system-wide, then how can /proc/cpuinfo show shared cache 
info.

Regards,
Sudeep

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC/RFT v2 3/8] s390: move cacheinfo sysfs to generic cacheinfo infrastructure

2014-02-17 Thread Sudeep Holla
Hi Heiko,

On 10/02/14 11:30, Heiko Carstens wrote:
 On Fri, Feb 07, 2014 at 04:49:18PM +, Sudeep Holla wrote:
 From: Sudeep Holla sudeep.ho...@arm.com

 This patch removes the redundant sysfs cacheinfo code by making use of
 the newly introduced generic cacheinfo infrastructure.

 Signed-off-by: Sudeep Holla sudeep.ho...@arm.com
 
 [...]
 
 -static ssize_t shared_cpu_map_func(struct kobject *kobj, int type, char 
 *buf)
 -{
 -struct cache_index_dir *index;
 -int len;
 +this_leaf-level = level + 1;
 +this_leaf-type = type;
 +this_leaf-coherency_line_size = ecag(EXTRACT_LINE_SIZE, level, ti);
 +this_leaf-ways_of_associativity = ecag(EXTRACT_ASSOCIATIVITY,
 +level, ti);
 +this_leaf-size = ecag(EXTRACT_SIZE, level, ti);
 +if (private)
 +cpumask_set_cpu(cpu, this_leaf-shared_cpu_map);
 +else /* System wide */
 +cpumask_copy(this_leaf-shared_cpu_map, cpu_online_mask);
 
 FWIW, this also seems to be wrong: on s390 we only expose cpu private
 caches via sysfs. Shared caches are not exposed (and simply saying they are
 system wide would be wrong).
 Please have a look at these two commits which should describe why things
 are as they are on s390:
 
 881730ad365130f64b5c70c40904b04eb3b79de3
  s390/cache: expose cpu cache topology via sysfs
 6668022c7bde3fdc96d3d257294a7216c7a46829
  s390/cache: add cpu cache information to /proc/cpuinfo
 


I need your help to get few things clarified.

IIUC, I see that shared caches are not exposed via sysfs but there are exposed
through /proc/cpuinfo, right ? If yes, based on your above statement, shared
cpus are may not be system-wide, then how can /proc/cpuinfo show shared cache 
info.

Regards,
Sudeep

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC/RFT v2 3/8] s390: move cacheinfo sysfs to generic cacheinfo infrastructure

2014-02-10 Thread Heiko Carstens
On Mon, Feb 10, 2014 at 11:34:55AM +, Sudeep Holla wrote:
> On 10/02/14 09:50, Heiko Carstens wrote:
> > On Fri, Feb 07, 2014 at 04:49:18PM +, Sudeep Holla wrote:
> >> -  show_cacheinfo(m);
> >>}
> >>get_online_cpus();
> >>if (cpu_online(n)) {
> > 
> > You can't remove that. It's a user space visible change.
> > 
> Correct, I wanted to add show_cacheinfo back as its user ABI already, missed 
> it.
> 
> Is it ok if I use cpu0 cacheinfo or to be safer as cpu0 can be offline, use
> the cacheinfo of the cpu executing this ?

Any online cpu would do, as the information is completely symmetrical.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC/RFT v2 3/8] s390: move cacheinfo sysfs to generic cacheinfo infrastructure

2014-02-10 Thread Sudeep Holla
On 10/02/14 11:30, Heiko Carstens wrote:
> On Fri, Feb 07, 2014 at 04:49:18PM +, Sudeep Holla wrote:
>> From: Sudeep Holla 
>>
>> This patch removes the redundant sysfs cacheinfo code by making use of
>> the newly introduced generic cacheinfo infrastructure.
>>
>> Signed-off-by: Sudeep Holla 
> 
> [...]
> 
>> -static ssize_t shared_cpu_map_func(struct kobject *kobj, int type, char 
>> *buf)
>> -{
>> -struct cache_index_dir *index;
>> -int len;
>> +this_leaf->level = level + 1;
>> +this_leaf->type = type;
>> +this_leaf->coherency_line_size = ecag(EXTRACT_LINE_SIZE, level, ti);
>> +this_leaf->ways_of_associativity = ecag(EXTRACT_ASSOCIATIVITY,
>> +level, ti);
>> +this_leaf->size = ecag(EXTRACT_SIZE, level, ti);
>> +if (private)
>> +cpumask_set_cpu(cpu, _leaf->shared_cpu_map);
>> +else /* System wide */
>> +cpumask_copy(_leaf->shared_cpu_map, cpu_online_mask);
> 
> FWIW, this also seems to be wrong: on s390 we only expose cpu private
> caches via sysfs. Shared caches are not exposed (and simply saying they are
> system wide would be wrong).
> Please have a look at these two commits which should describe why things
> are as they are on s390:
> 
> 881730ad365130f64b5c70c40904b04eb3b79de3
>  "s390/cache: expose cpu cache topology via sysfs"
> 6668022c7bde3fdc96d3d257294a7216c7a46829
>  "s390/cache: add cpu cache information to /proc/cpuinfo"
> 
Thanks for the review, will have a look at these commits and update accordingly.

Regards,
Sudeep


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC/RFT v2 3/8] s390: move cacheinfo sysfs to generic cacheinfo infrastructure

2014-02-10 Thread Sudeep Holla
On 10/02/14 09:50, Heiko Carstens wrote:
> On Fri, Feb 07, 2014 at 04:49:18PM +, Sudeep Holla wrote:
>> From: Sudeep Holla 
>>
>> This patch removes the redundant sysfs cacheinfo code by making use of
>> the newly introduced generic cacheinfo infrastructure.
>>
>> Signed-off-by: Sudeep Holla 
>> Cc: Martin Schwidefsky 
>> Cc: Heiko Carstens 
>> Cc: linux...@de.ibm.com
>> Cc: linux-s...@vger.kernel.org
>> ---
> 
> [...]
> 
>> diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c
>> index 2461202..1f875db 100644
>> --- a/arch/s390/kernel/processor.c
>> +++ b/arch/s390/kernel/processor.c
>> @@ -58,7 +58,6 @@ static int show_cpuinfo(struct seq_file *m, void *v)
>>  if (hwcap_str[i] && (elf_hwcap & (1UL << i)))
>>  seq_printf(m, "%s ", hwcap_str[i]);
>>  seq_puts(m, "\n");
>> -show_cacheinfo(m);
>>  }
>>  get_online_cpus();
>>  if (cpu_online(n)) {
> 
> You can't remove that. It's a user space visible change.
> 
Correct, I wanted to add show_cacheinfo back as its user ABI already, missed it.

Is it ok if I use cpu0 cacheinfo or to be safer as cpu0 can be offline, use
the cacheinfo of the cpu executing this ?

Regards,
Sudeep


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC/RFT v2 3/8] s390: move cacheinfo sysfs to generic cacheinfo infrastructure

2014-02-10 Thread Heiko Carstens
On Fri, Feb 07, 2014 at 04:49:18PM +, Sudeep Holla wrote:
> From: Sudeep Holla 
> 
> This patch removes the redundant sysfs cacheinfo code by making use of
> the newly introduced generic cacheinfo infrastructure.
> 
> Signed-off-by: Sudeep Holla 

[...]

> -static ssize_t shared_cpu_map_func(struct kobject *kobj, int type, char *buf)
> -{
> - struct cache_index_dir *index;
> - int len;
> + this_leaf->level = level + 1;
> + this_leaf->type = type;
> + this_leaf->coherency_line_size = ecag(EXTRACT_LINE_SIZE, level, ti);
> + this_leaf->ways_of_associativity = ecag(EXTRACT_ASSOCIATIVITY,
> + level, ti);
> + this_leaf->size = ecag(EXTRACT_SIZE, level, ti);
> + if (private)
> + cpumask_set_cpu(cpu, _leaf->shared_cpu_map);
> + else /* System wide */
> + cpumask_copy(_leaf->shared_cpu_map, cpu_online_mask);

FWIW, this also seems to be wrong: on s390 we only expose cpu private
caches via sysfs. Shared caches are not exposed (and simply saying they are
system wide would be wrong).
Please have a look at these two commits which should describe why things
are as they are on s390:

881730ad365130f64b5c70c40904b04eb3b79de3
 "s390/cache: expose cpu cache topology via sysfs"
6668022c7bde3fdc96d3d257294a7216c7a46829
 "s390/cache: add cpu cache information to /proc/cpuinfo"

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC/RFT v2 3/8] s390: move cacheinfo sysfs to generic cacheinfo infrastructure

2014-02-10 Thread Heiko Carstens
On Fri, Feb 07, 2014 at 04:49:18PM +, Sudeep Holla wrote:
> From: Sudeep Holla 
> 
> This patch removes the redundant sysfs cacheinfo code by making use of
> the newly introduced generic cacheinfo infrastructure.
> 
> Signed-off-by: Sudeep Holla 
> Cc: Martin Schwidefsky 
> Cc: Heiko Carstens 
> Cc: linux...@de.ibm.com
> Cc: linux-s...@vger.kernel.org
> ---

[...]

> diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c
> index 2461202..1f875db 100644
> --- a/arch/s390/kernel/processor.c
> +++ b/arch/s390/kernel/processor.c
> @@ -58,7 +58,6 @@ static int show_cpuinfo(struct seq_file *m, void *v)
>   if (hwcap_str[i] && (elf_hwcap & (1UL << i)))
>   seq_printf(m, "%s ", hwcap_str[i]);
>   seq_puts(m, "\n");
> - show_cacheinfo(m);
>   }
>   get_online_cpus();
>   if (cpu_online(n)) {

You can't remove that. It's a user space visible change.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC/RFT v2 3/8] s390: move cacheinfo sysfs to generic cacheinfo infrastructure

2014-02-10 Thread Heiko Carstens
On Fri, Feb 07, 2014 at 04:49:18PM +, Sudeep Holla wrote:
 From: Sudeep Holla sudeep.ho...@arm.com
 
 This patch removes the redundant sysfs cacheinfo code by making use of
 the newly introduced generic cacheinfo infrastructure.
 
 Signed-off-by: Sudeep Holla sudeep.ho...@arm.com
 Cc: Martin Schwidefsky schwidef...@de.ibm.com
 Cc: Heiko Carstens heiko.carst...@de.ibm.com
 Cc: linux...@de.ibm.com
 Cc: linux-s...@vger.kernel.org
 ---

[...]

 diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c
 index 2461202..1f875db 100644
 --- a/arch/s390/kernel/processor.c
 +++ b/arch/s390/kernel/processor.c
 @@ -58,7 +58,6 @@ static int show_cpuinfo(struct seq_file *m, void *v)
   if (hwcap_str[i]  (elf_hwcap  (1UL  i)))
   seq_printf(m, %s , hwcap_str[i]);
   seq_puts(m, \n);
 - show_cacheinfo(m);
   }
   get_online_cpus();
   if (cpu_online(n)) {

You can't remove that. It's a user space visible change.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC/RFT v2 3/8] s390: move cacheinfo sysfs to generic cacheinfo infrastructure

2014-02-10 Thread Heiko Carstens
On Fri, Feb 07, 2014 at 04:49:18PM +, Sudeep Holla wrote:
 From: Sudeep Holla sudeep.ho...@arm.com
 
 This patch removes the redundant sysfs cacheinfo code by making use of
 the newly introduced generic cacheinfo infrastructure.
 
 Signed-off-by: Sudeep Holla sudeep.ho...@arm.com

[...]

 -static ssize_t shared_cpu_map_func(struct kobject *kobj, int type, char *buf)
 -{
 - struct cache_index_dir *index;
 - int len;
 + this_leaf-level = level + 1;
 + this_leaf-type = type;
 + this_leaf-coherency_line_size = ecag(EXTRACT_LINE_SIZE, level, ti);
 + this_leaf-ways_of_associativity = ecag(EXTRACT_ASSOCIATIVITY,
 + level, ti);
 + this_leaf-size = ecag(EXTRACT_SIZE, level, ti);
 + if (private)
 + cpumask_set_cpu(cpu, this_leaf-shared_cpu_map);
 + else /* System wide */
 + cpumask_copy(this_leaf-shared_cpu_map, cpu_online_mask);

FWIW, this also seems to be wrong: on s390 we only expose cpu private
caches via sysfs. Shared caches are not exposed (and simply saying they are
system wide would be wrong).
Please have a look at these two commits which should describe why things
are as they are on s390:

881730ad365130f64b5c70c40904b04eb3b79de3
 s390/cache: expose cpu cache topology via sysfs
6668022c7bde3fdc96d3d257294a7216c7a46829
 s390/cache: add cpu cache information to /proc/cpuinfo

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC/RFT v2 3/8] s390: move cacheinfo sysfs to generic cacheinfo infrastructure

2014-02-10 Thread Sudeep Holla
On 10/02/14 09:50, Heiko Carstens wrote:
 On Fri, Feb 07, 2014 at 04:49:18PM +, Sudeep Holla wrote:
 From: Sudeep Holla sudeep.ho...@arm.com

 This patch removes the redundant sysfs cacheinfo code by making use of
 the newly introduced generic cacheinfo infrastructure.

 Signed-off-by: Sudeep Holla sudeep.ho...@arm.com
 Cc: Martin Schwidefsky schwidef...@de.ibm.com
 Cc: Heiko Carstens heiko.carst...@de.ibm.com
 Cc: linux...@de.ibm.com
 Cc: linux-s...@vger.kernel.org
 ---
 
 [...]
 
 diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c
 index 2461202..1f875db 100644
 --- a/arch/s390/kernel/processor.c
 +++ b/arch/s390/kernel/processor.c
 @@ -58,7 +58,6 @@ static int show_cpuinfo(struct seq_file *m, void *v)
  if (hwcap_str[i]  (elf_hwcap  (1UL  i)))
  seq_printf(m, %s , hwcap_str[i]);
  seq_puts(m, \n);
 -show_cacheinfo(m);
  }
  get_online_cpus();
  if (cpu_online(n)) {
 
 You can't remove that. It's a user space visible change.
 
Correct, I wanted to add show_cacheinfo back as its user ABI already, missed it.

Is it ok if I use cpu0 cacheinfo or to be safer as cpu0 can be offline, use
the cacheinfo of the cpu executing this ?

Regards,
Sudeep


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC/RFT v2 3/8] s390: move cacheinfo sysfs to generic cacheinfo infrastructure

2014-02-10 Thread Sudeep Holla
On 10/02/14 11:30, Heiko Carstens wrote:
 On Fri, Feb 07, 2014 at 04:49:18PM +, Sudeep Holla wrote:
 From: Sudeep Holla sudeep.ho...@arm.com

 This patch removes the redundant sysfs cacheinfo code by making use of
 the newly introduced generic cacheinfo infrastructure.

 Signed-off-by: Sudeep Holla sudeep.ho...@arm.com
 
 [...]
 
 -static ssize_t shared_cpu_map_func(struct kobject *kobj, int type, char 
 *buf)
 -{
 -struct cache_index_dir *index;
 -int len;
 +this_leaf-level = level + 1;
 +this_leaf-type = type;
 +this_leaf-coherency_line_size = ecag(EXTRACT_LINE_SIZE, level, ti);
 +this_leaf-ways_of_associativity = ecag(EXTRACT_ASSOCIATIVITY,
 +level, ti);
 +this_leaf-size = ecag(EXTRACT_SIZE, level, ti);
 +if (private)
 +cpumask_set_cpu(cpu, this_leaf-shared_cpu_map);
 +else /* System wide */
 +cpumask_copy(this_leaf-shared_cpu_map, cpu_online_mask);
 
 FWIW, this also seems to be wrong: on s390 we only expose cpu private
 caches via sysfs. Shared caches are not exposed (and simply saying they are
 system wide would be wrong).
 Please have a look at these two commits which should describe why things
 are as they are on s390:
 
 881730ad365130f64b5c70c40904b04eb3b79de3
  s390/cache: expose cpu cache topology via sysfs
 6668022c7bde3fdc96d3d257294a7216c7a46829
  s390/cache: add cpu cache information to /proc/cpuinfo
 
Thanks for the review, will have a look at these commits and update accordingly.

Regards,
Sudeep


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC/RFT v2 3/8] s390: move cacheinfo sysfs to generic cacheinfo infrastructure

2014-02-10 Thread Heiko Carstens
On Mon, Feb 10, 2014 at 11:34:55AM +, Sudeep Holla wrote:
 On 10/02/14 09:50, Heiko Carstens wrote:
  On Fri, Feb 07, 2014 at 04:49:18PM +, Sudeep Holla wrote:
  -  show_cacheinfo(m);
 }
 get_online_cpus();
 if (cpu_online(n)) {
  
  You can't remove that. It's a user space visible change.
  
 Correct, I wanted to add show_cacheinfo back as its user ABI already, missed 
 it.
 
 Is it ok if I use cpu0 cacheinfo or to be safer as cpu0 can be offline, use
 the cacheinfo of the cpu executing this ?

Any online cpu would do, as the information is completely symmetrical.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RFC/RFT v2 3/8] s390: move cacheinfo sysfs to generic cacheinfo infrastructure

2014-02-07 Thread Sudeep Holla
From: Sudeep Holla 

This patch removes the redundant sysfs cacheinfo code by making use of
the newly introduced generic cacheinfo infrastructure.

Signed-off-by: Sudeep Holla 
Cc: Martin Schwidefsky 
Cc: Heiko Carstens 
Cc: linux...@de.ibm.com
Cc: linux-s...@vger.kernel.org
---
 arch/s390/include/asm/processor.h |   6 -
 arch/s390/kernel/cache.c  | 380 --
 arch/s390/kernel/processor.c  |   1 -
 3 files changed, 76 insertions(+), 311 deletions(-)

diff --git a/arch/s390/include/asm/processor.h 
b/arch/s390/include/asm/processor.h
index 0a876bc..84addf4 100644
--- a/arch/s390/include/asm/processor.h
+++ b/arch/s390/include/asm/processor.h
@@ -153,12 +153,6 @@ struct task_struct;
 struct mm_struct;
 struct seq_file;
 
-#ifdef CONFIG_64BIT
-extern void show_cacheinfo(struct seq_file *m);
-#else
-static inline void show_cacheinfo(struct seq_file *m) { }
-#endif
-
 /* Free all resources held by a thread. */
 extern void release_thread(struct task_struct *);
 
diff --git a/arch/s390/kernel/cache.c b/arch/s390/kernel/cache.c
index 3a414c0..e55dcd4 100644
--- a/arch/s390/kernel/cache.c
+++ b/arch/s390/kernel/cache.c
@@ -5,37 +5,11 @@
  *Author(s): Heiko Carstens 
  */
 
-#include 
 #include 
-#include 
-#include 
-#include 
 #include 
+#include 
 #include 
 
-struct cache {
-   unsigned long size;
-   unsigned int line_size;
-   unsigned int associativity;
-   unsigned int nr_sets;
-   unsigned int level   : 3;
-   unsigned int type: 2;
-   unsigned int private : 1;
-   struct list_head list;
-};
-
-struct cache_dir {
-   struct kobject *kobj;
-   struct cache_index_dir *index;
-};
-
-struct cache_index_dir {
-   struct kobject kobj;
-   int cpu;
-   struct cache *cache;
-   struct cache_index_dir *next;
-};
-
 enum {
CACHE_SCOPE_NOTEXISTS,
CACHE_SCOPE_PRIVATE,
@@ -44,10 +18,10 @@ enum {
 };
 
 enum {
-   CACHE_TYPE_SEPARATE,
-   CACHE_TYPE_DATA,
-   CACHE_TYPE_INSTRUCTION,
-   CACHE_TYPE_UNIFIED,
+   CTYPE_SEPARATE,
+   CTYPE_DATA,
+   CTYPE_INSTRUCTION,
+   CTYPE_UNIFIED,
 };
 
 enum {
@@ -63,44 +37,36 @@ enum {
CACHE_TI_INSTRUCTION,
 };
 
-struct cache_info {
+struct _cacheinfo {
unsigned char   : 4;
unsigned char scope : 2;
unsigned char type  : 2;
 };
 
 #define CACHE_MAX_LEVEL 8
-
 union cache_topology {
-   struct cache_info ci[CACHE_MAX_LEVEL];
+   struct _cacheinfo ci[CACHE_MAX_LEVEL];
unsigned long long raw;
 };
 
-static const char * const cache_type_string[] = {
-   "Data",
-   "Instruction",
-   "Unified",
+static const enum cache_type cache_type_map[] = {
+   [CTYPE_SEPARATE] = CACHE_TYPE_SEPARATE,
+   [CTYPE_DATA] = CACHE_TYPE_DATA,
+   [CTYPE_INSTRUCTION] = CACHE_TYPE_INST,
+   [CTYPE_UNIFIED] = CACHE_TYPE_UNIFIED,
 };
 
-static struct cache_dir *cache_dir_cpu[NR_CPUS];
-static LIST_HEAD(cache_list);
-
-void show_cacheinfo(struct seq_file *m)
+static inline enum cache_type get_cache_type(struct _cacheinfo *ci, int level)
 {
-   struct cache *cache;
-   int index = 0;
+   if (level >= CACHE_MAX_LEVEL)
+   return CACHE_TYPE_NOCACHE;
 
-   list_for_each_entry(cache, _list, list) {
-   seq_printf(m, "cache%-11d: ", index);
-   seq_printf(m, "level=%d ", cache->level);
-   seq_printf(m, "type=%s ", cache_type_string[cache->type]);
-   seq_printf(m, "scope=%s ", cache->private ? "Private" : 
"Shared");
-   seq_printf(m, "size=%luK ", cache->size >> 10);
-   seq_printf(m, "line_size=%u ", cache->line_size);
-   seq_printf(m, "associativity=%d", cache->associativity);
-   seq_puts(m, "\n");
-   index++;
-   }
+   ci += level;
+
+   if (ci->scope != CACHE_SCOPE_SHARED && ci->scope != CACHE_SCOPE_PRIVATE)
+   return CACHE_TYPE_NOCACHE;
+
+   return cache_type_map[ci->type];
 }
 
 static inline unsigned long ecag(int ai, int li, int ti)
@@ -113,274 +79,80 @@ static inline unsigned long ecag(int ai, int li, int ti)
return val;
 }
 
-static int __init cache_add(int level, int private, int type)
+static void ci_leaf_init(struct cache_info *this_leaf, int private,
+enum cache_type type, unsigned int level)
 {
-   struct cache *cache;
-   int ti;
+   int ti, num_sets;
+   int cpu = smp_processor_id();
 
-   cache = kzalloc(sizeof(*cache), GFP_KERNEL);
-   if (!cache)
-   return -ENOMEM;
-   if (type == CACHE_TYPE_INSTRUCTION)
+   if (type == CACHE_TYPE_INST)
ti = CACHE_TI_INSTRUCTION;
else
ti = CACHE_TI_UNIFIED;
-   cache->size = ecag(EXTRACT_SIZE, level, ti);
-   cache->line_size = ecag(EXTRACT_LINE_SIZE, level, ti);
-   cache->associativity = ecag(EXTRACT_ASSOCIATIVITY, level, ti);
-   

[PATCH RFC/RFT v2 3/8] s390: move cacheinfo sysfs to generic cacheinfo infrastructure

2014-02-07 Thread Sudeep Holla
From: Sudeep Holla sudeep.ho...@arm.com

This patch removes the redundant sysfs cacheinfo code by making use of
the newly introduced generic cacheinfo infrastructure.

Signed-off-by: Sudeep Holla sudeep.ho...@arm.com
Cc: Martin Schwidefsky schwidef...@de.ibm.com
Cc: Heiko Carstens heiko.carst...@de.ibm.com
Cc: linux...@de.ibm.com
Cc: linux-s...@vger.kernel.org
---
 arch/s390/include/asm/processor.h |   6 -
 arch/s390/kernel/cache.c  | 380 --
 arch/s390/kernel/processor.c  |   1 -
 3 files changed, 76 insertions(+), 311 deletions(-)

diff --git a/arch/s390/include/asm/processor.h 
b/arch/s390/include/asm/processor.h
index 0a876bc..84addf4 100644
--- a/arch/s390/include/asm/processor.h
+++ b/arch/s390/include/asm/processor.h
@@ -153,12 +153,6 @@ struct task_struct;
 struct mm_struct;
 struct seq_file;
 
-#ifdef CONFIG_64BIT
-extern void show_cacheinfo(struct seq_file *m);
-#else
-static inline void show_cacheinfo(struct seq_file *m) { }
-#endif
-
 /* Free all resources held by a thread. */
 extern void release_thread(struct task_struct *);
 
diff --git a/arch/s390/kernel/cache.c b/arch/s390/kernel/cache.c
index 3a414c0..e55dcd4 100644
--- a/arch/s390/kernel/cache.c
+++ b/arch/s390/kernel/cache.c
@@ -5,37 +5,11 @@
  *Author(s): Heiko Carstens heiko.carst...@de.ibm.com
  */
 
-#include linux/notifier.h
 #include linux/seq_file.h
-#include linux/init.h
-#include linux/list.h
-#include linux/slab.h
 #include linux/cpu.h
+#include linux/cacheinfo.h
 #include asm/facility.h
 
-struct cache {
-   unsigned long size;
-   unsigned int line_size;
-   unsigned int associativity;
-   unsigned int nr_sets;
-   unsigned int level   : 3;
-   unsigned int type: 2;
-   unsigned int private : 1;
-   struct list_head list;
-};
-
-struct cache_dir {
-   struct kobject *kobj;
-   struct cache_index_dir *index;
-};
-
-struct cache_index_dir {
-   struct kobject kobj;
-   int cpu;
-   struct cache *cache;
-   struct cache_index_dir *next;
-};
-
 enum {
CACHE_SCOPE_NOTEXISTS,
CACHE_SCOPE_PRIVATE,
@@ -44,10 +18,10 @@ enum {
 };
 
 enum {
-   CACHE_TYPE_SEPARATE,
-   CACHE_TYPE_DATA,
-   CACHE_TYPE_INSTRUCTION,
-   CACHE_TYPE_UNIFIED,
+   CTYPE_SEPARATE,
+   CTYPE_DATA,
+   CTYPE_INSTRUCTION,
+   CTYPE_UNIFIED,
 };
 
 enum {
@@ -63,44 +37,36 @@ enum {
CACHE_TI_INSTRUCTION,
 };
 
-struct cache_info {
+struct _cacheinfo {
unsigned char   : 4;
unsigned char scope : 2;
unsigned char type  : 2;
 };
 
 #define CACHE_MAX_LEVEL 8
-
 union cache_topology {
-   struct cache_info ci[CACHE_MAX_LEVEL];
+   struct _cacheinfo ci[CACHE_MAX_LEVEL];
unsigned long long raw;
 };
 
-static const char * const cache_type_string[] = {
-   Data,
-   Instruction,
-   Unified,
+static const enum cache_type cache_type_map[] = {
+   [CTYPE_SEPARATE] = CACHE_TYPE_SEPARATE,
+   [CTYPE_DATA] = CACHE_TYPE_DATA,
+   [CTYPE_INSTRUCTION] = CACHE_TYPE_INST,
+   [CTYPE_UNIFIED] = CACHE_TYPE_UNIFIED,
 };
 
-static struct cache_dir *cache_dir_cpu[NR_CPUS];
-static LIST_HEAD(cache_list);
-
-void show_cacheinfo(struct seq_file *m)
+static inline enum cache_type get_cache_type(struct _cacheinfo *ci, int level)
 {
-   struct cache *cache;
-   int index = 0;
+   if (level = CACHE_MAX_LEVEL)
+   return CACHE_TYPE_NOCACHE;
 
-   list_for_each_entry(cache, cache_list, list) {
-   seq_printf(m, cache%-11d: , index);
-   seq_printf(m, level=%d , cache-level);
-   seq_printf(m, type=%s , cache_type_string[cache-type]);
-   seq_printf(m, scope=%s , cache-private ? Private : 
Shared);
-   seq_printf(m, size=%luK , cache-size  10);
-   seq_printf(m, line_size=%u , cache-line_size);
-   seq_printf(m, associativity=%d, cache-associativity);
-   seq_puts(m, \n);
-   index++;
-   }
+   ci += level;
+
+   if (ci-scope != CACHE_SCOPE_SHARED  ci-scope != CACHE_SCOPE_PRIVATE)
+   return CACHE_TYPE_NOCACHE;
+
+   return cache_type_map[ci-type];
 }
 
 static inline unsigned long ecag(int ai, int li, int ti)
@@ -113,274 +79,80 @@ static inline unsigned long ecag(int ai, int li, int ti)
return val;
 }
 
-static int __init cache_add(int level, int private, int type)
+static void ci_leaf_init(struct cache_info *this_leaf, int private,
+enum cache_type type, unsigned int level)
 {
-   struct cache *cache;
-   int ti;
+   int ti, num_sets;
+   int cpu = smp_processor_id();
 
-   cache = kzalloc(sizeof(*cache), GFP_KERNEL);
-   if (!cache)
-   return -ENOMEM;
-   if (type == CACHE_TYPE_INSTRUCTION)
+   if (type == CACHE_TYPE_INST)
ti = CACHE_TI_INSTRUCTION;
else
ti = CACHE_TI_UNIFIED;
-