Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2278425imm; Thu, 20 Sep 2018 10:27:52 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZbdxT1E7xSJljTU6Ka5RpqcgpFjTRsAn1bBbe5WyJyJFa5Edek8C8vDI25QKZmv3kTXme+ X-Received: by 2002:a63:6746:: with SMTP id b67-v6mr2034637pgc.310.1537464472434; Thu, 20 Sep 2018 10:27:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537464472; cv=none; d=google.com; s=arc-20160816; b=Kiiqad3DnlWERjHeJBamZgw0qK0I/zWvw2u7A82/f+YpPqxvnR3diu+pA3ntxe3Ifx pW9uGXyWsgZhCPzZPs03ovVnQ6HL2NCVDblDuRLgI27BrhmZzmW1xD3Fi+LT9PCcjH7E 9iyXJ5IJHdmqlwi4cyiaQz3z8P9dZsOE8+pBQIZWGDy6DXRClr0ZPZdJMtN31eT9Mf1x RV3Ls6nQYbElK7U1eo4yWRVMCkR0DQBxDjGq0KggR9hN/WVpVUXkwyZTV+URc6PT13IA Hj8vG3JudKGmdQypV1kZjRQojgzkZHhJu5kAck85yVOdmwi3L8Kr6KFjp1wEyWxwD/PG prGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=xxtGwpm1HwUNipY1U3lX8H9+RsjkdLpeRLYyJHzHza4=; b=as7Cqj315tWexAILtoQ/7Xa7uhTFATZgXkpjghLxn++Hswu75yGO1cCx+kzRBfu9O0 68yjd0PfkJw7Sz7ZJTL6hlabY6mpokvoBpdyk51RfiBatDhnZ0z00jHx5n2QR0hPA7i5 suXzBt9fYho0bCdBuq3VD7KoqKBRLRg8rkikn+u9VzfDgmliXqeYZOcS/L5LxauhqVMY sli6/0hUZMb7C+i7CpK/rLMcTv3ILhBtcBctNC/XsUX59TpFWUgfePj8uoieWXSKmrXv lKjQzpm/+X5QompM5awiCK9iEPGXIdNJcoJXxuN/plBToMIFFyb5zcCQKhGT3Te0Q/Zq qgng== ARC-Authentication-Results: i=1; mx.google.com; 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 t1-v6si1561748pgf.262.2018.09.20.10.27.34; Thu, 20 Sep 2018 10:27:52 -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; 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 S1733117AbeITXKD (ORCPT + 99 others); Thu, 20 Sep 2018 19:10:03 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:50388 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731448AbeITXKD (ORCPT ); Thu, 20 Sep 2018 19:10:03 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 099871596; Thu, 20 Sep 2018 10:25:33 -0700 (PDT) Received: from arrakis.emea.arm.com (arrakis.Emea.Arm.com [10.4.12.129]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A994F3F557; Thu, 20 Sep 2018 10:25:31 -0700 (PDT) Date: Thu, 20 Sep 2018 18:25:29 +0100 From: Catalin Marinas To: Chintan Pandya Cc: will.deacon@arm.com, mark.rutland@arm.com, akpm@linux-foundation.org, linux-arm-kernel@lists.infradead.org, toshi.kani@hpe.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v13 3/3] arm64: Implement page table free interfaces Message-ID: <20180920172527.GB18934@arrakis.emea.arm.com> References: <1528268481-19299-1-git-send-email-cpandya@codeaurora.org> <1528268481-19299-4-git-send-email-cpandya@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1528268481-19299-4-git-send-email-cpandya@codeaurora.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Chintan, On Wed, Jun 06, 2018 at 12:31:21PM +0530, Chintan Pandya wrote: > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > index 8ae5d7a..65f8627 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) > @@ -977,12 +978,51 @@ 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); > + pte_t *table; > + pmd_t pmd; > + > + pmd = READ_ONCE(*pmdp); > + > + /* No-op for empty entry and WARN_ON for valid entry */ > + if (!pmd_present(pmd) || !pmd_table(pmd)) { > + VM_WARN_ON(!pmd_table(pmd)); > + return 1; > + } What's this VM_WARN_ON supposed to do here? If the pmd is 0, we trigger it all the time. Did you actually mean something like: VM_WARN_ON(!pmd_none(pmd)); or pmd_present(pmd)? Since the comment mentions empty entry, I'd rather make it explicit: if (pmd_none(pmd) || !pmd_table(pmd)) VM_WARN_ON(!pmd_none(pmd)); return 1; } Similarly for the pud_free_pmd_page(): ----------8<-------------------------- diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 65f86271f02b..2662937ef879 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -986,8 +986,8 @@ int pmd_free_pte_page(pmd_t *pmdp, unsigned long addr) pmd = READ_ONCE(*pmdp); /* No-op for empty entry and WARN_ON for valid entry */ - if (!pmd_present(pmd) || !pmd_table(pmd)) { - VM_WARN_ON(!pmd_table(pmd)); + if (pmd_none(pmd) || !pmd_table(pmd)) { + VM_WARN_ON(!pmd_none(pmd)); return 1; } @@ -1008,8 +1008,8 @@ int pud_free_pmd_page(pud_t *pudp, unsigned long addr) pud = READ_ONCE(*pudp); /* No-op for empty entry and WARN_ON for valid entry */ - if (!pud_present(pud) || !pud_table(pud)) { - VM_WARN_ON(!pud_table(pud)); + if (pud_none(pud) || !pud_table(pud)) { + VM_WARN_ON(!pud_none(pud)); return 1; }