aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/irq.h
diff options
context:
space:
mode:
authorMike Travis <travis@sgi.com>2009-01-11 00:58:08 -0500
committerIngo Molnar <mingo@elte.hu>2009-01-11 13:12:46 -0500
commit7f7ace0cda64c99599c23785f8979a072e118058 (patch)
tree13f2826e64e09ebaef94a3e7fd9c21cfbd31ec3f /include/linux/irq.h
parentc59765042f53a79a7a65585042ff463b69cb248c (diff)
cpumask: update irq_desc to use cpumask_var_t
Impact: reduce memory usage, use new cpumask API. Replace the affinity and pending_masks with cpumask_var_t's. This adds to the significant size reduction done with the SPARSE_IRQS changes. The added functions (init_alloc_desc_masks & init_copy_desc_masks) are in the include file so they can be inlined (and optimized out for the !CONFIG_CPUMASKS_OFFSTACK case.) [Naming chosen to be consistent with the other init*irq functions, as well as the backwards arg declaration of "from, to" instead of the more common "to, from" standard.] Includes a slight change to the declaration of struct irq_desc to embed the pending_mask within ifdef(CONFIG_SMP) to be consistent with other references, and some small changes to Xen. Tested: sparse/non-sparse/cpumask_offstack/non-cpumask_offstack/nonuma/nosmp on x86_64 Signed-off-by: Mike Travis <travis@sgi.com> Cc: Chris Wright <chrisw@sous-sol.org> Cc: Jeremy Fitzhardinge <jeremy@xensource.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> Cc: virtualization@lists.osdl.org Cc: xen-devel@lists.xensource.com Cc: Yinghai Lu <yhlu.kernel@gmail.com>
Diffstat (limited to 'include/linux/irq.h')
-rw-r--r--include/linux/irq.h81
1 files changed, 78 insertions, 3 deletions
diff --git a/include/linux/irq.h b/include/linux/irq.h
index f899b502f186..fa27210f1dfd 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -182,11 +182,11 @@ struct irq_desc {
182 unsigned int irqs_unhandled; 182 unsigned int irqs_unhandled;
183 spinlock_t lock; 183 spinlock_t lock;
184#ifdef CONFIG_SMP 184#ifdef CONFIG_SMP
185 cpumask_t affinity; 185 cpumask_var_t affinity;
186 unsigned int cpu; 186 unsigned int cpu;
187#endif
188#ifdef CONFIG_GENERIC_PENDING_IRQ 187#ifdef CONFIG_GENERIC_PENDING_IRQ
189 cpumask_t pending_mask; 188 cpumask_var_t pending_mask;
189#endif
190#endif 190#endif
191#ifdef CONFIG_PROC_FS 191#ifdef CONFIG_PROC_FS
192 struct proc_dir_entry *dir; 192 struct proc_dir_entry *dir;
@@ -422,4 +422,79 @@ extern int set_irq_msi(unsigned int irq, struct msi_desc *entry);
422 422
423#endif /* !CONFIG_S390 */ 423#endif /* !CONFIG_S390 */
424 424
425#ifdef CONFIG_SMP
426/**
427 * init_alloc_desc_masks - allocate cpumasks for irq_desc
428 * @desc: pointer to irq_desc struct
429 * @boot: true if need bootmem
430 *
431 * Allocates affinity and pending_mask cpumask if required.
432 * Returns true if successful (or not required).
433 * Side effect: affinity has all bits set, pending_mask has all bits clear.
434 */
435static inline bool init_alloc_desc_masks(struct irq_desc *desc, int node,
436 bool boot)
437{
438 if (boot) {
439 alloc_bootmem_cpumask_var(&desc->affinity);
440 cpumask_setall(desc->affinity);
441
442#ifdef CONFIG_GENERIC_PENDING_IRQ
443 alloc_bootmem_cpumask_var(&desc->pending_mask);
444 cpumask_clear(desc->pending_mask);
445#endif
446 return true;
447 }
448
449 if (!alloc_cpumask_var_node(&desc->affinity, GFP_ATOMIC, node))
450 return false;
451 cpumask_setall(desc->affinity);
452
453#ifdef CONFIG_GENERIC_PENDING_IRQ
454 if (!alloc_cpumask_var_node(&desc->pending_mask, GFP_ATOMIC, node)) {
455 free_cpumask_var(desc->affinity);
456 return false;
457 }
458 cpumask_clear(desc->pending_mask);
459#endif
460 return true;
461}
462
463/**
464 * init_copy_desc_masks - copy cpumasks for irq_desc
465 * @old_desc: pointer to old irq_desc struct
466 * @new_desc: pointer to new irq_desc struct
467 *
468 * Insures affinity and pending_masks are copied to new irq_desc.
469 * If !CONFIG_CPUMASKS_OFFSTACK the cpumasks are embedded in the
470 * irq_desc struct so the copy is redundant.
471 */
472
473static inline void init_copy_desc_masks(struct irq_desc *old_desc,
474 struct irq_desc *new_desc)
475{
476#ifdef CONFIG_CPUMASKS_OFFSTACK
477 cpumask_copy(new_desc->affinity, old_desc->affinity);
478
479#ifdef CONFIG_GENERIC_PENDING_IRQ
480 cpumask_copy(new_desc->pending_mask, old_desc->pending_mask);
481#endif
482#endif
483}
484
485#else /* !CONFIG_SMP */
486
487static inline bool init_alloc_desc_masks(struct irq_desc *desc, int node,
488 bool boot)
489{
490 return true;
491}
492
493static inline void init_copy_desc_masks(struct irq_desc *old_desc,
494 struct irq_desc *new_desc)
495{
496}
497
498#endif /* CONFIG_SMP */
499
425#endif /* _LINUX_IRQ_H */ 500#endif /* _LINUX_IRQ_H */