Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3776651pxk; Tue, 29 Sep 2020 06:07:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxh0Ula2Io4Srnn5DsWFpox40qX9/N1t0c9xBwG1fyO2Ubcq8yqSYBQ95YDRW8tiftFW3ny X-Received: by 2002:a17:906:770c:: with SMTP id q12mr3691214ejm.518.1601384860378; Tue, 29 Sep 2020 06:07:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601384860; cv=none; d=google.com; s=arc-20160816; b=lCf7pWkJUvzVrXLfwnebZAgZV100hdFcWoTWAnfuraj3JejBFrsTCdJfpltjoBcjUu o1+0lMQ+1yLHRU06W6nCe7LBMu504OPVIskG4NPzsxmVgty8nQtVVh3lsHMaIQowCj6c c4mEUEMVfi70CGLPjsN2CNmFF9FNC6nlchf2E3QRWXa2k1afvk28HMXK31DPRRC0GPJG tUPff2rn6B+3pxZFFHVSV/A3pH3JpEJ496TIWhtxgrJBl+c2zk8Y6c56Zl1/pkBDzIWi yyinxEwno8DSo60UOyEhb1THOD4VYk9JJvA6Mw0wWGV8bW8+2lIKuYL9A9iTgVydQfZn V7GA== 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=Y4jXcnHhlTzU7/zfOVcWMF7VbPqoVFjm2MHOiddqmn0=; b=xF4BBbS+vmGGfFkypkW90i5PZ0iqZOZUQ9geKO6GO8DVC5eghSj39pp6mLEQNBjRT3 Uo+4bZvp2GhT+FwV8s4AmYYYxTWaAOsOw7PRqH8e0XYjSBtO/UNoWyMCEt9pRrLYyVNo RG/xJ7tIQD6N63GhJDpVyozwXqk6GDNrBUpqBjnbW2dt0NZOB+kFdZN1IsjM8KxGbtWf FQNc+kfDVz6qw9myyL3fxvlSGWj7myfZfnQWK/71rYJAUJKYmNWJuNRFfalxzP+ABEgf H/hFN42k1pTYhWpX3LDc2B1REN6keUollcuLw7SBc7BZtw9E9UwiCkaYUcehXCHxd9cr 4bMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="YfoO9Oo/"; 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 w12si3008837edi.441.2020.09.29.06.07.15; Tue, 29 Sep 2020 06:07:40 -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=default header.b="YfoO9Oo/"; 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 S1728797AbgI2NFr (ORCPT + 99 others); Tue, 29 Sep 2020 09:05:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:46754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728674AbgI2NFr (ORCPT ); Tue, 29 Sep 2020 09:05:47 -0400 Received: from kernel.org (unknown [87.71.73.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4CD4820848; Tue, 29 Sep 2020 13:05:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601384746; bh=w8jEjdPVhwgAP8ieOGmZq7rvrkzmFW13pl6Bcj/9DDg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YfoO9Oo/YwKl80W7Ps/3xh0cfYEHin8QOUrn/iFqhLYw+b2DAWHKu9Y+mnqgIAACA uQkYtRdB+liRGsxjQlUpAtvTPmGTHbQnf35XbZMDwXCeXkiEteBW7/GT/3ZbUZnHCL kuQnBbyQK81Mz6jqRSLbGj/2AcjW0JSpMYmSqJQw= Date: Tue, 29 Sep 2020 16:05:29 +0300 From: Mike Rapoport To: Peter Zijlstra Cc: Andrew Morton , Alexander Viro , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christopher Lameter , Dan Williams , Dave Hansen , David Hildenbrand , 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: <20200929130529.GE2142832@kernel.org> References: <20200924132904.1391-1-rppt@kernel.org> <20200924132904.1391-6-rppt@kernel.org> <20200925074125.GQ2628@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200925074125.GQ2628@hirez.programming.kicks-ass.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 25, 2020 at 09:41:25AM +0200, 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. This indeed will cause 1G pages in the direct map to be split into 2M chunks, but I disagree with 'destroy' term here. Citing the cover letter of an earlier version of this series: I've tried to find some numbers that show the benefit of using larger pages in the direct map, but I couldn't find anything so I've run a couple of benchmarks from phoronix-test-suite on my laptop (i7-8650U with 32G RAM). I've tested three variants: the default with 28G of the physical memory covered with 1G pages, then I disabled 1G pages using "nogbpages" in the kernel command line and at last I've forced the entire direct map to use 4K pages using a simple patch to arch/x86/mm/init.c. I've made runs of the benchmarks with SSD and tmpfs. Surprisingly, the results does not show huge advantage for large pages. For instance, here the results for kernel build with 'make -j8', in seconds: | 1G | 2M | 4K ----------------------+--------+--------+--------- ssd, mitigations=on | 308.75 | 317.37 | 314.9 ssd, mitigations=off | 305.25 | 295.32 | 304.92 ram, mitigations=on | 301.58 | 322.49 | 306.54 ram, mitigations=off | 299.32 | 288.44 | 310.65 All the results I have are available here: https://docs.google.com/spreadsheets/d/1tdD-cu8e93vnfGsTFxZ5YdaEfs2E1GELlvWNOGkJV2U/edit?usp=sharing The numbers suggest that using smaller pages in the direct map does not necessarily leads to performance degradation and some runs produced better results with smaller pages in the direct map. > I really don't like this, at all. > > IIRC Kirill looked at merging the directmap. I think he ran into > performance issues there, but we really need something like that before > something like this lands. -- Sincerely yours, Mike.