Skip to content

Commit af4bf6c

Browse files
davidhildenbrandfrankjaa
authored andcommitted
s390/mm: optimize locking without huge pages in gmap_pmd_op_walk()
Right now we temporarily take the page table lock in gmap_pmd_op_walk() even though we know we won't need it (if we can never have 1mb pages mapped into the gmap). Let's make this a special case, so gmap_protect_range() and gmap_sync_dirty_log_pmd() will not take the lock when huge pages are not allowed. gmap_protect_range() is called quite frequently for managing shadow page tables in vSIE environments. Signed-off-by: David Hildenbrand <david@redhat.com> Reviewed-by: Janosch Frank <frankja@linux.ibm.com> Message-Id: <20180806155407.15252-1-david@redhat.com> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
1 parent 67d49d5 commit af4bf6c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

arch/s390/mm/gmap.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -905,10 +905,16 @@ static inline pmd_t *gmap_pmd_op_walk(struct gmap *gmap, unsigned long gaddr)
905905
pmd_t *pmdp;
906906

907907
BUG_ON(gmap_is_shadow(gmap));
908-
spin_lock(&gmap->guest_table_lock);
909908
pmdp = (pmd_t *) gmap_table_walk(gmap, gaddr, 1);
909+
if (!pmdp)
910+
return NULL;
910911

911-
if (!pmdp || pmd_none(*pmdp)) {
912+
/* without huge pages, there is no need to take the table lock */
913+
if (!gmap->mm->context.allow_gmap_hpage_1m)
914+
return pmd_none(*pmdp) ? NULL : pmdp;
915+
916+
spin_lock(&gmap->guest_table_lock);
917+
if (pmd_none(*pmdp)) {
912918
spin_unlock(&gmap->guest_table_lock);
913919
return NULL;
914920
}

0 commit comments

Comments
 (0)