Commit d036e67b authored by Rusty Russell's avatar Rusty Russell

cpumask: convert kernel/irq

Impact: Reduce stack usage, use new cpumask API.  ALPHA mod!

Main change is that irq_default_affinity becomes a cpumask_var_t, so
treat it as a pointer (this effects alpha).
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 6b954823
...@@ -50,7 +50,8 @@ int irq_select_affinity(unsigned int irq) ...@@ -50,7 +50,8 @@ int irq_select_affinity(unsigned int irq)
if (!irq_desc[irq].chip->set_affinity || irq_user_affinity[irq]) if (!irq_desc[irq].chip->set_affinity || irq_user_affinity[irq])
return 1; return 1;
while (!cpu_possible(cpu) || !cpu_isset(cpu, irq_default_affinity)) while (!cpu_possible(cpu) ||
!cpumask_test_cpu(cpu, irq_default_affinity))
cpu = (cpu < (NR_CPUS-1) ? cpu + 1 : 0); cpu = (cpu < (NR_CPUS-1) ? cpu + 1 : 0);
last_cpu = cpu; last_cpu = cpu;
......
...@@ -109,7 +109,7 @@ extern void enable_irq(unsigned int irq); ...@@ -109,7 +109,7 @@ extern void enable_irq(unsigned int irq);
#if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_HARDIRQS) #if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_HARDIRQS)
extern cpumask_t irq_default_affinity; extern cpumask_var_t irq_default_affinity;
extern int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask); extern int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask);
extern int irq_can_set_affinity(unsigned int irq); extern int irq_can_set_affinity(unsigned int irq);
......
...@@ -16,8 +16,15 @@ ...@@ -16,8 +16,15 @@
#include "internals.h" #include "internals.h"
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
cpumask_var_t irq_default_affinity;
cpumask_t irq_default_affinity = CPU_MASK_ALL; static int init_irq_default_affinity(void)
{
alloc_cpumask_var(&irq_default_affinity, GFP_KERNEL);
cpumask_setall(irq_default_affinity);
return 0;
}
core_initcall(init_irq_default_affinity);
/** /**
* synchronize_irq - wait for pending IRQ handlers (on other CPUs) * synchronize_irq - wait for pending IRQ handlers (on other CPUs)
...@@ -127,7 +134,7 @@ int do_irq_select_affinity(unsigned int irq, struct irq_desc *desc) ...@@ -127,7 +134,7 @@ int do_irq_select_affinity(unsigned int irq, struct irq_desc *desc)
desc->status &= ~IRQ_AFFINITY_SET; desc->status &= ~IRQ_AFFINITY_SET;
} }
cpumask_and(&desc->affinity, cpu_online_mask, &irq_default_affinity); cpumask_and(&desc->affinity, cpu_online_mask, irq_default_affinity);
set_affinity: set_affinity:
desc->chip->set_affinity(irq, &desc->affinity); desc->chip->set_affinity(irq, &desc->affinity);
......
...@@ -20,7 +20,7 @@ static struct proc_dir_entry *root_irq_dir; ...@@ -20,7 +20,7 @@ static struct proc_dir_entry *root_irq_dir;
static int irq_affinity_proc_show(struct seq_file *m, void *v) static int irq_affinity_proc_show(struct seq_file *m, void *v)
{ {
struct irq_desc *desc = irq_to_desc((long)m->private); struct irq_desc *desc = irq_to_desc((long)m->private);
cpumask_t *mask = &desc->affinity; const struct cpumask *mask = &desc->affinity;
#ifdef CONFIG_GENERIC_PENDING_IRQ #ifdef CONFIG_GENERIC_PENDING_IRQ
if (desc->status & IRQ_MOVE_PENDING) if (desc->status & IRQ_MOVE_PENDING)
...@@ -93,7 +93,7 @@ static const struct file_operations irq_affinity_proc_fops = { ...@@ -93,7 +93,7 @@ static const struct file_operations irq_affinity_proc_fops = {
static int default_affinity_show(struct seq_file *m, void *v) static int default_affinity_show(struct seq_file *m, void *v)
{ {
seq_cpumask(m, &irq_default_affinity); seq_cpumask(m, irq_default_affinity);
seq_putc(m, '\n'); seq_putc(m, '\n');
return 0; return 0;
} }
...@@ -101,27 +101,37 @@ static int default_affinity_show(struct seq_file *m, void *v) ...@@ -101,27 +101,37 @@ static int default_affinity_show(struct seq_file *m, void *v)
static ssize_t default_affinity_write(struct file *file, static ssize_t default_affinity_write(struct file *file,
const char __user *buffer, size_t count, loff_t *ppos) const char __user *buffer, size_t count, loff_t *ppos)
{ {
cpumask_t new_value; cpumask_var_t new_value;
int err; int err;
err = cpumask_parse_user(buffer, count, &new_value); if (!alloc_cpumask_var(&new_value, GFP_KERNEL))
return -ENOMEM;
err = cpumask_parse_user(buffer, count, new_value);
if (err) if (err)
return err; goto out;
if (!is_affinity_mask_valid(new_value)) if (!is_affinity_mask_valid(new_value)) {
return -EINVAL; err = -EINVAL;
goto out;
}
/* /*
* Do not allow disabling IRQs completely - it's a too easy * Do not allow disabling IRQs completely - it's a too easy
* way to make the system unusable accidentally :-) At least * way to make the system unusable accidentally :-) At least
* one online CPU still has to be targeted. * one online CPU still has to be targeted.
*/ */
if (!cpus_intersects(new_value, cpu_online_map)) if (!cpumask_intersects(new_value, cpu_online_mask)) {
return -EINVAL; err = -EINVAL;
goto out;
}
irq_default_affinity = new_value; cpumask_copy(irq_default_affinity, new_value);
err = count;
return count; out:
free_cpumask_var(new_value);
return err;
} }
static int default_affinity_open(struct inode *inode, struct file *file) static int default_affinity_open(struct inode *inode, struct file *file)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment