Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cpu_rmap.h
Go to the documentation of this file.
1 #ifndef __LINUX_CPU_RMAP_H
2 #define __LINUX_CPU_RMAP_H
3 
4 /*
5  * cpu_rmap.c: CPU affinity reverse-map support
6  * Copyright 2011 Solarflare Communications Inc.
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License version 2 as published
10  * by the Free Software Foundation, incorporated herein by reference.
11  */
12 
13 #include <linux/cpumask.h>
14 #include <linux/gfp.h>
15 #include <linux/slab.h>
16 
25 struct cpu_rmap {
27  void **obj;
28  struct {
31  } near[0];
32 };
33 #define CPU_RMAP_DIST_INF 0xffff
34 
35 extern struct cpu_rmap *alloc_cpu_rmap(unsigned int size, gfp_t flags);
36 
41 static inline void free_cpu_rmap(struct cpu_rmap *rmap)
42 {
43  kfree(rmap);
44 }
45 
46 extern int cpu_rmap_add(struct cpu_rmap *rmap, void *obj);
47 extern int cpu_rmap_update(struct cpu_rmap *rmap, u16 index,
48  const struct cpumask *affinity);
49 
50 static inline u16 cpu_rmap_lookup_index(struct cpu_rmap *rmap, unsigned int cpu)
51 {
52  return rmap->near[cpu].index;
53 }
54 
55 static inline void *cpu_rmap_lookup_obj(struct cpu_rmap *rmap, unsigned int cpu)
56 {
57  return rmap->obj[rmap->near[cpu].index];
58 }
59 
60 #ifdef CONFIG_GENERIC_HARDIRQS
61 
68 static inline struct cpu_rmap *alloc_irq_cpu_rmap(unsigned int size)
69 {
70  return alloc_cpu_rmap(size, GFP_KERNEL);
71 }
72 extern void free_irq_cpu_rmap(struct cpu_rmap *rmap);
73 
74 extern int irq_cpu_rmap_add(struct cpu_rmap *rmap, int irq);
75 
76 #endif
77 #endif /* __LINUX_CPU_RMAP_H */