Skip to content

Commit f28a4b4

Browse files
author
Martin Schwidefsky
committed
s390/mm: use a single lock for the fields in mm_context_t
The three locks 'lock', 'pgtable_lock' and 'gmap_lock' in the mm_context_t can be reduced to a single lock. Signed-off-by: Martin Schwidefsky <[email protected]>
1 parent 60f07c8 commit f28a4b4

File tree

4 files changed

+12
-19
lines changed

4 files changed

+12
-19
lines changed

arch/s390/include/asm/mmu.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ typedef struct {
99
cpumask_t cpu_attach_mask;
1010
atomic_t flush_count;
1111
unsigned int flush_mm;
12-
spinlock_t pgtable_lock;
1312
struct list_head pgtable_list;
14-
spinlock_t gmap_lock;
1513
struct list_head gmap_list;
1614
unsigned long gmap_asce;
1715
unsigned long asce;
@@ -29,10 +27,7 @@ typedef struct {
2927

3028
#define INIT_MM_CONTEXT(name) \
3129
.context.lock = __SPIN_LOCK_UNLOCKED(name.context.lock), \
32-
.context.pgtable_lock = \
33-
__SPIN_LOCK_UNLOCKED(name.context.pgtable_lock), \
3430
.context.pgtable_list = LIST_HEAD_INIT(name.context.pgtable_list), \
35-
.context.gmap_lock = __SPIN_LOCK_UNLOCKED(name.context.gmap_lock), \
3631
.context.gmap_list = LIST_HEAD_INIT(name.context.gmap_list),
3732

3833
static inline int tprot(unsigned long addr)

arch/s390/include/asm/mmu_context.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ static inline int init_new_context(struct task_struct *tsk,
1818
struct mm_struct *mm)
1919
{
2020
spin_lock_init(&mm->context.lock);
21-
spin_lock_init(&mm->context.pgtable_lock);
2221
INIT_LIST_HEAD(&mm->context.pgtable_list);
23-
spin_lock_init(&mm->context.gmap_lock);
2422
INIT_LIST_HEAD(&mm->context.gmap_list);
2523
cpumask_clear(&mm->context.cpu_attach_mask);
2624
atomic_set(&mm->context.flush_count, 0);

arch/s390/mm/gmap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ struct gmap *gmap_create(struct mm_struct *mm, unsigned long limit)
100100
if (!gmap)
101101
return NULL;
102102
gmap->mm = mm;
103-
spin_lock(&mm->context.gmap_lock);
103+
spin_lock(&mm->context.lock);
104104
list_add_rcu(&gmap->list, &mm->context.gmap_list);
105105
if (list_is_singular(&mm->context.gmap_list))
106106
gmap_asce = gmap->asce;
107107
else
108108
gmap_asce = -1UL;
109109
WRITE_ONCE(mm->context.gmap_asce, gmap_asce);
110-
spin_unlock(&mm->context.gmap_lock);
110+
spin_unlock(&mm->context.lock);
111111
return gmap;
112112
}
113113
EXPORT_SYMBOL_GPL(gmap_create);
@@ -248,7 +248,7 @@ void gmap_remove(struct gmap *gmap)
248248
spin_unlock(&gmap->shadow_lock);
249249
}
250250
/* Remove gmap from the pre-mm list */
251-
spin_lock(&gmap->mm->context.gmap_lock);
251+
spin_lock(&gmap->mm->context.lock);
252252
list_del_rcu(&gmap->list);
253253
if (list_empty(&gmap->mm->context.gmap_list))
254254
gmap_asce = 0;
@@ -258,7 +258,7 @@ void gmap_remove(struct gmap *gmap)
258258
else
259259
gmap_asce = -1UL;
260260
WRITE_ONCE(gmap->mm->context.gmap_asce, gmap_asce);
261-
spin_unlock(&gmap->mm->context.gmap_lock);
261+
spin_unlock(&gmap->mm->context.lock);
262262
synchronize_rcu();
263263
/* Put reference */
264264
gmap_put(gmap);

arch/s390/mm/pgalloc.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ unsigned long *page_table_alloc(struct mm_struct *mm)
188188
/* Try to get a fragment of a 4K page as a 2K page table */
189189
if (!mm_alloc_pgste(mm)) {
190190
table = NULL;
191-
spin_lock_bh(&mm->context.pgtable_lock);
191+
spin_lock_bh(&mm->context.lock);
192192
if (!list_empty(&mm->context.pgtable_list)) {
193193
page = list_first_entry(&mm->context.pgtable_list,
194194
struct page, lru);
@@ -203,7 +203,7 @@ unsigned long *page_table_alloc(struct mm_struct *mm)
203203
list_del(&page->lru);
204204
}
205205
}
206-
spin_unlock_bh(&mm->context.pgtable_lock);
206+
spin_unlock_bh(&mm->context.lock);
207207
if (table)
208208
return table;
209209
}
@@ -227,9 +227,9 @@ unsigned long *page_table_alloc(struct mm_struct *mm)
227227
/* Return the first 2K fragment of the page */
228228
atomic_set(&page->_mapcount, 1);
229229
clear_table(table, _PAGE_INVALID, PAGE_SIZE);
230-
spin_lock_bh(&mm->context.pgtable_lock);
230+
spin_lock_bh(&mm->context.lock);
231231
list_add(&page->lru, &mm->context.pgtable_list);
232-
spin_unlock_bh(&mm->context.pgtable_lock);
232+
spin_unlock_bh(&mm->context.lock);
233233
}
234234
return table;
235235
}
@@ -243,13 +243,13 @@ void page_table_free(struct mm_struct *mm, unsigned long *table)
243243
if (!mm_alloc_pgste(mm)) {
244244
/* Free 2K page table fragment of a 4K page */
245245
bit = (__pa(table) & ~PAGE_MASK)/(PTRS_PER_PTE*sizeof(pte_t));
246-
spin_lock_bh(&mm->context.pgtable_lock);
246+
spin_lock_bh(&mm->context.lock);
247247
mask = atomic_xor_bits(&page->_mapcount, 1U << bit);
248248
if (mask & 3)
249249
list_add(&page->lru, &mm->context.pgtable_list);
250250
else
251251
list_del(&page->lru);
252-
spin_unlock_bh(&mm->context.pgtable_lock);
252+
spin_unlock_bh(&mm->context.lock);
253253
if (mask != 0)
254254
return;
255255
}
@@ -275,13 +275,13 @@ void page_table_free_rcu(struct mmu_gather *tlb, unsigned long *table,
275275
return;
276276
}
277277
bit = (__pa(table) & ~PAGE_MASK) / (PTRS_PER_PTE*sizeof(pte_t));
278-
spin_lock_bh(&mm->context.pgtable_lock);
278+
spin_lock_bh(&mm->context.lock);
279279
mask = atomic_xor_bits(&page->_mapcount, 0x11U << bit);
280280
if (mask & 3)
281281
list_add_tail(&page->lru, &mm->context.pgtable_list);
282282
else
283283
list_del(&page->lru);
284-
spin_unlock_bh(&mm->context.pgtable_lock);
284+
spin_unlock_bh(&mm->context.lock);
285285
table = (unsigned long *) (__pa(table) | (1U << bit));
286286
tlb_remove_table(tlb, table);
287287
}

0 commit comments

Comments
 (0)