From: Christoph Hellwig <hch@infradead.org>
To: William Lee Irwin III <wli@holomorphy.com>,
linux-kernel@vger.kernel.org, lse-tech@lists.sourceforge.net,
kaos@ocs.com.au, James.Bottomley@steeleye.com,
mort@wildopensource.com, davidm@napali.hpl.hp.com,
jun.nakajima@intel.com, tomita@cinet.co.jp
Subject: Re: [Lse-tech] cpu-2.5.69-bk14-1
Date: Wed, 21 May 2003 09:43:17 +0100 [thread overview]
Message-ID: <20030521094317.A6612@infradead.org> (raw)
In-Reply-To: <20030520170331.GK29926@holomorphy.com>; from wli@holomorphy.com on Tue, May 20, 2003 at 10:03:31AM -0700
On Tue, May 20, 2003 at 10:03:31AM -0700, William Lee Irwin III wrote:
> Extended cpumasks for larger systems. Now featuring bigsmp, Summit,
> and Voyager updates in addition to PC-compatible, NUMA-Q, and SN2
> bits from SGI.
Here's the PPC32 UP bits. I'll look into SMP once it starts to actually
compile again.
--- 1.26/arch/ppc/kernel/irq.c Sun Apr 27 13:56:50 2003
+++ edited/arch/ppc/kernel/irq.c Tue May 20 11:43:43 2003
@@ -44,6 +44,7 @@
#include <linux/proc_fs.h>
#include <linux/random.h>
#include <linux/seq_file.h>
+#include <linux/cpumask.h>
#include <asm/uaccess.h>
#include <asm/bitops.h>
@@ -567,24 +568,35 @@
#define DEFAULT_CPU_AFFINITY 0x00000001
#endif
-unsigned int irq_affinity [NR_IRQS] =
- { [0 ... NR_IRQS-1] = DEFAULT_CPU_AFFINITY };
+#define HEX_DIGITS (2*sizeof(cpumask_t))
-#define HEX_DIGITS 8
+cpumask_t irq_affinity[NR_IRQS] = { [0 ... NR_IRQS-1] = CPU_MASK_ALL };
-static int irq_affinity_read_proc (char *page, char **start, off_t off,
+static int irq_affinity_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
+ cpumask_t tmp = irq_affinity[(long)data];
+ int k, len = 0;
+
if (count < HEX_DIGITS+1)
return -EINVAL;
- return sprintf (page, "%08x\n", irq_affinity[(int)data]);
+
+ for (k = 0; k < sizeof(cpumask_t)/sizeof(unsigned long); ++k) {
+ int j = sprintf(page, "%04hx", (u16)cpus_coerce(tmp));
+ len += j;
+ page += j;
+ cpus_shift_right(tmp, tmp, 16);
+ }
+
+ len += sprintf(page, "\n");
+ return len;
}
-static unsigned int parse_hex_value (const char *buffer,
+static unsigned int parse_hex_value(const char *buffer,
unsigned long count, unsigned long *ret)
{
- unsigned char hexnum [HEX_DIGITS];
- unsigned long value;
+ unsigned char hexnum[HEX_DIGITS];
+ cpumask_t value = CPU_MASK_NONE;
int i;
if (!count)
@@ -598,10 +610,9 @@
* Parse the first 8 characters as a hex string, any non-hex char
* is end-of-string. '00e1', 'e1', '00E1', 'E1' are all the same.
*/
- value = 0;
-
for (i = 0; i < count; i++) {
unsigned int c = hexnum[i];
+ int k;
switch (c) {
case '0' ... '9': c -= '0'; break;
@@ -610,18 +621,21 @@
default:
goto out;
}
- value = (value << 4) | c;
+ cpus_shift_left(value, value, 4);
+ for (k = 0; k < 4; ++k)
+ if (test_bit(k, (unsigned long *)&c))
+ cpu_set(k, value);
}
out:
*ret = value;
return 0;
}
-static int irq_affinity_write_proc (struct file *file, const char *buffer,
+static int irq_affinity_write_proc(struct file *file, const char *buffer,
unsigned long count, void *data)
{
- int irq = (int) data, full_count = count, err;
- unsigned long new_value;
+ int irq = (long)data, full_count = count, err;
+ cpumask_t new_value, tmp;
if (!irq_desc[irq].handler->set_affinity)
return -EIO;
@@ -638,29 +652,42 @@
* are actually logical cpu #'s then we have no problem.
* -- Cort <cort@fsmlabs.com>
*/
- if (!(new_value & cpu_online_map))
+ cpus_and(tmp, new_value, cpu_online_map);
+ if (cpus_empty(tmp))
return -EINVAL;
irq_affinity[irq] = new_value;
- irq_desc[irq].handler->set_affinity(irq, new_value);
-
+ irq_desc[irq].handler->set_affinity(irq,
+ cpumask_of_cpu(first_cpu(new_value)));
return full_count;
}
-static int prof_cpu_mask_read_proc (char *page, char **start, off_t off,
+static int prof_cpu_mask_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
- unsigned long *mask = (unsigned long *) data;
+ cpumask_t *tmp = (cpumask_t *)data;
+ int k, len = 0;
+
if (count < HEX_DIGITS+1)
return -EINVAL;
- return sprintf (page, "%08lx\n", *mask);
+
+ for (k = 0; k < sizeof(cpumask_t)/sizeof(unsigned long); ++k) {
+ int j = sprintf(page, "%04hx", (u16)cpus_coerce(*tmp));
+ len += j;
+ page += j;
+ cpus_shift_right(*tmp, *tmp, 16);
+ }
+
+ len += sprintf(page, "\n");
+ return len;
}
static int prof_cpu_mask_write_proc (struct file *file, const char *buffer,
unsigned long count, void *data)
{
- unsigned long *mask = (unsigned long *) data, full_count = count, err;
- unsigned long new_value;
+ cpumask_t *mask = (cpumask_t *)data;
+ unsigned long full_count = count, err;
+ cpumask_t new_value;
err = parse_hex_value(buffer, count, &new_value);
if (err)
next prev parent reply other threads:[~2003-05-21 8:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-20 17:03 cpu-2.5.69-bk14-1 William Lee Irwin III
2003-05-21 8:43 ` Christoph Hellwig [this message]
2003-05-21 15:23 ` [Lse-tech] cpu-2.5.69-bk14-1 William Lee Irwin III
2003-05-21 15:05 ` Martin J. Bligh
2003-05-24 21:54 ` cpu-2.5.69-bk14-1 Zwane Mwaikambo
2003-05-25 4:23 ` cpu-2.5.69-bk14-1 William Lee Irwin III
2003-05-25 4:39 ` cpu-2.5.69-bk14-1 Zwane Mwaikambo
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=20030521094317.A6612@infradead.org \
--to=hch@infradead.org \
--cc=James.Bottomley@steeleye.com \
--cc=davidm@napali.hpl.hp.com \
--cc=jun.nakajima@intel.com \
--cc=kaos@ocs.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=lse-tech@lists.sourceforge.net \
--cc=mort@wildopensource.com \
--cc=tomita@cinet.co.jp \
--cc=wli@holomorphy.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox