History

mm/vmacache, sched/headers: Introduce 'struct vmacache' and move it from <linux/sched.h> to <linux/mm_types>

The <linux/sched.h> header includes various vmacache related defines, which are arguably misplaced. Move them to mm_types.h and minimize the sched.h impact by putting all task vmacache state into a new 'struct vmacache' structure. No change in functionality.

Ingo Molnar committed 9 years ago

Commit 314ff781 parent 780de9d6 files · +25 −16Browse files

Unified · Split

6 files
  1. include/linux/mm_types.h +12 −0
  2. include/linux/sched.h +4 −7
  3. include/linux/vmacache.h +1 −1
  4. kernel/debug/debug_core.c +2 −2
  5. mm/nommu.c +1 −1
  6. mm/vmacache.c +5 −5
include/linux/mm_types.h+12−0
@@ -360,6 +360,18 @@ struct vm_area_struct { · 359 unmodified lines
360 struct vm_userfaultfd_ctx vm_userfaultfd_ctx;360 struct vm_userfaultfd_ctx vm_userfaultfd_ctx;
361};361};
362 362
363/*
364 * The per task VMA cache array:
365 */
366#define VMACACHE_BITS 2
367#define VMACACHE_SIZE (1U << VMACACHE_BITS)
368#define VMACACHE_MASK (VMACACHE_SIZE - 1)
369
370struct vmacache {
371 u32 seqnum;
372 struct vm_area_struct *vmas[VMACACHE_SIZE];
373};
374
363struct core_thread {375struct core_thread {
364 struct task_struct *task;376 struct task_struct *task;
365 struct core_thread *next;377 struct core_thread *next;
include/linux/sched.h+4−7
@@ -134,10 +134,6 @@ struct blk_plug; · 133 unmodified lines
134struct filename;134struct filename;
135struct nameidata;135struct nameidata;
136 136
137#define VMACACHE_BITS 2
138#define VMACACHE_SIZE (1U << VMACACHE_BITS)
139#define VMACACHE_MASK (VMACACHE_SIZE - 1)
140
141/*137/*
142 * These are the constant used to fake the fixed-point load-average138 * These are the constant used to fake the fixed-point load-average
143 * counting. Some notes:139 * counting. Some notes:
@@ -1550,9 +1546,10 @@ struct task_struct { · 1406 unmodified lines
1550#endif1546#endif
1551 1547
1552 struct mm_struct *mm, *active_mm;1548 struct mm_struct *mm, *active_mm;
1553 /* per-thread vma caching */1549
1554 u32 vmacache_seqnum;1550 /* Per-thread vma caching: */
1555 struct vm_area_struct *vmacache[VMACACHE_SIZE];1551 struct vmacache vmacache;
1552
1556#if defined(SPLIT_RSS_COUNTING)1553#if defined(SPLIT_RSS_COUNTING)
1557 struct task_rss_stat rss_stat;1554 struct task_rss_stat rss_stat;
1558#endif1555#endif
include/linux/vmacache.h+1−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
12 12
13static inline void vmacache_flush(struct task_struct *tsk)13static inline void vmacache_flush(struct task_struct *tsk)
14{14{
15 memset(tsk->vmacache, 0, sizeof(tsk->vmacache));15 memset(tsk->vmacache.vmas, 0, sizeof(tsk->vmacache.vmas));
16}16}
17 17
18extern void vmacache_flush_all(struct mm_struct *mm);18extern void vmacache_flush_all(struct mm_struct *mm);
kernel/debug/debug_core.c+2−2
@@ -232,9 +232,9 @@ static void kgdb_flush_swbreak_addr(unsigned long addr) · 231 unmodified lines
232 int i;232 int i;
233 233
234 for (i = 0; i < VMACACHE_SIZE; i++) {234 for (i = 0; i < VMACACHE_SIZE; i++) {
235 if (!current->vmacache[i])235 if (!current->vmacache.vmas[i])
236 continue;236 continue;
237 flush_cache_range(current->vmacache[i],237 flush_cache_range(current->vmacache.vmas[i],
238 addr, addr + BREAK_INSTR_SIZE);238 addr, addr + BREAK_INSTR_SIZE);
239 }239 }
240 }240 }
mm/nommu.c+1−1
@@ -757,7 +757,7 @@ static void delete_vma_from_mm(struct vm_area_struct *vma) · 756 unmodified lines
757 mm->map_count--;757 mm->map_count--;
758 for (i = 0; i < VMACACHE_SIZE; i++) {758 for (i = 0; i < VMACACHE_SIZE; i++) {
759 /* if the vma is cached, invalidate the entire cache */759 /* if the vma is cached, invalidate the entire cache */
760 if (curr->vmacache[i] == vma) {760 if (curr->vmacache.vmas[i] == vma) {
761 vmacache_invalidate(mm);761 vmacache_invalidate(mm);
762 break;762 break;
763 }763 }
mm/vmacache.c+5−5
@@ -60,7 +60,7 @@ static inline bool vmacache_valid_mm(struct mm_struct *mm) · 59 unmodified lines
60void vmacache_update(unsigned long addr, struct vm_area_struct *newvma)60void vmacache_update(unsigned long addr, struct vm_area_struct *newvma)
61{61{
62 if (vmacache_valid_mm(newvma->vm_mm))62 if (vmacache_valid_mm(newvma->vm_mm))
63 current->vmacache[VMACACHE_HASH(addr)] = newvma;63 current->vmacache.vmas[VMACACHE_HASH(addr)] = newvma;
64}64}
65 65
66static bool vmacache_valid(struct mm_struct *mm)66static bool vmacache_valid(struct mm_struct *mm)
@@ -71,12 +71,12 @@ static bool vmacache_valid(struct mm_struct *mm) · 4 unmodified lines
71 return false;71 return false;
72 72
73 curr = current;73 curr = current;
74 if (mm->vmacache_seqnum != curr->vmacache_seqnum) {74 if (mm->vmacache_seqnum != curr->vmacache.seqnum) {
75 /*75 /*
76 * First attempt will always be invalid, initialize76 * First attempt will always be invalid, initialize
77 * the new cache for this task here.77 * the new cache for this task here.
78 */78 */
79 curr->vmacache_seqnum = mm->vmacache_seqnum;79 curr->vmacache.seqnum = mm->vmacache_seqnum;
80 vmacache_flush(curr);80 vmacache_flush(curr);
81 return false;81 return false;
82 }82 }
@@ -93,7 +93,7 @@ struct vm_area_struct *vmacache_find(struct mm_struct *mm, unsigned long addr) · 10 unmodified lines
93 return NULL;93 return NULL;
94 94
95 for (i = 0; i < VMACACHE_SIZE; i++) {95 for (i = 0; i < VMACACHE_SIZE; i++) {
96 struct vm_area_struct *vma = current->vmacache[i];96 struct vm_area_struct *vma = current->vmacache.vmas[i];
97 97
98 if (!vma)98 if (!vma)
99 continue;99 continue;
@@ -121,7 +121,7 @@ struct vm_area_struct *vmacache_find_exact(struct mm_struct *mm, · 21 unmodified lines
121 return NULL;121 return NULL;
122 122
123 for (i = 0; i < VMACACHE_SIZE; i++) {123 for (i = 0; i < VMACACHE_SIZE; i++) {
124 struct vm_area_struct *vma = current->vmacache[i];124 struct vm_area_struct *vma = current->vmacache.vmas[i];
125 125
126 if (vma && vma->vm_start == start && vma->vm_end == end) {126 if (vma && vma->vm_start == start && vma->vm_end == end) {
127 count_vm_vmacache_event(VMACACHE_FIND_HITS);127 count_vm_vmacache_event(VMACACHE_FIND_HITS);