Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1665925pxy; Thu, 6 May 2021 12:44:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5CGIRuqYrvpyLOoE8pRGEW2W9OlHG/38rQySkd+XYTOghEmipAFNmzIrTme3tbKq07zC5 X-Received: by 2002:aa7:c918:: with SMTP id b24mr7208617edt.58.1620330291088; Thu, 06 May 2021 12:44:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620330291; cv=none; d=google.com; s=arc-20160816; b=q8Q9FrwlP3adxBUPlbVSNn/IKzwh4H70gfBxJc44ozWYS6ltldByBL2cGWn2izncr7 cbyTwqi2vdBDpcPQCofNfEd5IctjX64ptk4XWxS7JQmB86gi+FxlgA8GGVX9Ho4wbek4 4WevCeA+f5spXFTKJDjZXn80gbq2nuZG5Qa3nF8AHzIHYW4uBTpTEz2LCqEQk9YaLtLq zSg5pmx228RzAj62WAJ1C0YCuaYO3zwkZo1JJH0lmlI2tTAIOnjnoOlg3dOtknovVQsa fyIc9+GVWc/4mL1hSeruwK0n+fzdBLjfZkVzEw26X/g4H+MT+MSmxMyK63+sw4NC54iL 2/bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Myawrg/Eh1KKgeTyc8ETEcq2kjGMoYOMLzTzDqOVZ8M=; b=xhKevGX3drwoRkQB0PKTj5Eqvb16waSK7YxsxabrQol3wf10yGTBWWGjd92kh16QAf lJXkU36NjBKY8C+mGDNHi60eATfFcXA3t615LK55fNgqFoXqejIJi+WfA+mVU4JY8AeP isEZhWgx+PlDNQesiicXvAF1vgrz347o6YgpK7i6SSxoOzk8+bETEm0rUxRvgj16pZWW mstpMFuRMu+XXgyyjzc8wm0PAZbPSH5636pSWxUTqYNvQAFnrZTVqzlmWup0lHxK5iba +wtsdH+zVJnF+6SkwziIlDtXclVLwkrpMJY39aB8XFGRCqWgSAdIsgVlq44lnroVkmtC iS5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=e1iQYj3+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d2si469563ejd.638.2021.05.06.12.44.26; Thu, 06 May 2021 12:44:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=e1iQYj3+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236376AbhEFSBv (ORCPT + 99 others); Thu, 6 May 2021 14:01:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236362AbhEFSBv (ORCPT ); Thu, 6 May 2021 14:01:51 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2B4DC061574; Thu, 6 May 2021 11:00:52 -0700 (PDT) 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ...