Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1174006pxk; Fri, 25 Sep 2020 08:03:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/CQMsRPR0Q/lYWHKmV0n2bfp7d3Kz+b3f3AMmhjmyV0xHsggPEinVkUGy7PG9mR72IgML X-Received: by 2002:a05:6402:68c:: with SMTP id f12mr1887046edy.8.1601046204379; Fri, 25 Sep 2020 08:03:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601046204; cv=none; d=google.com; s=arc-20160816; b=GXwTPed/hHsN6IQi3stP6R7pxg7vJNQqskWKhK1rInxHMzUHhhhw4Vrl4Qd2p0wPVj C28cp9npd5xYXSJEfJ0j/SoJW2dSNHjAhJTgs8F7bmwtS3f7kNyeAsy5Jp4VLAzDYWja g31GkzTX194VbcNRVtWPQDU1o5NimVrHgfLEtzuu4daIMm2gtPJACJN3MHwH9MaZ0OxF iAWdNvE5MrveRaeIhaW0rr3oKSoJnsm773Wx6nhKAU3CEVnCBtuQcoka4lIT/gVVi7Vg g7C1BmO1XKZyE6VkF2+9jwNckIx4B+FHueyi12Abc+x3QLynEgUqMcyKT0z8O4X6kAyH zoEg== 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 :dkim-signature; bh=tBfuOWmQyjKgArCfu4khNo2TUG7Jq21FgCLcBIcnmPM=; b=jjFWJEwU8OSMp0bVftQJsGwY+L9a2GgucWG8MxoL44FvhW5TZPS5yqZxeOWLS3W1ld Vbw2AOXLAdSOHg9ohW6S8KxggqvAYadLzV1vX/NtM92xEYHtSOmAzKBvfR8YYPGiWryu chywkXymYb/CIRG+TIf7CSrBEjNYP7V64sbm0g1tF9VB9F5fD1pAF5K0r9c6dMrqg9o1 qDlI0nIlk0BPXSiDTj3E9Tqo5or04l+YhyXK4kL9OVESAijmrO08+cDulnjUHiexp6yJ gX/mWkUCf9vws07T8AojAnx4PkVRTPSHHrVEOxxzDpIAlHKDcNpXzot/PS+0xtHqdrP4 9Bzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm1 header.b=OofIQppg; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=O2AlydY1; 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 uz13si1968121ejb.531.2020.09.25.08.03.00; Fri, 25 Sep 2020 08:03:24 -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=@tycho.pizza header.s=fm1 header.b=OofIQppg; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=O2AlydY1; 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 S1729077AbgIYO6C (ORCPT + 99 others); Fri, 25 Sep 2020 10:58:02 -0400 Received: from new1-smtp.messagingengine.com ([66.111.4.221]:40875 "EHLO new1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728974AbgIYO5j (ORCPT ); Fri, 25 Sep 2020 10:57:39 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 6C28D580762; Fri, 25 Sep 2020 10:57:25 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Fri, 25 Sep 2020 10:57:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho.pizza; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=tBfuOWmQyjKgArCfu4khNo2TUG7 Jq21FgCLcBIcnmPM=; b=OofIQppgkot+WhAGmGPKk5hZgjNlpN1ZlHwJkZhHUT7 KzQ9a4UKLvBtvt6IoY28ep/w/+2zSquvjNGRBmkSersamyUPK4mq6bGc213GAiGs 6eeA6co4G2jngyV6y9+g8szoci4GiiwwXywXX2pXq0HGjzmMhlmRWxQ85LK/DlDy irsPbph5wkukocpS6KgwRtiTKpYoXd3eKdxCN9qwKIkQcRRXIio+zFQ2SjqkppTg SNQPkGiduZegcLFBIHP5gJ/Op/FSZLeDDXJiOr9hfVgoldvcVMrRECA9TV6Wq7zO 8FAbll8jR/Sd8TZyP6RpX6gZdv/A69N8+b8xGORjw1A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=tBfuOW mQyjKgArCfu4khNo2TUG7Jq21FgCLcBIcnmPM=; b=O2AlydY1ltQyDVNghirgyE d0O51zrG8EUimzMadviff/NiqC0auMDDpsNj82EjtYhLCHLnvp4ul7cmJcKB4oic 8GyaGwvleCXSsdBrsydeqkvzbq2T7kD4/ki04+EPu9S3o67WbG3C4srDADzAbfLV SaqsEs/JPQPxAl+TMoyLW00k6FlCJFMhhZSC9xeH5+0jlcUcku9NsJuXufMDdzoq zdAtNnQpSuuO9acwwrKLSyqcC1vJ24Bg4hY3bq8wGRJsi/GvmWV6uSzubM/akmk0 XCtdH3b4xnADHi4BE95Cgt9gxaWKV/9k1KSsSHPJtWhz0FVMgsaL4L1E5bop9FyA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvddtgdekudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepvfihtghhohcu tehnuggvrhhsvghnuceothihtghhohesthihtghhohdrphhiiiiirgeqnecuggftrfgrth htvghrnhepgeekfeejgeektdejgfefudelkeeuteejgefhhfeugffffeelheegieefvdfg tefhnecukfhppedukeegrdduieejrddvtddruddvjeenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthigthhhosehthigthhhordhpihiiiigr X-ME-Proxy: Received: from cisco (184-167-020-127.res.spectrum.com [184.167.20.127]) by mail.messagingengine.com (Postfix) with ESMTPA id B8B0B328005D; Fri, 25 Sep 2020 10:57:18 -0400 (EDT) Date: Fri, 25 Sep 2020 08:57:17 -0600 From: Tycho Andersen To: Mark Rutland Cc: Peter Zijlstra , David Hildenbrand , Mike Rapoport , Andrew Morton , Alexander Viro , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christopher Lameter , Dan Williams , Dave Hansen , Elena Reshetova , "H. Peter Anvin" , Idan Yaniv , Ingo Molnar , James Bottomley , "Kirill A. Shutemov" , Matthew Wilcox , Mike Rapoport , Michael Kerrisk , Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Shuah Khan , Will Deacon , linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-nvdimm@lists.01.org, linux-riscv@lists.infradead.org, x86@kernel.org Subject: Re: [PATCH v6 5/6] mm: secretmem: use PMD-size pages to amortize direct map fragmentation Message-ID: <20200925145717.GA284424@cisco> References: <20200924132904.1391-1-rppt@kernel.org> <20200924132904.1391-6-rppt@kernel.org> <20200925074125.GQ2628@hirez.programming.kicks-ass.net> <8435eff6-7fa9-d923-45e5-d8850e4c6d73@redhat.com> <20200925095029.GX2628@hirez.programming.kicks-ass.net> <20200925103114.GA7407@C02TD0UTHF1T.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200925103114.GA7407@C02TD0UTHF1T.local> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 25, 2020 at 11:31:14AM +0100, Mark Rutland wrote: > Hi, > > Sorry to come to this so late; I've been meaning to provide feedback on > this for a while but have been indisposed for a bit due to an injury. > > On Fri, Sep 25, 2020 at 11:50:29AM +0200, Peter Zijlstra wrote: > > On Fri, Sep 25, 2020 at 11:00:30AM +0200, David Hildenbrand wrote: > > > On 25.09.20 09:41, Peter Zijlstra wrote: > > > > On Thu, Sep 24, 2020 at 04:29:03PM +0300, Mike Rapoport wrote: > > > >> From: Mike Rapoport > > > >> > > > >> Removing a PAGE_SIZE page from the direct map every time such page is > > > >> allocated for a secret memory mapping will cause severe fragmentation of > > > >> the direct map. This fragmentation can be reduced by using PMD-size pages > > > >> as a pool for small pages for secret memory mappings. > > > >> > > > >> Add a gen_pool per secretmem inode and lazily populate this pool with > > > >> PMD-size pages. > > > > > > > > What's the actual efficacy of this? Since the pmd is per inode, all I > > > > need is a lot of inodes and we're in business to destroy the directmap, > > > > no? > > > > > > > > Afaict there's no privs needed to use this, all a process needs is to > > > > stay below the mlock limit, so a 'fork-bomb' that maps a single secret > > > > page will utterly destroy the direct map. > > > > > > > > I really don't like this, at all. > > > > > > As I expressed earlier, I would prefer allowing allocation of secretmem > > > only from a previously defined CMA area. This would physically locally > > > limit the pain. > > > > Given that this thing doesn't have a migrate hook, that seems like an > > eminently reasonable contraint. Because not only will it mess up the > > directmap, it will also destroy the ability of the page-allocator / > > compaction to re-form high order blocks by sprinkling holes throughout. > > > > Also, this is all very close to XPFO, yet I don't see that mentioned > > anywhere. > > Agreed. I think if we really need something like this, something between > XPFO and DEBUG_PAGEALLOC would be generally better, since: Perhaps we can brainstorm on this? XPFO has mostly been abandoned because there's no good/safe way to make it faster. There was work on eliminating TLB flushes, but that waters down the protection. When I was last thinking about it in anger, it just seemed like it was destined to be slow, especially on $large_num_cores machines, since you have to flush everyone else's map too. I think the idea of "opt in to XPFO" is mostly attractive because then people only have to pay the slowness cost for memory they really care about. But if there's some way to make XPFO, or some alternative design, that may be better. Tycho