Re: [Lse-tech] cpu-2.5.69-bk14-1

Christoph Hellwig (hch@infradead.org)
Wed, 21 May 2003 09:43:17 +0100


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)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/