From patchwork Wed Nov 14 21:51:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barret Rhoden X-Patchwork-Id: 10683235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB317109C for ; Wed, 14 Nov 2018 22:34:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD2FE2B9F9 for ; Wed, 14 Nov 2018 22:34:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DCF32BE96; Wed, 14 Nov 2018 22:34:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D9D42B9F9 for ; Wed, 14 Nov 2018 22:34:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388485AbeKOIkB (ORCPT ); Thu, 15 Nov 2018 03:40:01 -0500 Received: from mail-yb1-f201.google.com ([209.85.219.201]:33137 "EHLO mail-yb1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732896AbeKOI3z (ORCPT ); Thu, 15 Nov 2018 03:29:55 -0500 Received: by mail-yb1-f201.google.com with SMTP id r145-v6so13826798ybc.0 for ; Wed, 14 Nov 2018 14:24:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Swrg/Ql+aoXKDVqM4rUHKdjFWS7RdD4POWqk40vnoJ0=; b=jnaaG0KmPOtIngqfLHs7bFlfg63KFl/U07rJ2rlJdTOgtRPOkzSQrjiKwuWtic29wg Adla+90Mfzw6DYeictWdIx/CtriY3V2yAC3N/4sDyJ1z5kQaboGKHOlDEDJmvVI9usSq Wu90dimuVYQSWXVklUzKdX5gxRhFKmSGS646EGQMALfcaaJelGmUfaPGKjDC7Q4WTZur wqYCHPrF6S+DrYv9fpg7DBSrDW6zW7/kYR+0xTyiy2iD1Sh8eZO46z6E8JbR+NHD0iX4 AYw+y0vHCs4rGmJNpZhwOyqKF0OHSJbMsEZrAQslEd7SEvArL27n2/+OkcRxQuHZjtVn grfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Swrg/Ql+aoXKDVqM4rUHKdjFWS7RdD4POWqk40vnoJ0=; b=AgaMJvY0s6g+7aJ8U1gmX7pCv0XYyyZZyyVXO1Ot/80NH7ZlW1RC9Ssbse2fQbJ74u Xjbnbb//bgMptRDap/jkUtiHtt46gmIuOxYxe6/uosYX0LfjA1agod5Ub04McYnPz262 OZIlahmHD8RGJlB8RBzIKWtqrdOFWbgfpUND7yTMSxTlnZQcnZQqaluSg1xhOd7/nmd7 bx5YyC/pJROQTsqxHL5ZXXi5MH3RUlUB6PVMtISLJTTtK9UOejEjDxkkvi+ogFoNtNJi i4HaHQJ0ToDyW+ES8x5iHjJDI5ola29cn7ksVFroM7rIOQt3YStG9kfHr7Ixctj7ssbH rxZA== X-Gm-Message-State: AGRZ1gLcmTIDvrJzKe1bwjhPoib9AzJ91Xi+8r68sdeu+y6h6eOf4dby NXnI9VSrkCk3fEvEo4WVSxboFojA X-Google-Smtp-Source: AJdET5cydhrPOQA/wDgBNBMiRvM6xC5Bw1OO7w1/3WOMNTH68+Tk7ymaB2i9Hz2qGH2RLHvnvDmsz8w5 X-Received: by 2002:a25:3a03:: with SMTP id h3-v6mr1580605yba.77.1542232383861; Wed, 14 Nov 2018 13:53:03 -0800 (PST) Date: Wed, 14 Nov 2018 16:51:53 -0500 In-Reply-To: <20181114215155.259978-1-brho@google.com> Message-Id: <20181114215155.259978-2-brho@google.com> Mime-Version: 1.0 References: <20181109203921.178363-1-brho@google.com> <20181114215155.259978-1-brho@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH v2 1/3] mm: make dev_pagemap_mapping_shift() externally visible From: Barret Rhoden To: Dan Williams , Dave Jiang , Ross Zwisler , Vishal Verma , Paolo Bonzini , " =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= " , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Naoya Horiguchi Cc: linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, "H. Peter Anvin" , x86@kernel.org, kvm@vger.kernel.org, yu.c.zhang@intel.com, yi.z.zhang@intel.com, linux-mm@kvack.org, David Hildenbrand Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP KVM has a use case for determining the size of a dax mapping. The KVM code has easy access to the address and the mm; hence the change in parameters. Signed-off-by: Barret Rhoden Reviewed-by: David Hildenbrand Acked-by: Dan Williams --- include/linux/mm.h | 3 +++ mm/memory-failure.c | 38 +++----------------------------------- mm/util.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 35 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 5411de93a363..51215d695753 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -935,6 +935,9 @@ static inline bool is_pci_p2pdma_page(const struct page *page) } #endif /* CONFIG_DEV_PAGEMAP_OPS */ +unsigned long dev_pagemap_mapping_shift(unsigned long address, + struct mm_struct *mm); + static inline void get_page(struct page *page) { page = compound_head(page); diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 0cd3de3550f0..c3f2c6a8607e 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -265,40 +265,6 @@ void shake_page(struct page *p, int access) } EXPORT_SYMBOL_GPL(shake_page); -static unsigned long dev_pagemap_mapping_shift(struct page *page, - struct vm_area_struct *vma) -{ - unsigned long address = vma_address(page, vma); - pgd_t *pgd; - p4d_t *p4d; - pud_t *pud; - pmd_t *pmd; - pte_t *pte; - - pgd = pgd_offset(vma->vm_mm, address); - if (!pgd_present(*pgd)) - return 0; - p4d = p4d_offset(pgd, address); - if (!p4d_present(*p4d)) - return 0; - pud = pud_offset(p4d, address); - if (!pud_present(*pud)) - return 0; - if (pud_devmap(*pud)) - return PUD_SHIFT; - pmd = pmd_offset(pud, address); - if (!pmd_present(*pmd)) - return 0; - if (pmd_devmap(*pmd)) - return PMD_SHIFT; - pte = pte_offset_map(pmd, address); - if (!pte_present(*pte)) - return 0; - if (pte_devmap(*pte)) - return PAGE_SHIFT; - return 0; -} - /* * Failure handling: if we can't find or can't kill a process there's * not much we can do. We just print a message and ignore otherwise. @@ -329,7 +295,9 @@ static void add_to_kill(struct task_struct *tsk, struct page *p, tk->addr = page_address_in_vma(p, vma); tk->addr_valid = 1; if (is_zone_device_page(p)) - tk->size_shift = dev_pagemap_mapping_shift(p, vma); + tk->size_shift = + dev_pagemap_mapping_shift(vma_address(page, vma), + vma->vm_mm); else tk->size_shift = compound_order(compound_head(p)) + PAGE_SHIFT; diff --git a/mm/util.c b/mm/util.c index 8bf08b5b5760..61bc9bab931d 100644 --- a/mm/util.c +++ b/mm/util.c @@ -780,3 +780,37 @@ int get_cmdline(struct task_struct *task, char *buffer, int buflen) out: return res; } + +unsigned long dev_pagemap_mapping_shift(unsigned long address, + struct mm_struct *mm) +{ + pgd_t *pgd; + p4d_t *p4d; + pud_t *pud; + pmd_t *pmd; + pte_t *pte; + + pgd = pgd_offset(mm, address); + if (!pgd_present(*pgd)) + return 0; + p4d = p4d_offset(pgd, address); + if (!p4d_present(*p4d)) + return 0; + pud = pud_offset(p4d, address); + if (!pud_present(*pud)) + return 0; + if (pud_devmap(*pud)) + return PUD_SHIFT; + pmd = pmd_offset(pud, address); + if (!pmd_present(*pmd)) + return 0; + if (pmd_devmap(*pmd)) + return PMD_SHIFT; + pte = pte_offset_map(pmd, address); + if (!pte_present(*pte)) + return 0; + if (pte_devmap(*pte)) + return PAGE_SHIFT; + return 0; +} +EXPORT_SYMBOL_GPL(dev_pagemap_mapping_shift); From patchwork Wed Nov 14 21:51:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barret Rhoden X-Patchwork-Id: 10683307 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9736114D6 for ; Wed, 14 Nov 2018 22:57:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FD932BF8B for ; Wed, 14 Nov 2018 22:57:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 729102BFAA; Wed, 14 Nov 2018 22:57:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B5B02BF8B for ; Wed, 14 Nov 2018 22:57:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727128AbeKOJCi (ORCPT ); Thu, 15 Nov 2018 04:02:38 -0500 Received: from mail-vk1-f201.google.com ([209.85.221.201]:47020 "EHLO mail-vk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725895AbeKOJCi (ORCPT ); Thu, 15 Nov 2018 04:02:38 -0500 Received: by mail-vk1-f201.google.com with SMTP id p22so2900537vkd.13 for ; Wed, 14 Nov 2018 14:57:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=TjNbpFDEmROOYDgX+JBtXjmBSAKa/KDKnxWS9mQYdnM=; b=taFjDK0teNWIgkT/L+183FUK7Rjv5BiYjc2vj9n0IhdJavI+1kbRzaJU2Yiiu0h737 Wh0YUHhy9yDVHl+9c4GqoLinKZL/hiYqZIJgsfeS1QhSZjd36eM3bD78H/Q8sGHJ+vLm I7/MEgB1fNMShiA10dPq+M3pt1sOc2JWuVUnU9G7dxuXUvzheuRMYLSs/jlRC6c7hyFE APQR91LYXzb4ENO5mM4jbgKl9V7Yus/mOvA2PBY5nGoYkqPxnKIh+QLY4Uv0+ZDJUDRJ lfa4l23S3nN7B/tI6vj3q9nyARf3QBI5df/wHX2XKckqMBtglSEKQIibBZ0wwNQznCwd GYjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=TjNbpFDEmROOYDgX+JBtXjmBSAKa/KDKnxWS9mQYdnM=; b=dOrpd/xBOZ/5fZEFEaoSnTakgIRB+QuCjpd3O5R0ISqHQNGugAylA7htV0xnq1LrlR FGFN4RGi1AjxSNR1zd3GJrL7TBoOnXj1I+/TZfYygXpn20Q3wA7rINWUviGyJKU2aNZA T4zXhbMYlWNG0O4YzgOdO2W29xPbs2lETuT5aT69O40+AyQYk3mGMbHm9QtNPPBsYsCm 3hfg8Q0gAISh0UCeEyDgmuviuE1TND0EO4uT6Ilp2oodS+w/+2V4Oo0Zhb4R4SSb6Gw6 Oq3iG9eM2bJMjTPm53dEYbnfHqO4IxicXoMfjtXjfdpt2rYNCitLLvl4qxOfBMTxhcAn JhZw== X-Gm-Message-State: AGRZ1gJH8SLe72/eNPVeL8WxZwsAxZ7acnjOMGcP60BhlQmZYTp1+OXb pMEZO840xDbvjY/m8H2z9kDbI+qm X-Google-Smtp-Source: AJdET5fxjUluLcn0PMYFFDQMUPhJJ6f6///VYVv7kfdG0gbmeQPMhsaCe6AtiBa2pml32koG0VHN598e X-Received: by 2002:ab0:72d6:: with SMTP id g22mr3170146uap.14.1542232387447; Wed, 14 Nov 2018 13:53:07 -0800 (PST) Date: Wed, 14 Nov 2018 16:51:54 -0500 In-Reply-To: <20181114215155.259978-1-brho@google.com> Message-Id: <20181114215155.259978-3-brho@google.com> Mime-Version: 1.0 References: <20181109203921.178363-1-brho@google.com> <20181114215155.259978-1-brho@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH v2 2/3] kvm: Use huge pages for DAX-backed files From: Barret Rhoden To: Dan Williams , Dave Jiang , Ross Zwisler , Vishal Verma , Paolo Bonzini , " =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= " , Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, "H. Peter Anvin" , x86@kernel.org, kvm@vger.kernel.org, yu.c.zhang@intel.com, yi.z.zhang@intel.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This change allows KVM to map DAX-backed files made of huge pages with huge mappings in the EPT/TDP. DAX pages are not PageTransCompound. The existing check is trying to determine if the mapping for the pfn is a huge mapping or not. For non-DAX maps, e.g. hugetlbfs, that means checking PageTransCompound. For DAX, we can check the page table itself. Note that KVM already faulted in the page (or huge page) in the host's page table, and we hold the KVM mmu spinlock. We grabbed that lock in kvm_mmu_notifier_invalidate_range_end, before checking the mmu seq. Signed-off-by: Barret Rhoden --- - removed map_shift local variable arch/x86/kvm/mmu.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index cf5f572f2305..6914989d1e3d 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -3152,6 +3152,35 @@ static int kvm_handle_bad_page(struct kvm_vcpu *vcpu, gfn_t gfn, kvm_pfn_t pfn) return -EFAULT; } +static bool pfn_is_huge_mapped(struct kvm *kvm, gfn_t gfn, kvm_pfn_t pfn) +{ + struct page *page = pfn_to_page(pfn); + unsigned long hva; + + if (!is_zone_device_page(page)) + return PageTransCompoundMap(page); + + /* + * DAX pages do not use compound pages. The page should have already + * been mapped into the host-side page table during try_async_pf(), so + * we can check the page tables directly. + */ + hva = gfn_to_hva(kvm, gfn); + if (kvm_is_error_hva(hva)) + return false; + + /* + * Our caller grabbed the KVM mmu_lock with a successful + * mmu_notifier_retry, so we're safe to walk the page table. + */ + switch (dev_pagemap_mapping_shift(hva, current->mm)) { + case PMD_SHIFT: + case PUD_SIZE: + return true; + } + return false; +} + static void transparent_hugepage_adjust(struct kvm_vcpu *vcpu, gfn_t *gfnp, kvm_pfn_t *pfnp, int *levelp) @@ -3168,7 +3197,7 @@ static void transparent_hugepage_adjust(struct kvm_vcpu *vcpu, */ if (!is_error_noslot_pfn(pfn) && !kvm_is_reserved_pfn(pfn) && level == PT_PAGE_TABLE_LEVEL && - PageTransCompoundMap(pfn_to_page(pfn)) && + pfn_is_huge_mapped(vcpu->kvm, gfn, pfn) && !mmu_gfn_lpage_is_disallowed(vcpu, gfn, PT_DIRECTORY_LEVEL)) { unsigned long mask; /* @@ -5678,7 +5707,7 @@ static bool kvm_mmu_zap_collapsible_spte(struct kvm *kvm, */ if (sp->role.direct && !kvm_is_reserved_pfn(pfn) && - PageTransCompoundMap(pfn_to_page(pfn))) { + pfn_is_huge_mapped(kvm, sp->gfn, pfn)) { pte_list_remove(rmap_head, sptep); need_tlb_flush = 1; goto restart; From patchwork Wed Nov 14 21:51:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barret Rhoden X-Patchwork-Id: 10683265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2136213BF for ; Wed, 14 Nov 2018 22:46:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C00E29D1A for ; Wed, 14 Nov 2018 22:46:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF6802BDC9; Wed, 14 Nov 2018 22:46:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A054729D1A for ; Wed, 14 Nov 2018 22:46:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728411AbeKOIv6 (ORCPT ); Thu, 15 Nov 2018 03:51:58 -0500 Received: from mail-yw1-f74.google.com ([209.85.161.74]:38643 "EHLO mail-yw1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728393AbeKOIv6 (ORCPT ); Thu, 15 Nov 2018 03:51:58 -0500 Received: by mail-yw1-f74.google.com with SMTP id v11-v6so9707390ywv.5 for ; Wed, 14 Nov 2018 14:46:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=cef6YNlIU1qhqW6QfENAl8n18Yhm93q9fZZO+r6oQn0=; b=t7HWcSySxUpO/OZdd5gwxbvVhUTog5gHX0Cq0W3jWFJ8gs/5iH5jhylAWeqcu9uzCx ksb/W0m5Omr+FwduH5FwBuwQmdkakggEOJBYBk90mW9uRLgSHz7am3k5c6qB/yk0MYdl WA6oik/LsDoixfzHWqSwqk6ddkxH2wjww0xI3b8VYw4YD4GefiBNQMKRVCJdI2ZlIARq 6ybykly4+8x/M5IWUeIAMuEDE3ZeFpgWZtIv1fND5ujnvNFbhy294N8A/3L3mgwmphLz wfUeKDy933l8XM6JHYShKMNZW3kxfxMozztfGcY1S7ySG1xGwvVgjhle3K7XTa4G59mj qrHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=cef6YNlIU1qhqW6QfENAl8n18Yhm93q9fZZO+r6oQn0=; b=ZJF8ut9A6HCdwjRp1bsoSbv7X61uKQMcZj2cHX/BZgOQ4Bfj73C95Dc0IPvYOrtR8o O4hDWoRjH2jQvS7ufToj8+PKbtNWwRKlkBRnhCIwWtxb98YzbbqBL1m2F+u2G7Nhm9mv NEkBa/WVahpbafb50BAHcmVjtDxN7LoRF9b8DVnGbM/YZSd6zZJMBB8HKDJSe+dg0ImC 6U2LUkcJtkx/kcENa4mmLGismRlfSw7oYQJuR9ay0+I6lkWs+wou2TZ1JFjMaPltPQTu JoToRDIMkeecQ7YrBSy1TMQELMogl6xa7yNPqK+fY1qg9e3Lnag5LBiZ5N3rzfT+Uu/M cZjg== X-Gm-Message-State: AGRZ1gK/HzdHrpq6urTRGpwjqW+BSrAuH+oiXxNwji+2Z15MwxVtr26D q+A+V4+z+fxgDT8DUwcdQBjp90Wa X-Google-Smtp-Source: AJdET5fNHqW6uc/jnFI/Gp6AlfYsKcuiR7tSCSnpn/Rthe6786N1XCmZCOlfQ9LKEnrlCDJ9sUINBAqS X-Received: by 2002:a81:5f55:: with SMTP id t82-v6mr1740879ywb.24.1542232389390; Wed, 14 Nov 2018 13:53:09 -0800 (PST) Date: Wed, 14 Nov 2018 16:51:55 -0500 In-Reply-To: <20181114215155.259978-1-brho@google.com> Message-Id: <20181114215155.259978-4-brho@google.com> Mime-Version: 1.0 References: <20181109203921.178363-1-brho@google.com> <20181114215155.259978-1-brho@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH v2 3/3] kvm: remove redundant PageReserved() check From: Barret Rhoden To: Dan Williams , Dave Jiang , Ross Zwisler , Vishal Verma , Paolo Bonzini , " =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= " , Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, "H. Peter Anvin" , x86@kernel.org, kvm@vger.kernel.org, yu.c.zhang@intel.com, yi.z.zhang@intel.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP kvm_is_reserved_pfn() already checks PageReserved(). Signed-off-by: Barret Rhoden Reviewed-by: David Hildenbrand --- virt/kvm/kvm_main.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 2679e476b6c3..e0ea6d7dac14 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1700,12 +1700,8 @@ EXPORT_SYMBOL_GPL(kvm_release_pfn_dirty); void kvm_set_pfn_dirty(kvm_pfn_t pfn) { - if (!kvm_is_reserved_pfn(pfn)) { - struct page *page = pfn_to_page(pfn); - - if (!PageReserved(page)) - SetPageDirty(page); - } + if (!kvm_is_reserved_pfn(pfn)) + SetPageDirty(pfn_to_page(pfn)); } EXPORT_SYMBOL_GPL(kvm_set_pfn_dirty);