From patchwork Tue Apr 11 17:42:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 9675867 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7A9C160231 for ; Tue, 11 Apr 2017 17:42:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73A3028597 for ; Tue, 11 Apr 2017 17:42:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 686CB285A0; Tue, 11 Apr 2017 17:42:56 +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=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DE37528597 for ; Tue, 11 Apr 2017 17:42:55 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CAEA320D7648E; Tue, 11 Apr 2017 10:42:55 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 439B820D7648E for ; Tue, 11 Apr 2017 10:42:55 -0700 (PDT) Received: by mail-pf0-x241.google.com with SMTP id c198so670511pfc.0 for ; Tue, 11 Apr 2017 10:42:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zG0YeXJKyhBpgYydkFkrIL9gm7rQsMwsNMKiJHo2Ljc=; b=AjQTM91Mr/BHdJ5mh43FXq/ixOIo3qv8GK3gMREBsM9Zly/tvDTlThNeI+/6yGHPho iZlypAG3JutJjj+STjm3O/Xxf+G5yNZyLTMZf4i4QCuoA1ok2IBuOvHuyoBGKUye/HIY zxD7e7VQMXSWYP95QTn2PeQmDbkIBHFhEk+rnGcGrnOmW5PMOoS1f+DlxZUZMSM/0A+f D6N8q0Aekma5EgiwYRX8WIlviMfbhSYHgtjr0uZKpn1Xb1RWylbML3FTmcpfjyup9VHu 1gB7F9ROPbPIqG8b199vLXyI5GFn5YIG0hh76BW1lBAK2WTa72AJVQhYthbLVJaSgfFq pW2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zG0YeXJKyhBpgYydkFkrIL9gm7rQsMwsNMKiJHo2Ljc=; b=MuxdoMMv7N43Dfa4WlMHpVUVbyE+KJmPPP1M1tC4wElUWIxXxQAWYZ5WN3w4j5nYaR X3E7cxTss2v2spG1nzXeD5IV9kEvqwBzMRg/T3+NAC5pIi2waf+KSP73xHQFtr2d+ISe 87z+OuLUiU6ezRSvwa7SUkV+Zk6dA9Pd81sPxHs/VdG7bS5p2gGEixCaqp3hYIADeSaY zfRNHUoCzKmryGyOb4o+5XUG4qXhif0cUupOLRGI2egksFNl4MZBubvva7DRbOd/CQAw d01pXhn/i7uBPhAQeTgcvbgd5K3QRB3PAU05fYTthIzEmduf2HFgOZU2x/1NzqT9+05x 2H4g== X-Gm-Message-State: AFeK/H3HuGKkpl+TwrHcxJTEj1X86DTVVg0F2qdhqCTeSRu/Q8gt4d6GmPbxOGUi0WHKOA== X-Received: by 10.84.210.228 with SMTP id a91mr76097876pli.120.1491932574926; Tue, 11 Apr 2017 10:42:54 -0700 (PDT) Received: from localhost.localdomain ([103.57.0.128]) by smtp.gmail.com with ESMTPSA id r185sm20182582pfr.72.2017.04.11.10.42.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Apr 2017 10:42:54 -0700 (PDT) From: Oliver O'Halloran To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 1/9] mm/huge_memory: Use zap_deposited_table() more Date: Wed, 12 Apr 2017 03:42:25 +1000 Message-Id: <20170411174233.21902-2-oohall@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170411174233.21902-1-oohall@gmail.com> References: <20170411174233.21902-1-oohall@gmail.com> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-nvdimm@lists.01.org, bsingharora@gmail.com, arbab@linux.vnet.ibm.com, linux-mm@kvack.org, "Aneesh Kumar K.V" , "Kirill A. Shutemov" MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Depending flags of the PMD being zapped there may or may not be a deposited pgtable to be freed. In two of the three cases this is open coded while the third uses the zap_deposited_table() helper. This patch converts the others to use the helper to clean things up a bit. Cc: "Aneesh Kumar K.V" Cc: "Kirill A. Shutemov" Cc: linux-mm@kvack.org Signed-off-by: Oliver O'Halloran Reviewed-by: Aneesh Kumar K.V Acked-by: David Rientjes --- For reference: void zap_deposited_table(struct mm_struct *mm, pmd_t *pmd) { pgtable_t pgtable; pgtable = pgtable_trans_huge_withdraw(mm, pmd); pte_free(mm, pgtable); atomic_long_dec(&mm->nr_ptes); } --- mm/huge_memory.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index b787c4cfda0e..aa01dd47cc65 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1615,8 +1615,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, if (is_huge_zero_pmd(orig_pmd)) tlb_remove_page_size(tlb, pmd_page(orig_pmd), HPAGE_PMD_SIZE); } else if (is_huge_zero_pmd(orig_pmd)) { - pte_free(tlb->mm, pgtable_trans_huge_withdraw(tlb->mm, pmd)); - atomic_long_dec(&tlb->mm->nr_ptes); + zap_deposited_table(tlb->mm, pmd); spin_unlock(ptl); tlb_remove_page_size(tlb, pmd_page(orig_pmd), HPAGE_PMD_SIZE); } else { @@ -1625,10 +1624,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, VM_BUG_ON_PAGE(page_mapcount(page) < 0, page); VM_BUG_ON_PAGE(!PageHead(page), page); if (PageAnon(page)) { - pgtable_t pgtable; - pgtable = pgtable_trans_huge_withdraw(tlb->mm, pmd); - pte_free(tlb->mm, pgtable); - atomic_long_dec(&tlb->mm->nr_ptes); + zap_deposited_table(tlb->mm, pmd); add_mm_counter(tlb->mm, MM_ANONPAGES, -HPAGE_PMD_NR); } else { if (arch_needs_pgtable_deposit())