Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp708627pxy; Wed, 5 May 2021 11:47:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxlfhkCXPg1jGflWkaCA8EQLhW0jADhHWteNVy2oeImTO5ly3GpVIdIO00r1FQW+aSYWbg X-Received: by 2002:a17:90a:5602:: with SMTP id r2mr33788pjf.60.1620240463927; Wed, 05 May 2021 11:47:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620240463; cv=none; d=google.com; s=arc-20160816; b=Jtw6Sk6r2woVb9V7Wa0N2qeMLraHoX4Ri2O/HFYTjGynIr9VsCJgKpAOENFXh32qUo ECxwF/EjQZ3DCIvVu9CskdGXWqIseIPcVUzB2rpNaJSz8A7l/P4mgBc39gLZQ0zKO5lV BlteInaE8UXTPW0NCrU6u6htPnhjIIFldPosvW1j2TfJYaaSD5JjJiriUxh0rmPndYeu Vc8NnoFw2w0H7UseKW0hKd5+pgNuqiLJExtwj3JPFtAsDFk4ME0Bh3dXupQrs9sXrnVR UGie+M2lGTYDWqqW7k/+oIh+IEtCl1cAqNcpny0Iw3nJLD5ZJG4P3UdpwZP1/gLYM2K6 sJog== 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=iE9YFCbGDifoG+qG9fE8DKoC0WWDbMju88hIGkJ4VEc=; b=vkWMaO6VfFFyin+qYHpuDR+uzkMQS5MtD18gZ23h0zMNfjjzEiyw+GyLC4Wp58o/Af c/I1j1iMyGodabv+eiestqnn7yf6VqUe0bo7BC0uG2axTNBjfEGGGO6b5AFs0TVKUuzV cWlUyZHYm2O7zDG6tmzi1Rs0UWUD5ZFZzXvoOgyelN8jVrn9l6kqEyG+93dFi9k2Oluy c8CA6X77VV0zxgxPJgc9P3MSLXY1Jg8+g90TxIvhAwUd5s7ptNRweXL1iFD2V6PLK/1s Uspt0oAdj4nv40F0TwAlemst4w8fVgKPhE5Li1kwUUtji6IRyo2Oujs7mHkoTr1j+AId 7UgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=U4h+XW2J; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s19si66847pfu.44.2021.05.05.11.47.30; Wed, 05 May 2021 11:47:43 -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=@kernel.org header.s=k20201202 header.b=U4h+XW2J; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234916AbhEESqh (ORCPT + 99 others); Wed, 5 May 2021 14:46:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:38454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234475AbhEESqe (ORCPT ); Wed, 5 May 2021 14:46:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 74B9F6105A; Wed, 5 May 2021 18:45:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620240337; bh=tr9FqTMNy8Aj06BcquW7hrOWHRk5sO0oNB/v3F7fSGA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=U4h+XW2JoDzusBFB9PItP8owvyEeRbEBjS7C+MbTIM0pm8gW1/7Sgm3uiTnhr4l0q YkH7+NKvTuQC45/hUyhq5biEIbq09EV+IPth0gS+98hzzwncgLiZHExMu8vukCqhY3 PNztdmE9l2g3ophWibUn6lvKlOJe/C/11NDC6/DcaH6qcq3PN4eQP12imHVas1+rXJ gj0NfbuQ99F/T76cFFCGYkgDWsv7R4T6SZYqCncokXbBtSfHkxCpgq8repwdM9lSF8 TJJw3WF5R5H594VU3jmwl3NLWXutN9y1bHlSMTi+09MYV1ciHXSB8vuy7FJnvX+PPq LdPR40kMTc13A== Date: Wed, 5 May 2021 21:45:28 +0300 From: Mike Rapoport To: Peter Zijlstra 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:09:12PM +0200, Peter Zijlstra wrote: > 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. Unless I'm missing something we anyway hand out 4k pages from the cache and the neighbouring 4k may end up with different protections. This is also similar to what happens in the set Rick posted a while ago to support grouped vmalloc allocations: [1] https://lore.kernel.org/lkml/20210405203711.1095940-1-rick.p.edgecombe@intel.com/ -- Sincerely yours, Mike.