Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp674504pxb; Thu, 9 Sep 2021 09:27:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNzZ8rydM74y6Jbtusz5Dhv+gqN4dtEoUgedEbenFD5l16Rtn3uYXTAygwKV3/kTyz2awW X-Received: by 2002:aa7:dd4e:: with SMTP id o14mr3978272edw.104.1631204861603; Thu, 09 Sep 2021 09:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631204861; cv=none; d=google.com; s=arc-20160816; b=eXspKLuEptRXwSrIvw7O0UIsqY2bsLBo4cv3AWie/4XezcX+QLOYbfTui4StWDtuiK Tw3cuGtmECxDh1mwiwlHpt5asIfu6Jxpsuqu33dgGdsUUbngN0zqJQIjx3KbSJ61Ngs0 TNMnNtReZgY2CQL3WQAeY7ddEQ2IC8CMI8uBwr8zdoDHW8yqB3LBTFX7u7ev052xQssy aaudjPsBfTgEGrhSYIpRXqd9YJiSEDNYVKfRyjgLrOc94cq5PX6CGAUeAkiW3V0cvO4b SSC/AZ6/kAE3PaNhVi0FOFgecP6nBuiK9QCW6ika5dJueg0Pw/TtIml5f8zLPJcc+xMm bznw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FHro6t2tN+PX+WrUKfBpgz4ptLtDy0pjdbBM71YmOAI=; b=npCL84a06Fv5Aldsy/32GVNnfSS+RKU9IBdcwACNCaGd4UT/o1b2LUXsskyfyEVZ8Y qLn9ha83IqjIbXrES9lyM8kL3nqKE4Te1Ky17SNBlGbqctfVdTZJ1GIFWjIo3i/lo7fh dZVBF8935/SaL0+OOH9gSt7FPp9myE6y68C6g3MWQSyk/TbAITm6GCQTUaNqZpfFHg9S aY+DqB8JBI5x3YfiT/3KT1vd/r3evw6Zi6nfXiU8aB3PZvi6X2XSRzqcBWpEfnENjQXZ na5q22Aq0Fcj+Y51CRRers9bgICXhRjcHFQTuEgKs201Zuh3+b1XoZNw1DjqPBParNEB Ou/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LWXqOR77; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qf34si2732241ejc.197.2021.09.09.09.27.10; Thu, 09 Sep 2021 09:27:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LWXqOR77; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239543AbhIIQZl (ORCPT + 99 others); Thu, 9 Sep 2021 12:25:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30569 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239649AbhIIQZP (ORCPT ); Thu, 9 Sep 2021 12:25:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631204645; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FHro6t2tN+PX+WrUKfBpgz4ptLtDy0pjdbBM71YmOAI=; b=LWXqOR771Av+coe0iCWm8CMIrjGkBM9bgQRM+hn4x569cfwnI9HgEqOr3xIugQXxt1qDVA vu0k5ObYlptRMwMiY0ozVymlUTNSs5e0R9sf4YBiniiNHH4LRM3cz2BHTMZWIqRzU1mrTW iADOs3ge7bq3hVgi3WHjXxQtFo88m+4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-355-AjGPr8hoNB6cov7rMSNwlg-1; Thu, 09 Sep 2021 12:24:04 -0400 X-MC-Unique: AjGPr8hoNB6cov7rMSNwlg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 141A81006ACA; Thu, 9 Sep 2021 16:23:22 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.39.192.233]) by smtp.corp.redhat.com (Postfix) with ESMTP id CACD477718; Thu, 9 Sep 2021 16:23:18 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-s390@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, David Hildenbrand , Christian Borntraeger , Janosch Frank , Cornelia Huck , Claudio Imbrenda , Heiko Carstens , Vasily Gorbik , Niklas Schnelle , Gerald Schaefer , Ulrich Weigand Subject: [PATCH resend RFC 8/9] s390/mm: optimize set_guest_storage_key() Date: Thu, 9 Sep 2021 18:22:47 +0200 Message-Id: <20210909162248.14969-9-david@redhat.com> In-Reply-To: <20210909162248.14969-1-david@redhat.com> References: <20210909162248.14969-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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)) { -- 2.31.1