Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp724319pxb; Tue, 2 Feb 2021 16:46:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOdSfvp5tC/48PaSEBLwhSxKHcjSTKrhWrQxA/9Nderf5HjdXcntddjFo0gAm4OgjhBqgO X-Received: by 2002:a17:906:a153:: with SMTP id bu19mr604336ejb.287.1612313194332; Tue, 02 Feb 2021 16:46:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612313194; cv=none; d=google.com; s=arc-20160816; b=vRv93yoXkw86cUmijbUZhbItfD0grnI5dGEcFWJ6UnvjrCuaybGJ1IfR9+LjlMXoFK ZvUEcwcCxKH1vDfDXZlE/3ex2OXQrU0ez15Gn3mRRJVAhvM43/B/B9qiv9yBtOrT3qpo EyhUnybjik2h/CU2yZLHitR/e1dM06UJe3+ue+I+IL9goEZXP8XpfKmFSYxR240LxBuj 5NGi4tt/bj/50Tnhd8aAiZsdhp2RmgJyZ32xPqvPASHXAL3s7mwGidTUrJhd6smZhTZf gVY7XCVVb/uYYH6WqCbPtHDhhr63L8LzUhQynCR19gvha0ZQrjdJ77P/i5jRBlAF226+ fxhw== 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=HdjOm0U0PyBE6JlQBMpckY0IoUeGl4cGpCnJMkOpqEE=; b=SwYpsdjsIT9OFFwVcVXOpJX8LLNvHr5Ktf0Lk2S+9Ggo0Ljvi6zeWgwqw6epG9+K6k EZ8A1L7pW5VtBnZ3jU/fcuZ5sT1Lv8W8AVPQ6IEwWWUSKEFZmRNHL+AYU+VIWxBGcO5L 8mXz+2/qLJrLtZkHT4oNv4VbwcZnyuRON0IQHpPVFoUxtUiCePgSH8K7VYG4hRCnSOPr sDNXduIjfwyZgtdX6JL1r9wLt6r0wVG+itWWWzbsSM75N7E441cP+rdHlOg6vs3QgrnR iYOv/k+kj9GJePYbcDAjpbT9Pa98NFuEkVyeFMZUag+1ib9maBUj8UETcDhTY2F2dwId TH9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=urlxNYuf; 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 a66si247086edf.607.2021.02.02.16.46.10; Tue, 02 Feb 2021 16:46:34 -0800 (PST) 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=urlxNYuf; 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 S239511AbhBBTOK (ORCPT + 99 others); Tue, 2 Feb 2021 14:14:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:45758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231862AbhBBTLw (ORCPT ); Tue, 2 Feb 2021 14:11:52 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 47C6D64D87; Tue, 2 Feb 2021 19:10:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612293066; bh=Pzyl+wYYgvPCwgJ+GvBahmfBmshzS1gdeGZydw56C1k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=urlxNYufSkfJp0SH0EEfwFzSeIYwXDdueMnyILwXIullWx4SbMoEerX80f5OQqyLU Bg+fxp5cMzP5FzVAMlOPfjBauj+B1/aEKphaIK3R5lVLYCvCQesqrDIQmZvMjDXmNR wmsGMRNi9ZfDbI6vAJ5p7VMbSsLj4nb8l1NhazBIB10phtLBckQ1cOU2nN3vTXLilS uJtQ4CoJagfCIkQnsWqgtg/k3AnTkwWKwrvb5ozbBGjBggCHGi2zD+24ANJ5uL76kr bEh+jPfAk+q1UtVeseCuM6MVzwqCxfVLsegGHFyjAVr0PWSO8yZEm61pbzlwU5cRc5 HnguLQxiFymVg== Date: Tue, 2 Feb 2021 21:10:40 +0200 From: Mike Rapoport To: Michal Hocko Cc: James Bottomley , David Hildenbrand , Andrew Morton , Alexander Viro , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christopher Lameter , Dan Williams , Dave Hansen , Elena Reshetova , "H. Peter Anvin" , Ingo Molnar , "Kirill A. Shutemov" , Matthew Wilcox , Mark Rutland , Mike Rapoport , Michael Kerrisk , Palmer Dabbelt , Paul Walmsley , Peter Zijlstra , Rick Edgecombe , Roman Gushchin , Shakeel Butt , Shuah Khan , Thomas Gleixner , 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, Hagen Paul Pfeifer , Palmer Dabbelt Subject: Re: [PATCH v16 07/11] secretmem: use PMD-size pages to amortize direct map fragmentation Message-ID: <20210202191040.GP242749@kernel.org> References: <303f348d-e494-e386-d1f5-14505b5da254@redhat.com> <20210126120823.GM827@dhcp22.suse.cz> <20210128092259.GB242749@kernel.org> <73738cda43236b5ac2714e228af362b67a712f5d.camel@linux.ibm.com> <6de6b9f9c2d28eecc494e7db6ffbedc262317e11.camel@linux.ibm.com> <20210202124857.GN242749@kernel.org> 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 Tue, Feb 02, 2021 at 02:27:14PM +0100, Michal Hocko wrote: > On Tue 02-02-21 14:48:57, Mike Rapoport wrote: > > On Tue, Feb 02, 2021 at 10:35:05AM +0100, Michal Hocko wrote: > > > On Mon 01-02-21 08:56:19, James Bottomley wrote: > > > > > > I have also proposed potential ways out of this. Either the pool is not > > > fixed sized and you make it a regular unevictable memory (if direct map > > > fragmentation is not considered a major problem) > > > > I think that the direct map fragmentation is not a major problem, and the > > data we have confirms it, so I'd be more than happy to entirely drop the > > pool, allocate memory page by page and remove each page from the direct > > map. > > > > Still, we cannot prove negative and it could happen that there is a > > workload that would suffer a lot from the direct map fragmentation, so > > having a pool of large pages upfront is better than trying to fix it > > afterwards. As we get more confidence that the direct map fragmentation is > > not an issue as it is common to believe we may remove the pool altogether. > > I would drop the pool altogether and instantiate pages to the > unevictable LRU list and internally treat it as ramdisk/mlock so you > will get an accounting correctly. The feature should be still opt-in > (e.g. a kernel command line parameter) for now. The recent report by > Intel (http://lkml.kernel.org/r/213b4567-46ce-f116-9cdf-bbd0c884eb3c@linux.intel.com) > there is no clear win to have huge mappings in _general_ but there are > still workloads which benefit. > > > I think that using PMD_ORDER allocations for the pool with a fallback to > > order 0 will do the job, but unfortunately I doubt we'll reach a consensus > > about this because dogmatic beliefs are hard to shake... > > If this is opt-in then those beliefs can be relaxed somehow. Long term > it makes a lot of sense to optimize for a better direct map management > but I do not think this is a hard requirement for an initial > implementation if it is not imposed to everybody by default. > > > A more restrictive possibility is to still use plain PMD_ORDER allocations > > to fill the pool, without relying on CMA. In this case there will be no > > global secretmem specific pool to exhaust, but then it's possible to drain > > high order free blocks in a system, so CMA has an advantage of limiting > > secretmem pools to certain amount of memory with somewhat higher > > probability for high order allocation to succeed. > > > > > or you need a careful access control > > > > Do you mind elaborating what do you mean by "careful access control"? > > As already mentioned, a mechanism to control who can use this feature - > e.g. make it a special device which you can access control by > permissions or higher level security policies. But that is really needed > only if the pool is fixed sized. Let me reiterate to make sure I don't misread your suggestion. If we make secretmem an opt-in feature with, e.g. kernel parameter, the pooling of large pages is unnecessary. In this case there is no limited resource we need to protect because secretmem will allocate page by page. Since there is no limited resource, we don't need special permissions to access secretmem so we can move forward with a system call that creates a mmapable file descriptor and save the hassle of a chardev. I cannot say I don't like this as it cuts roughly half of mm/secretmem.c :) But I must say I am still a bit concerned about that we have no provisions here for dealing with the direct map fragmentation even with the set goal to improve the direct map management in the long run... -- Sincerely yours, Mike.