Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp3128118pxy; Wed, 4 Aug 2021 03:05:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUwkCol6PKVsNAjRicwGc1TMl9MHYV7w6sBapV3VjagsasFUjYtQRoqaOOwblNLk6YRwX4 X-Received: by 2002:a17:906:1355:: with SMTP id x21mr25504007ejb.490.1628071557956; Wed, 04 Aug 2021 03:05:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628071557; cv=none; d=google.com; s=arc-20160816; b=MWkmDD6RWsYrSoTBo/mxmj/vr2H4GWqrlyHHYqxb+D0buYbYGmFRYdMhhtVspr/Lyj wgLQsk3feIHOhLCyycnz+L6Eekvtyng1dGU8QuQQYwv5/nnhvfv7EyH2qui2vNS+Rde4 swsiXrXcC2iiy+YMMgzPJVQhLYuojOLgcJ58i9Qqe2xqjb6Jvtt+OTeFUH7jBiQQpRt2 1Qm6iQIWGxJB5P44nMAIVrej6ZxzT1wvlE54LYxB7us0h8gajiTLXZjbPqA+y5TX09Sw gJgKQF0F//Z4bc3Ug7U6ccnkpXanCDO2rS9rWIth2uDZD8drlw1ABfVKnCnlr+YR/C11 jiIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=h7Zb2A6Dh35OWvvMLuElewoKlDVEdIPG861c8z8d7jg=; b=DM7ZFbGL7h6I8/h8f2ZpiRIK8kzxtaJloyKJdA71/74KaWDPkgVf/jntpw+gRL7bUT NrOZPDFdufEZV5dE5tYsJsVIQTUwylL2u+QFAhwlhoAtcu4c27fGS+EKfZCB2x0MA0aY A3LZczziu+22NwZj25ecOo3Sv3779eBnAMTXgYf6OJGeJSGHWRirIog8Vtx4rpYHwYEM BZYuMqUsO963SgOxG/V9hXY+8STtwa6untSi1VxDCQ01Dp8ADFA76xfFTNH3fOplLyPE ZdZiXu91kdKWI0xZ/AJr7Uc2SGwJp5agjggrJvNpHVG4Y2ggoLrCdnjw3CYkHU2ozVmh jkVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Y+FPojpZ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h18si1437999ejt.663.2021.08.04.03.05.30; Wed, 04 Aug 2021 03:05:57 -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=@google.com header.s=20161025 header.b=Y+FPojpZ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232707AbhHDJPp (ORCPT + 99 others); Wed, 4 Aug 2021 05:15:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232428AbhHDJPn (ORCPT ); Wed, 4 Aug 2021 05:15:43 -0400 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B20DC061799 for ; Wed, 4 Aug 2021 02:15:31 -0700 (PDT) Received: by mail-oi1-x235.google.com with SMTP id a19so2135070oiw.6 for ; Wed, 04 Aug 2021 02:15:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=h7Zb2A6Dh35OWvvMLuElewoKlDVEdIPG861c8z8d7jg=; b=Y+FPojpZ7vt4c9aS5JxHtYi18I/UZ1MIAtfN7XmXFNAKWkhc8z6zThket2NIo8OWzv o6BoeEfJUNOU/E2EOlgL44Q4WYwKCgL8OwzFH99F9XMQm5SSel14hNwv+AqmKFh46L1C 1kYt5Y5qZQQCbd/dwLuOkWY6OJGph/xf8u3TjomeEOCGyff7QYW73X1eNuTNkYLQvGv5 ZR/cHEpvqFQSWRV4hjpDNnphgts54ZHQ3cccgNqDNaVhI4CSKEqCcv+xmT4QLqpNVaTx QEFAj5r7cAVU0Tga+T52yaijY0x26+uG/kZiDest7zF2s/PQqIlz4mKUa2LMtIjVXg41 0Xaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=h7Zb2A6Dh35OWvvMLuElewoKlDVEdIPG861c8z8d7jg=; b=ZH/oPX7YIP1S24nUqhsrca+YkaE+bvbL5qO9iNfBAEn21T8sJjQMYy8CFeWVkXMN7O Fzf2AfOXCVZD/ptdnsK/glhT7iDLCvehZKCIlZFDH13qSFtBPqdutfFKXuHkxznbFUIT FBnWJdiJ5olWD10VxWf6+TamdkYazbz4ADxr9vBSz3MfVnI9API/ewtcOdHQjSbDIwsj a9KK+JOMvg21aTdn91ezFz19kyD088EwqifXpHBRbUj9EA6LtF6oMOqDid+CgvBP3HLF D4ZCqsWgZAu4+1MA7jj9I4aCUFDc4WFUxB/fEetaijbXudyUrvkp64AuYZG1/4CTxSh4 c2XA== X-Gm-Message-State: AOAM530gJs3ejqQfnNP1diB8tKDuzTeGJOMJfqarx6rsomoV0BDyUaWb AwOQGWpRZRxFm+6A5p64pEjXkA== X-Received: by 2002:aca:6704:: with SMTP id z4mr17441159oix.89.1628068530413; Wed, 04 Aug 2021 02:15:30 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id x8sm260465oof.27.2021.08.04.02.15.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Aug 2021 02:15:29 -0700 (PDT) Date: Wed, 4 Aug 2021 02:15:26 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Matthew Wilcox cc: Hugh Dickins , Andrew Morton , Shakeel Butt , "Kirill A. Shutemov" , Yang Shi , Miaohe Lin , Mike Kravetz , Michal Hocko , Rik van Riel , Christoph Hellwig , "Eric W. Biederman" , Alexey Gladkov , Chris Wilson , Matthew Auld , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 10/16] tmpfs: fcntl(fd, F_MEM_LOCK) to memlock a tmpfs file In-Reply-To: Message-ID: <7077b94a-d894-4d97-4b3e-23f516d58591@google.com> References: <2862852d-badd-7486-3a8e-c5ea9666d6fb@google.com> <54e03798-d836-ae64-f41-4a1d46bc115b@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 3 Aug 2021, Matthew Wilcox wrote: > On Fri, Jul 30, 2021 at 12:55:22AM -0700, Hugh Dickins wrote: > > A new uapi to lock the files on tmpfs in memory, to protect against swap > > without mapping the files. This commit introduces two new commands to > > fcntl and shmem: F_MEM_LOCK and F_MEM_UNLOCK. The locking will be > > charged against RLIMIT_MEMLOCK of uid in namespace of the caller. > > It's not clear to me why this is limited to shmfs. Would it not also > make sense for traditional filesystems, eg to force chrome's text pages > to stay in the page cache, no matter how much memory the tabs allocate? Right: if VFS people would like this to be available for all filesystems, that's fine by me - it's just that we have not given thought to other filesystems, and the demand was for tmpfs, so that was where to start. I'm more confident adding fields to shmem inode than to generic inode. (Plus tmpfs does have a stronger claim on CAP_IPC_LOCK etc, but there's no real reason why that cannot be extended to similar use by other FSs). hugetlbfs and ramfs, where the files are already memlocked? Not worth a special case, I think: if someone uses up memlock quota on them, so be it. It looks as if tmpfs would still want its own special case, just to handle the FALLOC_FL_KEEP_SIZE issue (see 12/16): tmpfs has beyond-i_size pages in memory, but accounts them evictable; whereas I doubt any storage filesystems would be using memory for them. To be clear: I'm not intending to extend this to other filesystems at the moment; but happy to do so if that's the consensus. Hugh