Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2930528imm; Thu, 24 May 2018 19:17:01 -0700 (PDT) X-Google-Smtp-Source: AB8JxZryuxkdac/RWRVIj7P663ew9SV17wnU6bqZnnzyBNC+wrMSW9yW8D/GZDLo5xQAmv9KnY62 X-Received: by 2002:a62:7682:: with SMTP id r124-v6mr541160pfc.80.1527214621486; Thu, 24 May 2018 19:17:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527214621; cv=none; d=google.com; s=arc-20160816; b=SrtwzzAc2Sl53Gp7MiLxq3E+g5dw2TIVFzKnzkfeynt5R1u68DEkC4ZxPZWKYoW71I 7zKdwr0eit3fzNF8kjASFsscd7s+Q7BNOG9LjNv9dD28QdAEwKEUdvyIe+GUlKwmYq2c EPkToXNmP5wseGegJx4q8xm7avuv/fbbGnlsF/MLXNs4hZ0eJsoqdva6A5HqSjYPMp4m 1i+2E8TqR92JaVxNXvJkI6AGWTxWicWFUp0kRhPUfVvNtM9BM2H8vPZlGkaMF0nIHO82 L1pWARxaqzhm3/vpJZXDpYllTmW1EClAxt/9FUZ5X/emRvYmvHuMi6A692Olw+C3pQZL gfCQ== 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=xxNLeWR5Z4IgplcqoiEIXmrNUepzdm5yF4y9MWbkwQI=; b=lE/0GD0nLxhDg3NaeRPQKZWnth/yRkHssZflRR97tQfXbqqW3cgba6TsY2MhIVkfrH U6kpwFTZgCKlM/FlNqXlcbs1WA2Hie6Tit/Oik3hLMJoVC5YkXXOBHjD8piyLQ9zAYWI CP0HnFywHD0GxdrjzCaYvxExbBo31qntdAPVISZXo+24X3f7ZnoXis0akhwlbkHc7b9q QaWrINwfKfzxeM5bw0237F63p6gGLL0ydB+ma6f6BjAlXZIeoR1VHA6x0ykix16UWEFY 18YfOPJtUjv2IG4E9x5QpxmaCfsn8BgLZlWp8XRDeRle/suT1vP2xHXjIfEzoWwR53yT oyjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=DzO4IZiC; dkim=pass header.i=@codeaurora.org header.s=default header.b=bl59iZ3M; 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 n1-v6si22239811pld.188.2018.05.24.19.16.46; Thu, 24 May 2018 19:17:01 -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=DzO4IZiC; dkim=pass header.i=@codeaurora.org header.s=default header.b=bl59iZ3M; 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 S970613AbeEXO7m (ORCPT + 99 others); Thu, 24 May 2018 10:59:42 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:54444 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966726AbeEXO7j (ORCPT ); Thu, 24 May 2018 10:59:39 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 9F20660392; Thu, 24 May 2018 14:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527173978; bh=VQczlpN+0OAVnSpEii12l9hfgU3G5viuUtIngEOGmPs=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=DzO4IZiC+UnbnZYMGucwU7kdVNRff9qXAfDV5qu12YZkFWRVf4le/yWCH7ERGZP3/ E/F7Hkjo5n2gChwOqWht1Xcihcrxs2gJlaPOzoFDcD+R1ZSnfu6EKX5f8xlbo2bln/ 7paI+ngV9yqSNAtpuwlNG0CHdd5LPfgSSAcYDDmc= 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 [192.168.0.178] (unknown [183.83.195.189]) (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 1D99C60262; Thu, 24 May 2018 14:59:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527173977; bh=VQczlpN+0OAVnSpEii12l9hfgU3G5viuUtIngEOGmPs=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=bl59iZ3M874Bos7vpx4eV3LjkapxDP8Ps/n3i5/BuMc8rk7fM9WrpS5NgcoREzub0 05B9CzMGJt1JotQ2udwaar7NVlvA2xH1fopDbt3V4OqO8KUhqxAxqMKJYXT90WGbQ5 4n529+9F0fpEMV7hNDCHW3EpJhZCRRukZeg6/+fQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 1D99C60262 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 v10 3/4] arm64: Implement page table free interfaces To: will.deacon@arm.com, catalin.marinas@arm.com, mark.rutland@arm.com, labbott@redhat.com, akpm@linux-foundation.org Cc: toshi.kani@hpe.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <1527170250-5291-1-git-send-email-cpandya@codeaurora.org> <1527170250-5291-4-git-send-email-cpandya@codeaurora.org> From: Chintan Pandya Message-ID: <9cecab0d-3045-39dd-638e-59e4e951d23a@codeaurora.org> Date: Thu, 24 May 2018 20:29:31 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1527170250-5291-4-git-send-email-cpandya@codeaurora.org> 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 5/24/2018 7:27 PM, Chintan Pandya wrote: > Implement pud_free_pmd_page() and pmd_free_pte_page(). > > Implementation requires, > 1) Clearing off the current pud/pmd entry > 2) Invalidate TLB which could have previously > valid but not stale entry > 3) Freeing of the un-used next level page tables > > Signed-off-by: Chintan Pandya > --- > arch/arm64/mm/mmu.c | 34 ++++++++++++++++++++++++++++++---- > 1 file changed, 30 insertions(+), 4 deletions(-) > > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > index da98828..17d9282 100644 > --- a/arch/arm64/mm/mmu.c > +++ b/arch/arm64/mm/mmu.c > @@ -45,6 +45,7 @@ > #include > #include > #include > +#include > > #define NO_BLOCK_MAPPINGS BIT(0) > #define NO_CONT_MAPPINGS BIT(1) > @@ -973,12 +974,37 @@ int pmd_clear_huge(pmd_t *pmdp) > return 1; > } > > -int pud_free_pmd_page(pud_t *pud, unsigned long addr) > +int pmd_free_pte_page(pmd_t *pmdp, unsigned long addr) > { > - return pud_none(*pud); > + pmd_t *table; > + pmd_t pmd; > + > + pmd = READ_ONCE(*pmdp); > + if (pmd_present(pmd)) { > + table = __va(pmd_val(pmd)); > + pmd_clear(pmdp); > + __flush_tlb_kernel_pgtable(addr); > + pte_free_kernel(NULL, (pte_t *) table); > + } > + return 1; > } > > -int pmd_free_pte_page(pmd_t *pmd, unsigned long addr) > +int pud_free_pmd_page(pud_t *pudp, unsigned long addr) > { > - return pmd_none(*pmd); > + pmd_t *table; > + pud_t pud; > + int i = 0; > + > + pud = READ_ONCE(*pudp); > + if (pud_present(pud)) { > + table = __va(pud_val(pud)); > + do { > + pmd_free_pte_page(&table[i], addr + (i * PMD_SIZE)); > + } while (i++, i < PTRS_PER_PMD); Hi Will, Right after sending these patches, I realized that do-while condition can be made to look like what we see in ioremap/vmalloc code. I guess, that's what you suggested. So, I'll raise v11 fixing that. Any more concerns ? > + > + pud_clear(pudp); > + __flush_tlb_kernel_pgtable(addr); > + pmd_free(NULL, table); > + } > + return 1; > } > 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