Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3964335pxb; Tue, 17 Nov 2020 08:02:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGpcyWiqjkU+OzJ7UomWeme/c6VRbnMO5KbucNuUwLjKI+auSkURwUdJ/mOiMxcagmsQZj X-Received: by 2002:a05:6402:14cf:: with SMTP id f15mr21208136edx.18.1605628924653; Tue, 17 Nov 2020 08:02:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605628924; cv=none; d=google.com; s=arc-20160816; b=bZK7mW3SwoBbNsRu8KOK/8F/xpt3z3TjRvIQ+Rlc7ZZe7ksY/Ktv52e7Xkz5jkoZBj zAjlOnofZh/d2X17fryoesdLJxke6d/1z9kC63agp/02Ju3noFEE2qn+ZzZVa/Fyqxdi QeZ2Jdb3sdPq/p5ByCBVS2utjjU1MocaJQLzlfZHdOsWvGaG9RZ+NCV8yS8K/InLwuM6 z1kirjBjwD66dTORJepCnyT5u5iFT9chfmy8LVyh4Yr+OUTUFbG0yVuui9t23E1EVKwf OSRDvD8NLflHpCEKThY6AtRH2L/rse8TjJVdTbv4bWbABkjpjrwGd6wwMuQuU+f4qjCP /GJQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=p9756bX06uA6UoQMQK6/fDbFLpDYKnfh8BYy6dMV17w=; b=mlQDzurXNcRVqUKI8SDX0ryDofa+0gKfYtHDCW4v+RQuU8tl2IP7DNAZw6M5ZyotFS UPRYg5pmLZZ1EngSDpm0jj10u/Nzhr0+G1DWvXePbEN/YGiGL03jwGFUqzdlumy7frcn ZPPt4R6s6kZJYY6WZTvueKBK46q13x1NjNCKABpbTugqSQrwL8QkDdBYm2PBstlrEEUu r4XZaIeVHTSsbjDTyggLbU0+gPnrjn7FDghmtLIvVw+1FqQdlO1+/b2Xffa1AD07PG8D Es0lhg8kMa+o9ylWMlRCCN6vkaeVXZCE0+APJappqXFaRtyOOBIQeBGLzZggMDWtxYn1 G2Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=p8sWlliy; 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 i5si14665379edx.188.2020.11.17.08.01.39; Tue, 17 Nov 2020 08:02:04 -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=default header.b=p8sWlliy; 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 S1726827AbgKQP6n (ORCPT + 99 others); Tue, 17 Nov 2020 10:58:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:35552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725767AbgKQP6m (ORCPT ); Tue, 17 Nov 2020 10:58:42 -0500 Received: from kernel.org (unknown [77.125.7.142]) (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 D3B60238E6; Tue, 17 Nov 2020 15:58:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605628721; bh=9is+MjALfTGepw57FVx0JouySPxlzfHt3CDVLQ4Unmk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=p8sWlliyDkUNYoXZjFWSoiuQvdgEZNX+2SxP4AeRu3E6J1nQ7q1oTfz+6Ip2yE0wn cmwAFaK1S/AmhU4S6q0bHx0jhCupiexg9VCuzKWD3rTOMD16YOJ0wT4exivwNxppfK VG9oFzcdjadQK9Y3xyHqBPePYLUqwIL58wy/neZo= Date: Tue, 17 Nov 2020 17:58:29 +0200 From: Mike Rapoport To: David Hildenbrand Cc: 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 , James Bottomley , "Kirill A. Shutemov" , Matthew Wilcox , Mark Rutland , Mike Rapoport , Michael Kerrisk , Palmer Dabbelt , Paul Walmsley , Peter Zijlstra , Rick Edgecombe , 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 Subject: Re: [PATCH v8 2/9] mmap: make mlock_future_check() global Message-ID: <20201117155829.GJ370813@kernel.org> References: <20201112190827.GP4758@kernel.org> <7A16CA44-782D-4ABA-8D93-76BDD0A90F94@redhat.com> <20201115082625.GT4758@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 17, 2020 at 04:09:39PM +0100, David Hildenbrand wrote: > On 15.11.20 09:26, Mike Rapoport wrote: > > On Thu, Nov 12, 2020 at 09:15:18PM +0100, David Hildenbrand wrote: ... > > My thinking was that since secretmem does what mlock() does wrt > > swapability, it should at least obey the same limit, i.e. > > RLIMIT_MEMLOCK. > > Right, but at least currently, it behaves like any other CMA allocation > (IIRC they are all unmovable and, therefore, not swappable). In the future, > if pages would be movable (but not swappable), I guess it might makes more > sense. I assume we never ever want to swap secretmem. > > "man getrlimit" states for RLIMIT_MEMLOCK: > > "This is the maximum number of bytes of memory that may be > locked into RAM. [...] This limit affects > mlock(2), mlockall(2), and the mmap(2) MAP_LOCKED operation. > Since Linux 2.6.9, it also affects the shmctl(2) SHM_LOCK op‐ > eration [...]" > > So that place has to be updated as well I guess? Otherwise this might come > as a surprise for users. Sure. > > > > > E.g., we also don‘t > > > account for gigantic pages - which might be allocated from CMA and are > > > not swappable. > > Do you mean gigantic pages in hugetlbfs? > > Yes > > > It seems to me that hugetlbfs accounting is a completely different > > story. > > I'd say it is right now comparable to secretmem - which is why I though > similar accounting would make sense. IMHO, using RLIMIT_MEMLOCK and memcg is a more straightforward way than a custom cgroup. And if we'll see a need for additional mechanism, we can always add it. > -- > Thanks, > > David / dhildenb > > -- Sincerely yours, Mike.