Skip to content

Commit a1b200e

Browse files
heicarsttorvalds
authored andcommitted
mm: provide init_mm mm_context initializer
Provide an INIT_MM_CONTEXT intializer macro which can be used to statically initialize mm_struct:mm_context of init_mm. This way we can get rid of code which will do the initialization at run time (on s390). In addition the current code can be found at a place where it is not expected. So let's have a common initializer which architectures can use if needed. This is based on a patch from Suzuki Poulose. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Suzuki Poulose <suzuki@in.ibm.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent e7d8634 commit a1b200e

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎arch/s390/include/asm/mmu.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,9 @@ typedef struct {
1313
int alloc_pgste; /* cloned contexts will have extended page tables */
1414
} mm_context_t;
1515

16+
#define INIT_MM_CONTEXT(name) \
17+
.context.list_lock = __SPIN_LOCK_UNLOCKED(name.context.list_lock), \
18+
.context.crst_list = LIST_HEAD_INIT(name.context.crst_list), \
19+
.context.pgtable_list = LIST_HEAD_INIT(name.context.pgtable_list),
20+
1621
#endif

‎arch/s390/mm/vmem.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,6 @@ void __init vmem_map_init(void)
332332
unsigned long start, end;
333333
int i;
334334

335-
spin_lock_init(&init_mm.context.list_lock);
336-
INIT_LIST_HEAD(&init_mm.context.crst_list);
337-
INIT_LIST_HEAD(&init_mm.context.pgtable_list);
338-
init_mm.context.noexec = 0;
339335
ro_start = ((unsigned long)&_stext) & PAGE_MASK;
340336
ro_end = PFN_ALIGN((unsigned long)&_eshared);
341337
for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) {

‎mm/init-mm.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
#include <asm/atomic.h>
99
#include <asm/pgtable.h>
10+
#include <asm/mmu.h>
11+
12+
#ifndef INIT_MM_CONTEXT
13+
#define INIT_MM_CONTEXT(name)
14+
#endif
1015

1116
struct mm_struct init_mm = {
1217
.mm_rb = RB_ROOT,
@@ -17,4 +22,5 @@ struct mm_struct init_mm = {
1722
.page_table_lock = __SPIN_LOCK_UNLOCKED(init_mm.page_table_lock),
1823
.mmlist = LIST_HEAD_INIT(init_mm.mmlist),
1924
.cpu_vm_mask = CPU_MASK_ALL,
25+
INIT_MM_CONTEXT(init_mm)
2026
};

0 commit comments

Comments
 (0)