Commit fb0f330e62d71f7c535251438068199af320cf73
Committed by
Ingo Molnar
1 parent
9f0e8d0400
Exists in
master
and in
7 other branches
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>
Showing 1 changed file with 23 additions and 7 deletions Side-by-side Diff
arch/x86/kernel/cpu/intel_cacheinfo.c
... | ... | @@ -591,20 +591,34 @@ |
591 | 591 | return sprintf (buf, "%luK\n", this_leaf->size / 1024); |
592 | 592 | } |
593 | 593 | |
594 | -static ssize_t show_shared_cpu_map(struct _cpuid4_info *this_leaf, char *buf) | |
594 | +static 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 | 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) { | |
601 | - cpumask_scnprintf(mask_str, len, this_leaf->shared_cpu_map); | |
602 | - n = sprintf(buf, "%s\n", mask_str); | |
603 | - kfree(mask_str); | |
600 | + if (len > 1) { | |
601 | + cpumask_t *mask = &this_leaf->shared_cpu_map; | |
602 | + | |
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 | 609 | return n; |
606 | 610 | } |
607 | 611 | |
612 | +static 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 | + | |
617 | +static 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 | + | |
608 | 622 | static ssize_t show_type(struct _cpuid4_info *this_leaf, char *buf) { |
609 | 623 | switch(this_leaf->eax.split.type) { |
610 | 624 | case CACHE_TYPE_DATA: |
... | ... | @@ -640,6 +654,7 @@ |
640 | 654 | define_one_ro(number_of_sets); |
641 | 655 | define_one_ro(size); |
642 | 656 | define_one_ro(shared_cpu_map); |
657 | +define_one_ro(shared_cpu_list); | |
643 | 658 | |
644 | 659 | static struct attribute * default_attrs[] = { |
645 | 660 | &type.attr, |
... | ... | @@ -650,6 +665,7 @@ |
650 | 665 | &number_of_sets.attr, |
651 | 666 | &size.attr, |
652 | 667 | &shared_cpu_map.attr, |
668 | + &shared_cpu_list.attr, | |
653 | 669 | NULL |
654 | 670 | }; |
655 | 671 |