Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp495046pxy; Wed, 5 May 2021 07:13:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwelCvwI68I6XQO6PGxk3d01XNtMkKAQaiCRUBgcflOvV5ZNrVWXSBkJ5TZInS+hxhC9zVJ X-Received: by 2002:a17:906:94cd:: with SMTP id d13mr27070249ejy.478.1620223995962; Wed, 05 May 2021 07:13:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620223995; cv=none; d=google.com; s=arc-20160816; b=UaAHRrCmCFN2rnZ+gyF0ACJPVHsmN4hLkKVUcURZx5xjs5VKBzgO3ylRv3SUNfhSXq fW85l3nJBgEinTgoikxjZrDihqU/Xu0tkpesQFui1dfw+kVk+86wQYU5HmR01IAymB0h 1X6BNkXxQ4X1a8kXYdABz0mh38Z/VevOqQrRWFbP+ZviZgTa32Vt6jQU9YGW/ZH5nHxt hS4X7zZVwRImFzChM2/YExxc5IPZyrlzm6GXOboWPD9WN5gUdC3HFJqAfGiEXaxyapRS s+yZoJJI+XQWwRiSoKWtpNfxJWfy63A9U66Ppek2cW6P7xjC3/lHdEm97psg06XoACui IJCA== 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=RCnOPkMC/G1Vcdql+vcGlBPx7y6AVxksEchUg4RxzkQ=; b=FFXxPFm8tCGBqqUMrHSlx+2QNyuUded5vCe5iMDlprogfR7pmwXYuBSWqfegQs08H+ XneEwxIWCwi+rd70509sGH4XgwtoJDDDpvNVXyGxA+ZEa/UKPiWhev+wM8Lv8ziRjII+ nHodEW3A7b9JPn05u/fjJ7FPp/i2s1icXakwomLoqBz6xwU6csBMkwV2QtvQgnOz4eeK WkQ4tU8F4lHAfF55rhD2VMOZwQz9CGWca6MUmeNzoXPbmvKERyQKE5/mwXCp7V9U1cXk 7kYiLM3IKXUadxrXJLdyVR07cau51Fv4jclITBaxvRw9DLYWrjj4oOtYCUweDvq5C4vn LNSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=HfZvW5qU; 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 y100si9994880ede.376.2021.05.05.07.12.47; Wed, 05 May 2021 07:13:15 -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=HfZvW5qU; 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 S233192AbhEENLW (ORCPT + 99 others); Wed, 5 May 2021 09:11:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230208AbhEENLV (ORCPT ); Wed, 5 May 2021 09:11:21 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57A86C061574; Wed, 5 May 2021 06:10:25 -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=RCnOPkMC/G1Vcdql+vcGlBPx7y6AVxksEchUg4RxzkQ=; b=HfZvW5qU94p4oR2x4wqzGUPz2C oUXMRaZvZIiKUS0yu7zzm9G8JgWZKmdwbOIuReAcoiBJNS2SeFYoosJWcnydI27HD4ZLYn9SYeL+W BXZkVVtX1MN8k7232jA7Vj7pPv3nuhhdRuDgOeHiiLjJL1JXEbaWaNfMo7MjFV2tnhF5jbwLGzGt2 wmR6p75zHIsBDQ6GkXyT+tVRkvbmuibjXvIdM08ySYeuUagX9MzvqKuyg3r5tV41aIUFmF2iBKqPj xYjLfvxZhXqEqjKGsPw88JEHUSK7oFKjoAGuz41FoVzkFAnbsvnonAkNYrS0LgisF2C8ubNhwx4pz s5bxp44g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1leHHB-000LZH-U8; Wed, 05 May 2021 13:09:36 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id CAC99300103; Wed, 5 May 2021 15:09:12 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 5B8FB203E67C5; Wed, 5 May 2021 15:09:12 +0200 (CEST) Date: Wed, 5 May 2021 15:09:12 +0200 From: Peter Zijlstra To: Mike Rapoport Cc: 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 3/9] x86/mm/cpa: Add grouped page allocations Message-ID: References: <20210505003032.489164-1-rick.p.edgecombe@intel.com> <20210505003032.489164-4-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:08:27PM +0300, Mike Rapoport wrote: > On Tue, May 04, 2021 at 05:30:26PM -0700, Rick Edgecombe wrote: > > For x86, setting memory permissions on the direct map results in fracturing > > large pages. Direct map fracturing can be reduced by locating pages that > > will have their permissions set close together. > > > > Create a simple page cache that allocates pages from huge page size > > blocks. Don't guarantee that a page will come from a huge page grouping, > > instead fallback to non-grouped pages to fulfill the allocation if > > needed. Also, register a shrinker such that the system can ask for the > > pages back if needed. Since this is only needed when there is a direct > > map, compile it out on highmem systems. > > I only had time to skim through the patches, I like the idea of having a > simple cache that allocates larger pages with a fallback to basic page > size. > > I just think it should be more generic and closer to the page allocator. > I was thinking about adding a GFP flag that will tell that the allocated > pages should be removed from the direct map. Then alloc_pages() could use > such cache whenever this GFP flag is specified with a fallback for lower > order allocations. That doesn't provide enough information I think. Removing from direct map isn't the only consideration, you also want to group them by the target protection bits such that we don't get to use 4k pages quite so much.