aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorMike Travis <travis@sgi.com>2008-04-08 14:43:02 -0400
committerIngo Molnar <mingo@elte.hu>2008-04-19 13:44:59 -0400
commitfb0f330e62d71f7c535251438068199af320cf73 (patch)
tree43ad6b5e6b1c95df32ddd1aa8827c20f97d4e7b1 /arch/x86/kernel
parent9f0e8d0400d925c3acd5f4e01dbeb736e4011882 (diff)
x86: modify show_shared_cpu_map in intel_cacheinfo
* Removed kmalloc (or local array) in show_shared_cpu_map(). * Added show_shared_cpu_list() function. Signed-off-by: Mike Travis <travis@sgi.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/cpu/intel_cacheinfo.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index e073a93ceb42..26d615dcb149 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -591,20 +591,34 @@ static ssize_t show_size(struct _cpuid4_info *this_leaf, char *buf)
591 return sprintf (buf, "%luK\n", this_leaf->size / 1024); 591 return sprintf (buf, "%luK\n", this_leaf->size / 1024);
592} 592}
593 593
594static ssize_t show_shared_cpu_map(struct _cpuid4_info *this_leaf, char *buf) 594static ssize_t show_shared_cpu_map_func(struct _cpuid4_info *this_leaf,
595 int type, char *buf)
595{ 596{
597 ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf;
596 int n = 0; 598 int n = 0;
597 int len = cpumask_scnprintf_len(nr_cpu_ids);
598 char *mask_str = kmalloc(len, GFP_KERNEL);
599 599
600 if (mask_str) { 600 if (len > 1) {
601 cpumask_scnprintf(mask_str, len, this_leaf->shared_cpu_map); 601 cpumask_t *mask = &this_leaf->shared_cpu_map;
602 n = sprintf(buf, "%s\n", mask_str); 602
603 kfree(mask_str); 603 n = type?
604 cpulist_scnprintf(buf, len-2, *mask):
605 cpumask_scnprintf(buf, len-2, *mask);
606 buf[n++] = '\n';
607 buf[n] = '\0';
604 } 608 }
605 return n; 609 return n;
606} 610}
607 611
612static inline ssize_t show_shared_cpu_map(struct _cpuid4_info *leaf, char *buf)
613{
614 return show_shared_cpu_map_func(leaf, 0, buf);
615}
616
617static inline ssize_t show_shared_cpu_list(struct _cpuid4_info *leaf, char *buf)
618{
619 return show_shared_cpu_map_func(leaf, 1, buf);
620}
621
608static ssize_t show_type(struct _cpuid4_info *this_leaf, char *buf) { 622static ssize_t show_type(struct _cpuid4_info *this_leaf, char *buf) {
609 switch(this_leaf->eax.split.type) { 623 switch(this_leaf->eax.split.type) {
610 case CACHE_TYPE_DATA: 624 case CACHE_TYPE_DATA:
@@ -640,6 +654,7 @@ define_one_ro(ways_of_associativity);
640define_one_ro(number_of_sets); 654define_one_ro(number_of_sets);
641define_one_ro(size); 655define_one_ro(size);
642define_one_ro(shared_cpu_map); 656define_one_ro(shared_cpu_map);
657define_one_ro(shared_cpu_list);
643 658
644static struct attribute * default_attrs[] = { 659static struct attribute * default_attrs[] = {
645 &type.attr, 660 &type.attr,
@@ -650,6 +665,7 @@ static struct attribute * default_attrs[] = {
650 &number_of_sets.attr, 665 &number_of_sets.attr,
651 &size.attr, 666 &size.attr,
652 &shared_cpu_map.attr, 667 &shared_cpu_map.attr,
668 &shared_cpu_list.attr,
653 NULL 669 NULL
654}; 670};
655 671