Received: by 10.213.65.68 with SMTP id h4csp1489934imn; Thu, 15 Mar 2018 00:40:47 -0700 (PDT) X-Google-Smtp-Source: AG47ELuPe3aunk9ye7JMJF/cEuIMJdJ8TR8oh81g7TMR/qbA0kqnuNSbrbCuI5O3SsG0xBtHVz0A X-Received: by 10.101.75.18 with SMTP id r18mr5982560pgq.36.1521099647304; Thu, 15 Mar 2018 00:40:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521099647; cv=none; d=google.com; s=arc-20160816; b=CH19Tpohms7/KIW4ohKEoXyDYc9iDAyghQIu8xHntxzJkSR3S5gD90cgKTVv54HiqD CvWhylt1LxKSo1Z/0mM7nHXlbSAxpxfiji7Zs4wMdUk82u3ID4Qv4n2ICCT3eAUoFmP7 +25qGBPm+T+X6VJMDthdsRFFWB2pEJk0Om4M1phbfDZpG9XQfct8/IYzcWCinNd8Rvl1 PHrI9jqRoMP8UMLQiiu81d9YHtIiX1hU09brDkLRWRkthXTJYpyNd5mmKe4sQ8EXkEmx g8goo91S2qbUOpAJ6iPZRvFEfyiDApA9wKGs0gyReeng/dYAyEifmcvWoZ/2py58CPXg K4wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=BRlg1JX7zgQoBm1Rlwlnadnt2t4Rx8DI7ISKGntCIRQ=; b=0TnQxTsjw4V9Ur5y5xvdTDYGh/Ff1f+I0yCmdefc0+tUV5fF6kkVOOGI/FUepDBYZK v0FSrcgMA7VsUqwVgIEo8MFmHRrWerC9NSMvZpGTSoVCY9OT+4ss+T8k0SOwlU9sRaSA ILTylqwhiU2MaHX4F2KE6vib/X7lmGFx6+As9VClSFFvjN6iGaaiXRkp1w8zYNGuhKFp P6+yGR2EtyaiCI4vhBpLWCggCJKn3bElHPJ9f+CN6SeJ11sz/x8Ist+RO8Gq2rJ6rVmX KISklc/AVec9PWy9FFyo97O9Af/4d7XqL/HwVvTRfCmWgosT11GbTbioVdzoIcEDGFAt cr1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=jfF9NOJW; dkim=pass header.i=@codeaurora.org header.s=default header.b=EGnk003K; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w11si3060873pgo.826.2018.03.15.00.40.32; Thu, 15 Mar 2018 00:40:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=jfF9NOJW; dkim=pass header.i=@codeaurora.org header.s=default header.b=EGnk003K; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751495AbeCOHjh (ORCPT + 99 others); Thu, 15 Mar 2018 03:39:37 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:38584 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750722AbeCOHjf (ORCPT ); Thu, 15 Mar 2018 03:39:35 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D5189607A2; Thu, 15 Mar 2018 07:39:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521099574; bh=uT0wdDdh9nl508C2AXvJupIKBZj5LCWTblj/hokOxzM=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=jfF9NOJWkJqmaYpByrllYlm7yNdSs2JNqAy4/oC/5R9ifL0TXV1JbYeLiDsPgTe6U 9fm5nACY4SAoMk4Q6YZSfkchnOaWrMGD1ezzHPpbrurURn4jTdr3J7IxOgXvT6cPW3 AA50CCoNqqUZnEDHvjOUum4ij8A/nfRM2hTUcB8Q= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [10.204.79.109] (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cpandya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B4B27603AF; Thu, 15 Mar 2018 07:39:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521099557; bh=uT0wdDdh9nl508C2AXvJupIKBZj5LCWTblj/hokOxzM=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=EGnk003Kb3pw6Tag8Bvg9iZtOdT2MTbOCOi/6Yfrgd+IjhJzxDAE7tvQ28tNqtUXW wDKRLkhZ12YPQeWJ4mO9+WGrzJ69IleZ2puhjQSefThnruBr3wovgA5GN5lu4xSE68 PmqAD2eFvA75OFZCxw9XZtOuke6bqpXWUslfsgzU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B4B27603AF Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=cpandya@codeaurora.org Subject: Re: [PATCH v2 2/2] x86/mm: implement free pmd/pte page interfaces To: Toshi Kani , mhocko@suse.com, akpm@linux-foundation.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, bp@suse.de, catalin.marinas@arm.com Cc: x86@kernel.org, wxf.wang@hisilicon.com, guohanjun@huawei.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, willy@infradead.org, linux-mm@kvack.org, stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20180314180155.19492-1-toshi.kani@hpe.com> <20180314180155.19492-3-toshi.kani@hpe.com> From: Chintan Pandya Message-ID: <14cb9fdf-25de-6519-2200-43f585b64cdd@codeaurora.org> Date: Thu, 15 Mar 2018 13:09:10 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180314180155.19492-3-toshi.kani@hpe.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/14/2018 11:31 PM, Toshi Kani wrote: > Implement pud_free_pmd_page() and pmd_free_pte_page() on x86, which > clear a given pud/pmd entry and free up lower level page table(s). > Address range associated with the pud/pmd entry must have been purged > by INVLPG. > > fixes: e61ce6ade404e ("mm: change ioremap to set up huge I/O mappings") > Signed-off-by: Toshi Kani > Cc: Michal Hocko > Cc: Andrew Morton > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: "H. Peter Anvin" > Cc: Borislav Petkov > Cc: Matthew Wilcox > Cc: > --- > arch/x86/mm/pgtable.c | 28 ++++++++++++++++++++++++++-- > 1 file changed, 26 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c > index 1eed7ed518e6..34cda7e0551b 100644 > --- a/arch/x86/mm/pgtable.c > +++ b/arch/x86/mm/pgtable.c > @@ -712,7 +712,22 @@ int pmd_clear_huge(pmd_t *pmd) > */ > int pud_free_pmd_page(pud_t *pud) > { > - return pud_none(*pud); > + pmd_t *pmd; > + int i; > + > + if (pud_none(*pud)) > + return 1; > + > + pmd = (pmd_t *)pud_page_vaddr(*pud); > + > + for (i = 0; i < PTRS_PER_PMD; i++) > + if (!pmd_free_pte_page(&pmd[i])) This is forced action and no optional. Also, pmd_free_pte_page() doesn't return 0 in any case. So, you may remove _if_ ? > + return 0; > + > + pud_clear(pud); > + free_page((unsigned long)pmd); > + > + return 1; > } > > /** > @@ -724,6 +739,15 @@ int pud_free_pmd_page(pud_t *pud) > */ > int pmd_free_pte_page(pmd_t *pmd) > { > - return pmd_none(*pmd); > + pte_t *pte; > + > + if (pmd_none(*pmd)) This should also check if pmd is already huge. Same for pud ? > + return 1; > + > + pte = (pte_t *)pmd_page_vaddr(*pmd); > + pmd_clear(pmd); > + free_page((unsigned long)pte); > + > + return 1; > } > #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */ > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel > Chintan -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project