All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Travis <travis@sgi.com>
To: Bert Wesarg <bert.wesarg@googlemail.com>
Cc: Ingo Molnar <mingo@elte.hu>, Paul Jackson <pj@sgi.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] x86: modify show_shared_cpu_map in intel_cacheinfo v3
Date: Tue, 08 Apr 2008 13:44:05 -0700	[thread overview]
Message-ID: <47FBD915.7020809@sgi.com> (raw)
In-Reply-To: <36ca99e90804081236ifa3eecfue3dd211f9cdcb32a@mail.gmail.com>

Bert Wesarg wrote:
> On Tue, Apr 8, 2008 at 8:43 PM, Mike Travis <travis@sgi.com> wrote:
>>  --- linux-2.6.x86.sched.orig/arch/x86/kernel/cpu/intel_cacheinfo.c
>>  +++ linux-2.6.x86.sched/arch/x86/kernel/cpu/intel_cacheinfo.c
>>  @@ -591,20 +591,34 @@ static ssize_t show_size(struct _cpuid4_
>>         return sprintf (buf, "%luK\n", this_leaf->size / 1024);
>>   }
>>
>>  -static ssize_t show_shared_cpu_map(struct _cpuid4_info *this_leaf, char *buf)
>>  +static ssize_t show_shared_cpu_map_func(struct _cpuid4_info *this_leaf,
>>  +                                       int type, char *buf)
> I don't know if this is more efficient or better or cleaner, but how
> about to pass the function pointer (ie. cpulist_scnprintf or
> cpumap_scnprintf)? You safe at least one condition.
> 
>>  +               n = type?
>>  +                       cpulist_scnprintf(buf, len-2, *mask):
>>  +                       cpumask_scnprintf(buf, len-2, *mask);
> 
> Thanks.
> Bert

I have to subvert the cpumask interface a bit, but the resultant
code size is about 7 instructions smaller.

static ssize_t show_shared_cpu_map_func(struct _cpuid4_info *this_leaf,
		int (*cpumap_func)(char *, int, const cpumask_t *, int),
		char *buf)
{
	ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf;
	int n = 0;

	if (len > 1) {
		cpumask_t *mask = &this_leaf->shared_cpu_map;
		n = cpumap_func(buf, len-2, mask, NR_CPUS);
		buf[n++] = '\n';
		buf[n] = '\0';
	}
	return n;
}

static inline ssize_t show_shared_cpu_map(struct _cpuid4_info *leaf, char *buf)
{
	return show_shared_cpu_map_func(leaf, &__cpumask_scnprintf, buf);
}

static inline ssize_t show_shared_cpu_list(struct _cpuid4_info *leaf, char *buf)
{
	return show_shared_cpu_map_func(leaf, &__cpulist_scnprintf, buf);
}

Btw, you were asking about how to determine NR_CPUS.  Here's one way:

root@newton:~# cat /sys/devices/system/cpu/online
0-2,4-7
root@newton:~# cat /sys/devices/system/cpu/possible
0-511
root@newton:~# cat /sys/devices/system/cpu/present
0-7
root@newton:~# cat /sys/devices/system/cpu/system
0-4095

Thanks,
Mike

  reply	other threads:[~2008-04-08 20:44 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-08 18:43 [PATCH 0/3] x86: add cpus_scnprintf function v3 Mike Travis
2008-04-08 18:43 ` [PATCH 1/3] x86: modify show_shared_cpu_map in intel_cacheinfo v3 Mike Travis
2008-04-08 19:36   ` Bert Wesarg
2008-04-08 20:44     ` Mike Travis [this message]
2008-04-10 14:03       ` Paul Jackson
2008-04-10 17:24       ` Bert Wesarg
2008-04-10 17:36         ` Paul Jackson
2008-04-10 13:57   ` Paul Jackson
2008-04-08 18:43 ` [PATCH 2/3] cpumask: use new cpus_scnprintf function v3 Mike Travis
2008-04-08 19:40   ` Bert Wesarg
2008-04-08 20:46     ` Mike Travis
2008-04-09 15:53       ` Bert Wesarg
2008-04-10 12:49         ` Paul Jackson
2008-04-10  0:32   ` Paul Jackson
2008-04-10 12:13   ` Paul Jackson
2008-04-10 14:05   ` Paul Jackson
2008-04-08 18:43 ` [PATCH 3/3] cpumask: add show cpu map functions v2 Mike Travis
2008-04-08 19:32   ` Bert Wesarg
2008-04-08 20:52     ` Mike Travis
2008-04-09 17:39       ` Bert Wesarg
2008-04-10  0:29         ` Paul Jackson
2008-04-10  6:05           ` Bert Wesarg
2008-04-10 14:13   ` Paul Jackson
2008-04-08 19:33 ` [PATCH 0/3] x86: add cpus_scnprintf function v3 Bert Wesarg
2008-04-08 20:54   ` Mike Travis
2008-04-10 15:03     ` Paul Jackson
2008-04-09 15:11 ` Ingo Molnar
2008-04-09 17:51 ` Bert Wesarg
2008-04-09 20:39   ` Greg KH
2008-04-09 20:52     ` Bert Wesarg
2008-04-09 21:14       ` Greg KH
2008-04-09 21:21         ` Bert Wesarg
2008-04-09 20:59     ` Mike Travis
2008-04-09 21:02       ` Bert Wesarg
2008-04-09 21:15       ` Greg KH
2008-04-10  0:18       ` Paul Jackson
2008-04-10 12:10   ` Paul Jackson
2008-04-10 16:14     ` Bert Wesarg
2008-04-10 16:27       ` Paul Jackson
2008-04-10 17:30       ` Greg KH
2008-04-10 17:36         ` Bert Wesarg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47FBD915.7020809@sgi.com \
    --to=travis@sgi.com \
    --cc=akpm@linux-foundation.org \
    --cc=bert.wesarg@googlemail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=pj@sgi.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.