From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEDDEC433ED for ; Thu, 6 May 2021 18:01:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 25D8061107 for ; Thu, 6 May 2021 18:01:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25D8061107 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 656A96B006C; Thu, 6 May 2021 14:01:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 606AB6B006E; Thu, 6 May 2021 14:01:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A6DD6B0070; Thu, 6 May 2021 14:01:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id 2E1316B006C for ; Thu, 6 May 2021 14:01:27 -0400 (EDT) Received: from smtpin34.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D42325923C1B for ; Thu, 6 May 2021 18:01:26 +0000 (UTC) X-FDA: 78111573372.34.E1BF2EF Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP id 1469A801A817 for ; Thu, 6 May 2021 17:59:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Myawrg/Eh1KKgeTyc8ETEcq2kjGMoYOMLzTzDqOVZ8M=; b=e1iQYj3+gozYvU6ezrdcNd1QV7 1igZVEJMBjQgsXbWw3o1LId2dxXxUwIzERDtwbZH9np9H49DxNcTZP5rOtEiNy8Qk6136BD3b6aEm TIRQ7A7IMFbPVndkLVi2JlngFtakfotDoxPUyutj+vRgEZwNTuBedmr3LWgzE2GEZ8cNke/KUl/1E R3208cffmARKSrUwB5+AoKN3AHMAqaw+11+4GAWO0Ip5IvUOI8XKIGHvCZI+s6Pyf1hxvY/11fNZU mlQ2ghYICxRp7q7xrCk/xA/nPJh91+pNNa+HZJ1n6Skwmg9chI1VSPLgi8i6D01lh9y8U6D/ebs2Y ewi8ZWdQ==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1leiHO-0023DI-4n; Thu, 06 May 2021 17:59:42 +0000 Date: Thu, 6 May 2021 18:59:18 +0100 From: Matthew Wilcox To: Mike Rapoport Cc: Peter Zijlstra , Rick Edgecombe , dave.hansen@intel.com, luto@kernel.org, linux-mm@kvack.org, x86@kernel.org, akpm@linux-foundation.org, linux-hardening@vger.kernel.org, kernel-hardening@lists.openwall.com, ira.weiny@intel.com, dan.j.williams@intel.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC 5/9] x86, mm: Use cache of page tables Message-ID: <20210506175918.GC388843@casper.infradead.org> References: <20210505003032.489164-1-rick.p.edgecombe@intel.com> <20210505003032.489164-6-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 1469A801A817 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=e1iQYj3+; dmarc=none; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam04 X-Stat-Signature: ghrwdc96oj1uadsaty4dihoii8qewqfd Received-SPF: none (infradead.org>: No applicable sender policy available) receiver=imf27; identity=mailfrom; envelope-from=""; helo=casper.infradead.org; client-ip=90.155.50.34 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620323993-950701 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, May 05, 2021 at 03:09:09PM +0300, Mike Rapoport wrote: > On Wed, May 05, 2021 at 10:51:55AM +0200, Peter Zijlstra wrote: > > On Tue, May 04, 2021 at 05:30:28PM -0700, Rick Edgecombe wrote: > > > @@ -54,6 +98,8 @@ void ___pte_free_tlb(struct mmu_gather *tlb, struct page *pte) > > > { > > > pgtable_pte_page_dtor(pte); > > > paravirt_release_pte(page_to_pfn(pte)); > > > + /* Set Page Table so swap knows how to free it */ > > > + __SetPageTable(pte); > > > paravirt_tlb_remove_table(tlb, pte); > > > } > > > > > > @@ -70,12 +116,16 @@ void ___pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd) > > > tlb->need_flush_all = 1; > > > #endif > > > pgtable_pmd_page_dtor(page); > > > + /* Set Page Table so swap nows how to free it */ > > > + __SetPageTable(virt_to_page(pmd)); > > > paravirt_tlb_remove_table(tlb, page); > > > } > > > > > > #if CONFIG_PGTABLE_LEVELS > 3 > > > void ___pud_free_tlb(struct mmu_gather *tlb, pud_t *pud) > > > { > > > + /* Set Page Table so swap nows how to free it */ > > > + __SetPageTable(virt_to_page(pud)); > > > paravirt_release_pud(__pa(pud) >> PAGE_SHIFT); > > > paravirt_tlb_remove_table(tlb, virt_to_page(pud)); > > > } > > > @@ -83,6 +133,8 @@ void ___pud_free_tlb(struct mmu_gather *tlb, pud_t *pud) > > > #if CONFIG_PGTABLE_LEVELS > 4 > > > void ___p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d) > > > { > > > + /* Set Page Table so swap nows how to free it */ > > > + __SetPageTable(virt_to_page(p4d)); > > > paravirt_release_p4d(__pa(p4d) >> PAGE_SHIFT); > > > paravirt_tlb_remove_table(tlb, virt_to_page(p4d)); > > > } > > > > This, to me, seems like a really weird place to __SetPageTable(), why > > can't we do that on allocation? > > We call __ClearPageTable() at pgtable_pxy_page_dtor(), so at least for pte > and pmd we need to somehow tell release_pages() what kind of page it was. One of the things I've been thinking about doing is removing the pgtable dtors and instead calling the pgtable dtor in __put_page() if PageTable(). Might work nicely with this ...