Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp974753pxk; Fri, 25 Sep 2020 02:55:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzN/gBS2HaQnBa2EAHyck4tPVzxQX/GZOYBmHsIzWLlZ/S8hW4+J1AixkgIMUlBiMf59UcS X-Received: by 2002:a17:907:2139:: with SMTP id qo25mr1785629ejb.547.1601027701825; Fri, 25 Sep 2020 02:55:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601027701; cv=none; d=google.com; s=arc-20160816; b=Z+zuwMLPIyAA32EsfN3Qt8AahIkgqloF30d7IUWiQ48Om86HzKBAtC/VyGJROjsC4V nvOAi9PiXj4YpgkzFAWXWWfLPiHmb9U+35dYVR3T9zigtZYUXSWlExuaEacpRJAIO27S MMocfKiOCJYPZgCx4qlP5xYKMl762auwb9XwojRa8kxlzYjiiYJXw9mHukWf+OO4ewCA QiY5dmXYoruX/EV4Q0d2TiWPVM0h8Dl99L1RkFldDA0b7aLl1U1DSsc2dko3BMW6yQ0x 4UEKNaxU4CVzXYwx+fVC0lB5gKfyidsevp/1pvutHVui/3Hc0V0g3lhiJaUIMmZu0O+n C5BQ== 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=28F9ogfbtjbZVl/n21rnRnyA08/27VBA9tFd1Emv+00=; b=Gacp0QIdbCRI/QkaQQNGiExYtiEQlXMxJRS/Tz5d/BNZHwe3+zY1v9X8oA1ABS6fDE FwF8oK26llnef6jqyukyBH2PoH0tzz817JBg+tW41w4VqykKScNfI1aA8kqLyTvEvK5s C9w6zwMssIlvuOR8kjXEYMQiLKKKNP9J9hDbAN79jstr32GHv8aKoWqpojsXJZIYOMN3 3+o2SI+Ddi/UJip+MfD6QQ0mMBlY3ovPyXBfaZDKzWDPAmr8JWTlhazGjz36Kl6LtKzX /+ILNPb2NOfOZuq/cyF+VHxhpEIghftOr49xRFvC7wZRDVlIvQ5OBQwJOhso/o8cPbeI 6eUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=eDtTZJcK; 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 y6si1445217edo.322.2020.09.25.02.54.38; Fri, 25 Sep 2020 02:55:01 -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=merlin.20170209 header.b=eDtTZJcK; 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 S1728011AbgIYJu6 (ORCPT + 99 others); Fri, 25 Sep 2020 05:50:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727733AbgIYJu5 (ORCPT ); Fri, 25 Sep 2020 05:50:57 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47002C0613CE; Fri, 25 Sep 2020 02:50:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=28F9ogfbtjbZVl/n21rnRnyA08/27VBA9tFd1Emv+00=; b=eDtTZJcKIKXiogPX8IEoroVaur XW7EI4ZB21PTkWWr9eWrFNLyAkJMplmIZMrBeAnSzW1ixnZ6BrvaKgafONbS0Joxy2CeX/wnHxrF3 QqwrtXqNNoROvt9GzJImRgUczIUwWbo+Q/n6g6pLgQxTCohc5HZjzKY9ukoT8pzxVga7MCJTci00u 0GD1c38oFcQp82w8s0Sb1WyrTVLELnCaIlpKcH9QKL4xD5S/TA24mg6YoIDwpyhlh+50WQmGXx9t3 Am6sBfG2czlVMfNPRh2C6JExGJ+N5gbSe/yCFv0CGD1FP+tm8XQ/O71XwgOzhlYZ/Xlfujol8O6M7 B2891KUQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLkN6-0000zO-FY; Fri, 25 Sep 2020 09:50:32 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id D5927301A27; Fri, 25 Sep 2020 11:50:29 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id BEFA320104626; Fri, 25 Sep 2020 11:50:29 +0200 (CEST) Date: Fri, 25 Sep 2020 11:50:29 +0200 From: Peter Zijlstra To: David Hildenbrand Cc: 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 , Mark Rutland , Mike Rapoport , Michael Kerrisk , Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Shuah Khan , Tycho Andersen , 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: <20200925095029.GX2628@hirez.programming.kicks-ass.net> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8435eff6-7fa9-d923-45e5-d8850e4c6d73@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Further still, it has this HAVE_SECRETMEM_UNCACHED nonsense which is completely unused. I'm not at all sure exposing UNCACHED to random userspace is a sane idea.