Received: by 10.213.65.68 with SMTP id h4csp178181imn; Tue, 20 Mar 2018 00:08:02 -0700 (PDT) X-Google-Smtp-Source: AG47ELuPIfZ625CQq3EVWWZsCG/VvO0/snDxSq8kw2puujaBXnEImCjwIXlwDFVYV6+1bSZISbLp X-Received: by 2002:a17:902:24a5:: with SMTP id w34-v6mr15345484pla.328.1521529681999; Tue, 20 Mar 2018 00:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521529681; cv=none; d=google.com; s=arc-20160816; b=Aqx6ojwhhdkNpYEvpgBkEK5EMiydrTuAGti1yJwwW/UvudSFHVQXElw6OyP3Bus8Lq Fina55OoPXnbI1/um/z5GrwQ+H8Ty0zeX2tWo38ebfmdIx4rmq7pjw6+N/3BrTtxvH1b WjdgTVO+QZFvVnfPhCnqgqyFI/FskIaRC1oclrbupYVPtYCbpjEtbEsQ9qdAOGFfMWFX WViEI9joAX5nomZJ1VFuCqKrPbZAizygbxPRYdUpWBIuOKHMzPF16NRyZQmY7egMiiDK atYeMVaZ8fQS9dHlOJxTU+mXI8A086nEz1FnYcda3RwYyAv2cEqZ/SyrGeLaCPacVeSH nO3w== 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=2oF289IOF/tqxW3h0H4piUKvRu8YmDjOt7Kt3fM/ejo=; b=WFG9ah8sOjH1VOiMjXgw1032gRH89Zn67C6uPOwa3Gu7qjOZT9M7rQ+SRJqCpW5jPC zt9sfUUz2khsq2Jyosuu7CitzTLtpe8w+trOIhVkImHclzQWQiqU59kttV8sRzbZBb2p wjoL6aU3YqyPDeKSSCiKUN/TlX/WvlcT8jM2h8pNMFcthLFLA2xSeYKe24x5kGq80VHj N37LxwbKQJXkIFTL2zz8vJTN3fBPgoECPxalNFeKnEvwhWKLWJNzX+Ys6ATVGvjV4fYB 3WlpvhImKTS1dE6hWu2FXFlSeS1s1jmwdueTI0hVyP5zUazTw0802vlhssDSf6JwT0C/ nULw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=VVQc3Er0; dkim=pass header.i=@codeaurora.org header.s=default header.b=ENvVdtCi; 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 f33-v6si1007659plb.482.2018.03.20.00.07.47; Tue, 20 Mar 2018 00:08: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=VVQc3Er0; dkim=pass header.i=@codeaurora.org header.s=default header.b=ENvVdtCi; 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 S1751475AbeCTHGY (ORCPT + 99 others); Tue, 20 Mar 2018 03:06:24 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:53818 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750888AbeCTHGW (ORCPT ); Tue, 20 Mar 2018 03:06:22 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E20EC60F5F; Tue, 20 Mar 2018 07:06:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521529581; bh=Lm1aN9FwUIkb+hcvITQ3+D2YgWft84WS9Yw1kysMpbM=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=VVQc3Er0m6r3b+TMqF8uMf1R70FB4fUTXf8R0cAKd+cveLkmqon4qvQAcEZloj431 3g78SAGKLXNhby9fCpD+GJnpQGkhZWQKG6EvTrbYuYEcWXs5BsKJbr779m4rI6V3rE XIa5oKjx1lHl4pirbBWxqqdnQvvfIKcouMGPhNNE= 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 117DE60128; Tue, 20 Mar 2018 07:06:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521529580; bh=Lm1aN9FwUIkb+hcvITQ3+D2YgWft84WS9Yw1kysMpbM=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=ENvVdtCiJ+/SSo0tLwtU4jWg0dl6Trr+9Ztpdtrc4NwXFmuIrleLH7CGlqAMs0w2Y 4rISYLvnpOgJnkK6KCEgo4PNnfsQFCsxSSrF16PxEyQgbV0cfFvvY7OSdo9GU9er1V ZHKQnyqFOQlsdgOXhnIpBDuXi/+pRWTeVk7IUugc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 117DE60128 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 v3 2/3] arm64: Implement page table free interfaces To: "Kani, Toshi" , "mark.rutland@arm.com" , "catalin.marinas@arm.com" , "will.deacon@arm.com" Cc: "linux-kernel@vger.kernel.org" , "ard.biesheuvel@linaro.org" , "tglx@linutronix.de" , "takahiro.akashi@linaro.org" , "james.morse@arm.com" , "kristina.martsenko@arm.com" , "akpm@linux-foundation.org" , "gregkh@linuxfoundation.org" , "linux-arm-kernel@lists.infradead.org" , "marc.zyngier@arm.com" , "arnd@arndb.de" , "linux-arch@vger.kernel.org" References: <1521463256-19858-1-git-send-email-cpandya@codeaurora.org> <1521463256-19858-3-git-send-email-cpandya@codeaurora.org> <1521487759.2693.224.camel@hpe.com> From: Chintan Pandya Message-ID: Date: Tue, 20 Mar 2018 12:36: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: <1521487759.2693.224.camel@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/20/2018 12:59 AM, Kani, Toshi wrote: > On Mon, 2018-03-19 at 18:10 +0530, Chintan Pandya wrote: >> Implement pud_free_pmd_page() and pmd_free_pte_page(). >> >> Implementation requires, >> 1) Freeing of the un-used next level page tables >> 2) Clearing off the current pud/pmd entry >> 3) Invalidate TLB which could have previously >> valid but not stale entry >> >> Signed-off-by: Chintan Pandya >> --- >> arch/arm64/mm/mmu.c | 30 ++++++++++++++++++++++++++++-- >> 1 file changed, 28 insertions(+), 2 deletions(-) >> >> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c >> index da98828..c70f139 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) >> @@ -975,10 +976,35 @@ int pmd_clear_huge(pmd_t *pmdp) >> >> int pud_free_pmd_page(pud_t *pud, unsigned long addr) >> { >> - return pud_none(*pud); >> + pmd_t *pmd; >> + int i; >> + >> + pmd = __va(pud_val(*pud)); >> + if (pud_val(*pud)) { >> + for (i = 0; i < PTRS_PER_PMD; i++) >> + pmd_free_pte_page(&pmd[i], addr + (i * PMD_SIZE)); >> + >> + free_page((unsigned long) pmd); > > Why do you want to free this pmd page before clearing the pud entry on > this arm64 version (as it seems you intentionally changed it from the > x86 version)? It can be reused while being pointed by the pud. Same > for pmd. Noted. > >> + pud_clear(pud); >> + flush_tlb_kernel_range(addr, addr + PUD_SIZE); > > Since you purge the entire pud range here, do you still need to call > pmd_free_pte_page() to purge each pmd range? This looks very expensive. > You may want to consider if calling internal __pmd_free_pte_page() > without the purge operation works. I completely missed that. Sure, will fix this. I will upload v4 fixing all 4 comments. > > -Toshi > 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