Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3864978imm; Mon, 17 Sep 2018 04:36:05 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaiKLFEXIaxnvtACFHYN5KDwF8FDglhDNn6/cMa4FL4MEUPhoUl+vrtJasrlU7eGVqyApon X-Received: by 2002:a17:902:ab94:: with SMTP id f20-v6mr24685400plr.231.1537184165732; Mon, 17 Sep 2018 04:36:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537184165; cv=none; d=google.com; s=arc-20160816; b=Y/UMGpMAaw2ba0ILuVfc9vvWuEWal7Wyc1ExcRpmm1jqh9Zjf759YB223jmX0l5t8g Aw6pboNpt1DJ9d5065vMMohpgxhoeVgIyAc9uhbEnMuOyhNQJ9/CyzZJ9QrOH1XGG2J4 pl35jZoviah326BZSRp7m61Pe7rs0R6u0piBge47Ck68A4jycUVSEB74CXTbbF2AlqHU UptVNNWTm8h3PIpy5oNEkH6Qrj88i2+QqqLuQdo3I8fCrOqxBnkjvZZqcme6GpZ6DpEZ N8S/OsiI1JdDCbDxE/EpwieqD0G2C2rWws5aSM6j2okrNaBXYYUrtMhbxG5KmJfcninT 37/A== 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=pYBeQojZL2+fMhuv3tZdDW8upEdQQVvrI0E8HE248Os=; b=ANs/z0tNGvW9g2MNRVCdTUxJWZPcBn+uSLON8L4NioD4qowPsu8olxpHiBg/k5V6ak lhjMZAYJ8cMvzHwkI0CsyEc9Itf8ISYVaVCbX6ZOwkR5itKHhljU1en/sLrE7r8cuX2Z 8SSS9xnT38LhSa7PfOvMj8ekgNyeYNn49fGdH0eCCY3Z/jqJm99d/FKR7G02cO2GL1ql ao6C8rWbiNzEwwjl2MqCj7IGaHIR+OdEsaZ8rF9yY08AhggcPEeD1BdPMhS67qmnJboJ zg3zKVrrBcXGE5L2QRBxtEFX2IN8tfzXqTpfJZyEg8iKL6SVmY3DIb1yLE9zGNXnJOrD e0wA== 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 o20-v6si16628308pgn.66.2018.09.17.04.35.08; Mon, 17 Sep 2018 04:36:05 -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 S1728261AbeIQRAF (ORCPT + 99 others); Mon, 17 Sep 2018 13:00:05 -0400 Received: from foss.arm.com ([217.140.101.70]:57758 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727299AbeIQRAE (ORCPT ); Mon, 17 Sep 2018 13:00:04 -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 3D59380D; Mon, 17 Sep 2018 04:33:10 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0E3913F5BD; Mon, 17 Sep 2018 04:33:10 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 979D01AE2F82; Mon, 17 Sep 2018 12:33:28 +0100 (BST) Date: Mon, 17 Sep 2018 12:33:28 +0100 From: Will Deacon To: "Kani, Toshi" Cc: "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "tglx@linutronix.de" , "cpandya@codeaurora.org" , "Hocko, Michal" , "akpm@linux-foundation.org" Subject: Re: [PATCH 1/5] ioremap: Rework pXd_free_pYd_page() API Message-ID: <20180917113328.GC22717@arm.com> References: <1536747974-25875-1-git-send-email-will.deacon@arm.com> <1536747974-25875-2-git-send-email-will.deacon@arm.com> <71baefb8e0838fba89ee06262bbb2456e9091c7a.camel@hpe.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 14, 2018 at 09:10:49PM +0000, Kani, Toshi wrote: > On Fri, 2018-09-14 at 14:36 -0600, Toshi Kani wrote: > > On Wed, 2018-09-12 at 11:26 +0100, Will Deacon wrote: > > > The recently merged API for ensuring break-before-make on page-table > > > entries when installing huge mappings in the vmalloc/ioremap region is > > > fairly counter-intuitive, resulting in the arch freeing functions > > > (e.g. pmd_free_pte_page()) being called even on entries that aren't > > > present. This resulted in a minor bug in the arm64 implementation, giving > > > rise to spurious VM_WARN messages. > > > > > > This patch moves the pXd_present() checks out into the core code, > > > refactoring the callsites at the same time so that we avoid the complex > > > conjunctions when determining whether or not we can put down a huge > > > mapping. > > > > > > Cc: Chintan Pandya > > > Cc: Toshi Kani > > > Cc: Thomas Gleixner > > > Cc: Michal Hocko > > > Cc: Andrew Morton > > > Suggested-by: Linus Torvalds > > > Signed-off-by: Will Deacon > > > > Yes, this looks nicer. > > > > Reviewed-by: Toshi Kani > > Sorry, I take it back since I got a question... > > +static int ioremap_try_huge_pmd(pmd_t *pmd, unsigned long addr, > > + unsigned long end, phys_addr_t > phys_addr, > > + pgprot_t prot) > > +{ > > + if (!ioremap_pmd_enabled()) > > + return 0; > > + > > + if ((end - addr) != PMD_SIZE) > > + return 0; > > + > > + if (!IS_ALIGNED(phys_addr, PMD_SIZE)) > > + return 0; > > + > > + if (pmd_present(*pmd) && !pmd_free_pte_page(pmd, addr)) > > + return 0; > > Is pm_present() a proper check here? We probably do not have this case > for iomap, but I wonder if one can drop p-bit while it has a pte page > underneath. For ioremap/vunmap the pXd_present() check is correct, yes. The vunmap() code only ever clears leaf entries, leaving table entries intact. If it did clear table entries, you'd be stuck here because you wouldn't have the address of the table to free. If somebody called pmd_mknotpresent() on a table entry, we may run into problems, but it's only used for huge mappings afaict. Will