Used cpulist_scnprintf to print cpus on a leaf instead of requiring
a new "cpumask_scnprintf_len" function to determine the size of
the temporary buffer. cpulist_scnprintf can be used to print directly
to the output buffer, eliminating the need for the temporary buffer.
Based on:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86.git
Signed-off-by: Mike Travis <travis@sgi.com>
---
arch/x86/kernel/cpu/intel_cacheinfo.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
--- linux.trees.git.orig/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ linux.trees.git/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -593,14 +593,23 @@ static ssize_t show_size(struct _cpuid4_
static ssize_t show_shared_cpu_map(struct _cpuid4_info *this_leaf, char *buf)
{
- int n = 0;
- int len = cpumask_scnprintf_len(nr_cpu_ids);
- char *mask_str = kmalloc(len, GFP_KERNEL);
-
- if (mask_str) {
- cpumask_scnprintf(mask_str, len, this_leaf->shared_cpu_map);
- n = sprintf(buf, "%s\n", mask_str);
- kfree(mask_str);
+ /*
+ * cpulist_scnprintf() has the advantage of compressing
+ * consecutive cpu numbers into a single range which seems
+ * appropriate for cpus on a leaf. This will change what is
+ * output so scripts that process the output will have to change.
+ * The good news is that the output format is compatible
+ * with cpulist_parse() [bitmap_parselist()].
+ *
+ * Have to guess at output buffer size... 128 seems reasonable
+ * to represent all cpus on a leaf in the worst case, like
+ * if all cpus are non-consecutive and large numbers.
+ */
+ int n = cpulist_scnprintf(buf, 128, this_leaf->shared_cpu_map);
+
+ if (n > 0) {
+ sprintf(buf+n, "\n");
+ n++;
}
return n;
}
--
--
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| Hiten Pandya | Re: up? (emacs docbook xml ide) |
| Jan Engelhardt | intel iommu (Re: -mm merge plans for 2.6.23) |
| Tarkan Erimer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
git: | |
| Jarek Poplawski | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| David Miller | [GIT]: Networking |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| Daniel Eischen | Re: error with thread |
