Skip to content

Commit 7cb7026

Browse files
davidhildenbrandborntraeger
authored andcommitted
s390/mm: optimize set_guest_storage_key()
We already optimize get_guest_storage_key() to assume that if we don't have a PTE table and don't have a huge page mapped that the storage key is 0. Similarly, optimize set_guest_storage_key() to simply do nothing in case the key to set is 0. Signed-off-by: David Hildenbrand <[email protected]> Reviewed-by: Claudio Imbrenda <[email protected]> Acked-by: Heiko Carstens <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Borntraeger <[email protected]>
1 parent 8318c40 commit 7cb7026

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

arch/s390/mm/pgtable.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,13 +792,23 @@ int set_guest_storage_key(struct mm_struct *mm, unsigned long addr,
792792
pmd_t *pmdp;
793793
pte_t *ptep;
794794

795-
if (pmd_lookup(mm, addr, &pmdp))
795+
/*
796+
* If we don't have a PTE table and if there is no huge page mapped,
797+
* we can ignore attempts to set the key to 0, because it already is 0.
798+
*/
799+
switch (pmd_lookup(mm, addr, &pmdp)) {
800+
case -ENOENT:
801+
return key ? -EFAULT : 0;
802+
case 0:
803+
break;
804+
default:
796805
return -EFAULT;
806+
}
797807

798808
ptl = pmd_lock(mm, pmdp);
799809
if (!pmd_present(*pmdp)) {
800810
spin_unlock(ptl);
801-
return -EFAULT;
811+
return key ? -EFAULT : 0;
802812
}
803813

804814
if (pmd_large(*pmdp)) {

0 commit comments

Comments
 (0)