Commit 314ff785 authored by Ingo Molnar's avatar Ingo Molnar
Browse files

mm/vmacache, sched/headers: Introduce 'struct vmacache' and move it from...


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.

Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 780de9dd
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -360,6 +360,18 @@ struct vm_area_struct {
	struct vm_userfaultfd_ctx vm_userfaultfd_ctx;
};

/*
 * The per task VMA cache array:
 */
#define VMACACHE_BITS 2
#define VMACACHE_SIZE (1U << VMACACHE_BITS)
#define VMACACHE_MASK (VMACACHE_SIZE - 1)

struct vmacache {
	u32 seqnum;
	struct vm_area_struct *vmas[VMACACHE_SIZE];
};

struct core_thread {
	struct task_struct *task;
	struct core_thread *next;
+4 −7
Original line number Diff line number Diff line
@@ -134,10 +134,6 @@ struct blk_plug;
struct filename;
struct nameidata;

#define VMACACHE_BITS 2
#define VMACACHE_SIZE (1U << VMACACHE_BITS)
#define VMACACHE_MASK (VMACACHE_SIZE - 1)

/*
 * These are the constant used to fake the fixed-point load-average
 * counting. Some notes:
@@ -1550,9 +1546,10 @@ struct task_struct {
#endif

	struct mm_struct *mm, *active_mm;
	/* per-thread vma caching */
	u32 vmacache_seqnum;
	struct vm_area_struct *vmacache[VMACACHE_SIZE];

	/* Per-thread vma caching: */
	struct vmacache vmacache;

#if defined(SPLIT_RSS_COUNTING)
	struct task_rss_stat	rss_stat;
#endif
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@

static inline void vmacache_flush(struct task_struct *tsk)
{
	memset(tsk->vmacache, 0, sizeof(tsk->vmacache));
	memset(tsk->vmacache.vmas, 0, sizeof(tsk->vmacache.vmas));
}

extern void vmacache_flush_all(struct mm_struct *mm);
+2 −2
Original line number Diff line number Diff line
@@ -232,9 +232,9 @@ static void kgdb_flush_swbreak_addr(unsigned long addr)
		int i;

		for (i = 0; i < VMACACHE_SIZE; i++) {
			if (!current->vmacache[i])
			if (!current->vmacache.vmas[i])
				continue;
			flush_cache_range(current->vmacache[i],
			flush_cache_range(current->vmacache.vmas[i],
					  addr, addr + BREAK_INSTR_SIZE);
		}
	}
+1 −1
Original line number Diff line number Diff line
@@ -757,7 +757,7 @@ static void delete_vma_from_mm(struct vm_area_struct *vma)
	mm->map_count--;
	for (i = 0; i < VMACACHE_SIZE; i++) {
		/* if the vma is cached, invalidate the entire cache */
		if (curr->vmacache[i] == vma) {
		if (curr->vmacache.vmas[i] == vma) {
			vmacache_invalidate(mm);
			break;
		}
Loading