Skip to content

Commit 9171c67

Browse files
committed
Merge branches 'irq-urgent-for-linus' and 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull irq and smpboot updates from Thomas Gleixner: "Just cleanup patches with no functional change and a fix for suspend issues." * 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: genirq: Introduce irq_do_set_affinity() to reduce duplicated code genirq: Add IRQS_PENDING for nested and simple irq * 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: smpboot, idle: Fix comment mismatch over idle_threads_init() smpboot, idle: Optimize calls to smp_processor_id() in idle_threads_init()
3 parents c22072b + 818b0f3 + 4a70d2d commit 9171c67

File tree

5 files changed

+44
-36
lines changed

5 files changed

+44
-36
lines changed

kernel/irq/chip.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,10 @@ void handle_nested_irq(unsigned int irq)
275275
kstat_incr_irqs_this_cpu(irq, desc);
276276

277277
action = desc->action;
278-
if (unlikely(!action || irqd_irq_disabled(&desc->irq_data)))
278+
if (unlikely(!action || irqd_irq_disabled(&desc->irq_data))) {
279+
desc->istate |= IRQS_PENDING;
279280
goto out_unlock;
281+
}
280282

281283
irqd_set(&desc->irq_data, IRQD_IRQ_INPROGRESS);
282284
raw_spin_unlock_irq(&desc->lock);
@@ -324,8 +326,10 @@ handle_simple_irq(unsigned int irq, struct irq_desc *desc)
324326
desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING);
325327
kstat_incr_irqs_this_cpu(irq, desc);
326328

327-
if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data)))
329+
if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) {
330+
desc->istate |= IRQS_PENDING;
328331
goto out_unlock;
332+
}
329333

330334
handle_irq_event(desc);
331335

kernel/irq/internals.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ extern int irq_select_affinity_usr(unsigned int irq, struct cpumask *mask);
101101

102102
extern void irq_set_thread_affinity(struct irq_desc *desc);
103103

104+
extern int irq_do_set_affinity(struct irq_data *data,
105+
const struct cpumask *dest, bool force);
106+
104107
/* Inline functions for support of irq chips on slow busses */
105108
static inline void chip_bus_lock(struct irq_desc *desc)
106109
{

kernel/irq/manage.c

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,25 @@ static inline void
142142
irq_get_pending(struct cpumask *mask, struct irq_desc *desc) { }
143143
#endif
144144

145+
int irq_do_set_affinity(struct irq_data *data, const struct cpumask *mask,
146+
bool force)
147+
{
148+
struct irq_desc *desc = irq_data_to_desc(data);
149+
struct irq_chip *chip = irq_data_get_irq_chip(data);
150+
int ret;
151+
152+
ret = chip->irq_set_affinity(data, mask, false);
153+
switch (ret) {
154+
case IRQ_SET_MASK_OK:
155+
cpumask_copy(data->affinity, mask);
156+
case IRQ_SET_MASK_OK_NOCOPY:
157+
irq_set_thread_affinity(desc);
158+
ret = 0;
159+
}
160+
161+
return ret;
162+
}
163+
145164
int __irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask)
146165
{
147166
struct irq_chip *chip = irq_data_get_irq_chip(data);
@@ -152,14 +171,7 @@ int __irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask)
152171
return -EINVAL;
153172

154173
if (irq_can_move_pcntxt(data)) {
155-
ret = chip->irq_set_affinity(data, mask, false);
156-
switch (ret) {
157-
case IRQ_SET_MASK_OK:
158-
cpumask_copy(data->affinity, mask);
159-
case IRQ_SET_MASK_OK_NOCOPY:
160-
irq_set_thread_affinity(desc);
161-
ret = 0;
162-
}
174+
ret = irq_do_set_affinity(data, mask, false);
163175
} else {
164176
irqd_set_move_pending(data);
165177
irq_copy_pending(desc, mask);
@@ -283,9 +295,8 @@ EXPORT_SYMBOL_GPL(irq_set_affinity_notifier);
283295
static int
284296
setup_affinity(unsigned int irq, struct irq_desc *desc, struct cpumask *mask)
285297
{
286-
struct irq_chip *chip = irq_desc_get_chip(desc);
287298
struct cpumask *set = irq_default_affinity;
288-
int ret, node = desc->irq_data.node;
299+
int node = desc->irq_data.node;
289300

290301
/* Excludes PER_CPU and NO_BALANCE interrupts */
291302
if (!irq_can_set_affinity(irq))
@@ -311,13 +322,7 @@ setup_affinity(unsigned int irq, struct irq_desc *desc, struct cpumask *mask)
311322
if (cpumask_intersects(mask, nodemask))
312323
cpumask_and(mask, mask, nodemask);
313324
}
314-
ret = chip->irq_set_affinity(&desc->irq_data, mask, false);
315-
switch (ret) {
316-
case IRQ_SET_MASK_OK:
317-
cpumask_copy(desc->irq_data.affinity, mask);
318-
case IRQ_SET_MASK_OK_NOCOPY:
319-
irq_set_thread_affinity(desc);
320-
}
325+
irq_do_set_affinity(&desc->irq_data, mask, false);
321326
return 0;
322327
}
323328
#else

kernel/irq/migration.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,8 @@ void irq_move_masked_irq(struct irq_data *idata)
4242
* For correct operation this depends on the caller
4343
* masking the irqs.
4444
*/
45-
if (likely(cpumask_any_and(desc->pending_mask, cpu_online_mask)
46-
< nr_cpu_ids)) {
47-
int ret = chip->irq_set_affinity(&desc->irq_data,
48-
desc->pending_mask, false);
49-
switch (ret) {
50-
case IRQ_SET_MASK_OK:
51-
cpumask_copy(desc->irq_data.affinity, desc->pending_mask);
52-
case IRQ_SET_MASK_OK_NOCOPY:
53-
irq_set_thread_affinity(desc);
54-
}
55-
}
45+
if (cpumask_any_and(desc->pending_mask, cpu_online_mask) < nr_cpu_ids)
46+
irq_do_set_affinity(&desc->irq_data, desc->pending_mask, false);
5647

5748
cpumask_clear(desc->pending_mask);
5849
}

kernel/smpboot.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ void __init idle_thread_set_boot_cpu(void)
3131
per_cpu(idle_threads, smp_processor_id()) = current;
3232
}
3333

34+
/**
35+
* idle_init - Initialize the idle thread for a cpu
36+
* @cpu: The cpu for which the idle thread should be initialized
37+
*
38+
* Creates the thread if it does not exist.
39+
*/
3440
static inline void idle_init(unsigned int cpu)
3541
{
3642
struct task_struct *tsk = per_cpu(idle_threads, cpu);
@@ -45,17 +51,16 @@ static inline void idle_init(unsigned int cpu)
4551
}
4652

4753
/**
48-
* idle_thread_init - Initialize the idle thread for a cpu
49-
* @cpu: The cpu for which the idle thread should be initialized
50-
*
51-
* Creates the thread if it does not exist.
54+
* idle_threads_init - Initialize idle threads for all cpus
5255
*/
5356
void __init idle_threads_init(void)
5457
{
55-
unsigned int cpu;
58+
unsigned int cpu, boot_cpu;
59+
60+
boot_cpu = smp_processor_id();
5661

5762
for_each_possible_cpu(cpu) {
58-
if (cpu != smp_processor_id())
63+
if (cpu != boot_cpu)
5964
idle_init(cpu);
6065
}
6166
}

0 commit comments

Comments
 (0)