[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210927190157.65ce9f54@p-imbrenda>
Date: Mon, 27 Sep 2021 19:01:57 +0200
From: Claudio Imbrenda <imbrenda@...ux.ibm.com>
To: David Hildenbrand <david@...hat.com>
Cc: linux-kernel@...r.kernel.org, linux-s390@...r.kernel.org,
kvm@...r.kernel.org, linux-mm@...ck.org,
Christian Borntraeger <borntraeger@...ibm.com>,
Janosch Frank <frankja@...ux.ibm.com>,
Cornelia Huck <cohuck@...hat.com>,
Heiko Carstens <hca@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>,
Niklas Schnelle <schnelle@...ux.ibm.com>,
Gerald Schaefer <gerald.schaefer@...ux.ibm.com>,
Ulrich Weigand <Ulrich.Weigand@...ibm.com>
Subject: Re: [PATCH resend RFC 8/9] s390/mm: optimize
set_guest_storage_key()
On Thu, 9 Sep 2021 18:22:47 +0200
David Hildenbrand <david@...hat.com> wrote:
> 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 <david@...hat.com>
Reviewed-by: Claudio Imbrenda <imbrenda@...ux.ibm.com>
> ---
> arch/s390/mm/pgtable.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c
> index 4e77b8ebdcc5..534939a3eca5 100644
> --- a/arch/s390/mm/pgtable.c
> +++ b/arch/s390/mm/pgtable.c
> @@ -792,13 +792,23 @@ int set_guest_storage_key(struct mm_struct *mm, unsigned long addr,
> pmd_t *pmdp;
> pte_t *ptep;
>
> - if (pmd_lookup(mm, addr, &pmdp))
> + /*
> + * If we don't have a PTE table and if there is no huge page mapped,
> + * we can ignore attempts to set the key to 0, because it already is 0.
> + */
> + switch (pmd_lookup(mm, addr, &pmdp)) {
> + case -ENOENT:
> + return key ? -EFAULT : 0;
> + case 0:
> + break;
> + default:
> return -EFAULT;
> + }
>
> ptl = pmd_lock(mm, pmdp);
> if (!pmd_present(*pmdp)) {
> spin_unlock(ptl);
> - return -EFAULT;
> + return key ? -EFAULT : 0;
> }
>
> if (pmd_large(*pmdp)) {
Powered by blists - more mailing lists