Skip to content

Commit 1058c16

Browse files
Alexander GordeevVasily Gorbik
authored andcommitted
s390/mm: cleanup init_new_context() callback
The set of values asce_limit may be assigned with is TASK_SIZE_MAX, _REGION1_SIZE, _REGION2_SIZE and 0 as a special case if the callback was called from execve(). Do VM_BUG_ON() if asce_limit is something else. Save few CPU cycles by removing unnecessary asce_limit re-assignment in case of 3-level task and redundant PGD entry type reconstruction. Signed-off-by: Alexander Gordeev <[email protected]> Reviewed-by: Heiko Carstens <[email protected]> Signed-off-by: Heiko Carstens <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent f755560 commit 1058c16

File tree

2 files changed

+21
-25
lines changed

2 files changed

+21
-25
lines changed

arch/s390/include/asm/mmu_context.h

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
static inline int init_new_context(struct task_struct *tsk,
1919
struct mm_struct *mm)
2020
{
21+
unsigned long asce_type, init_entry;
22+
2123
spin_lock_init(&mm->context.lock);
2224
INIT_LIST_HEAD(&mm->context.pgtable_list);
2325
INIT_LIST_HEAD(&mm->context.gmap_list);
@@ -35,29 +37,34 @@ static inline int init_new_context(struct task_struct *tsk,
3537
mm->context.allow_gmap_hpage_1m = 0;
3638
#endif
3739
switch (mm->context.asce_limit) {
38-
case _REGION2_SIZE:
40+
default:
3941
/*
40-
* forked 3-level task, fall through to set new asce with new
41-
* mm->pgd
42+
* context created by exec, the value of asce_limit can
43+
* only be zero in this case
4244
*/
43-
case 0:
44-
/* context created by exec, set asce limit to 4TB */
45+
VM_BUG_ON(mm->context.asce_limit);
46+
/* continue as 3-level task */
4547
mm->context.asce_limit = _REGION2_SIZE;
46-
mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH |
47-
_ASCE_USER_BITS | _ASCE_TYPE_REGION3;
48+
fallthrough;
49+
case _REGION2_SIZE:
50+
/* forked 3-level task */
51+
init_entry = _REGION3_ENTRY_EMPTY;
52+
asce_type = _ASCE_TYPE_REGION3;
4853
break;
4954
case TASK_SIZE_MAX:
50-
/* forked 5-level task, set new asce with new_mm->pgd */
51-
mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH |
52-
_ASCE_USER_BITS | _ASCE_TYPE_REGION1;
55+
/* forked 5-level task */
56+
init_entry = _REGION1_ENTRY_EMPTY;
57+
asce_type = _ASCE_TYPE_REGION1;
5358
break;
5459
case _REGION1_SIZE:
55-
/* forked 4-level task, set new asce with new mm->pgd */
56-
mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH |
57-
_ASCE_USER_BITS | _ASCE_TYPE_REGION2;
60+
/* forked 4-level task */
61+
init_entry = _REGION2_ENTRY_EMPTY;
62+
asce_type = _ASCE_TYPE_REGION2;
5863
break;
5964
}
60-
crst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm));
65+
mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH |
66+
_ASCE_USER_BITS | asce_type;
67+
crst_table_init((unsigned long *) mm->pgd, init_entry);
6168
return 0;
6269
}
6370

arch/s390/include/asm/pgalloc.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,6 @@ static inline void crst_table_init(unsigned long *crst, unsigned long entry)
3434
memset64((u64 *)crst, entry, _CRST_ENTRIES);
3535
}
3636

37-
static inline unsigned long pgd_entry_type(struct mm_struct *mm)
38-
{
39-
if (mm_pmd_folded(mm))
40-
return _SEGMENT_ENTRY_EMPTY;
41-
if (mm_pud_folded(mm))
42-
return _REGION3_ENTRY_EMPTY;
43-
if (mm_p4d_folded(mm))
44-
return _REGION2_ENTRY_EMPTY;
45-
return _REGION1_ENTRY_EMPTY;
46-
}
47-
4837
int crst_table_upgrade(struct mm_struct *mm, unsigned long limit);
4938

5039
static inline unsigned long check_asce_limit(struct mm_struct *mm, unsigned long addr,

0 commit comments

Comments
 (0)