From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECE8518027 for ; Fri, 21 Nov 2025 04:22:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763698960; cv=none; b=RKOIgSR/2+PCtDZ3hYiM80spZaQBc8yY5h+fedG3nT50ZCkk7S3jJeduOhWEBtsokc3a4KyxNUL3eoXCi+wQJ61qT7jfunhzkmxwg58Z8/KtVAeyFR2bOmXpN6mn8AuKqjLkPPbBxgLnJpTk9tduYe06aNn9D5Xta/HJgecKbmI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763698960; c=relaxed/simple; bh=CMdOyjNqJ8WgLuLhqeo32xItYLjaHl6lRd+PlqQhXtc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gq8+PDqNGn0ZD6WZDmH5i6YRt9Jo3loBPFjWCWrB2AvLVn+8SZh6hO4BzD60a3/6pPJV8WZe8DzHO2UCOWsIPSFHPKlRbOudNAbMI7NG0+eqSV0C200GNs4HZK7mWG4BqV5FC6+fMnFkccrr81/gGETg2ikAgD29knKDUOOWglc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=pbszIUkG; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="pbszIUkG" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=RtfILe7M/y6h7GRu89gildDYXQDPaHfJbR7EMAPvGEs=; b=pbszIUkGt5QpYpTvCpY2eKLc4q yqwvzPN3e8ia319WGovFqgv4VQQ8uv+yhj8upvHyeJBOfNCOrCVn/PySR1Sy1K4rlF0ciX6oOJaUK KQD5wgVFNbiMEzQ2LhKEp2ApuATlSwBSS1udIeh3cznVp1eQiUdy0YCNPXFTKFLHIW4xpPtP/In53 FHBeZDYSbCfuWyzdIOviPiREzOqo/0QkN2tWft9Bzp0LfXQF8Gsbglbd00KfXYk290vj1ZAXJEWJU 4WDX+l4uOnUAwJH3MMHJt9GpPfrKE4J/Bazd4EVhxPpBtNzdwwqiOSt8f0Xhk2Vrb+Yykxz/aqN10 5PWr139w==; Received: from willy by casper.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1vMIfI-00000002IJw-2Iwl; Fri, 21 Nov 2025 04:22:32 +0000 Date: Fri, 21 Nov 2025 04:22:32 +0000 From: Matthew Wilcox To: Jaegeuk Kim Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Christian Brauner Subject: Re: [PATCH] [RFC] mm/fadvise: introduce POSIX_FADV_MLOCK Message-ID: References: <20251121032718.1993528-1-jaegeuk@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251121032718.1993528-1-jaegeuk@kernel.org> On Fri, Nov 21, 2025 at 03:27:18AM +0000, Jaegeuk Kim wrote: > This patch introduces a new POSIX_FADV_MLOCK which 1) invalidates the range of > cached pages, 2) sets the mapping as inaccessible, 3) POSIX_FADV_WILLNEED loads > pages directly to the inaccessible mapping. ... what? This seems like something which is completely different from mlock(). So it needs a different name. But I don't understand the point of this, whatever it's called. Need more information. > The inaccessible pages will be invalidated by evict_inode or explicit munlock(). > > Cc: Matthew Wilcox (Oracle) > Cc: Christian Brauner > Signed-off-by: Jaegeuk Kim > --- > include/uapi/linux/fadvise.h | 2 ++ > mm/fadvise.c | 14 ++++++++++++++ > 2 files changed, 16 insertions(+) > > diff --git a/include/uapi/linux/fadvise.h b/include/uapi/linux/fadvise.h > index 0862b87434c2..06018688b99b 100644 > --- a/include/uapi/linux/fadvise.h > +++ b/include/uapi/linux/fadvise.h > @@ -19,4 +19,6 @@ > #define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */ > #endif > > +#define POSIX_FADV_MLOCK 8 /* Load pages into inaccessible map. */ > + > #endif /* FADVISE_H_INCLUDED */ > diff --git a/mm/fadvise.c b/mm/fadvise.c > index 588fe76c5a14..849b151d2024 100644 > --- a/mm/fadvise.c > +++ b/mm/fadvise.c > @@ -56,6 +56,7 @@ int generic_fadvise(struct file *file, loff_t offset, loff_t len, int advice) > case POSIX_FADV_WILLNEED: > case POSIX_FADV_NOREUSE: > case POSIX_FADV_DONTNEED: > + case POSIX_FADV_MLOCK: > /* no bad return value, but ignore advice */ > break; > default: > @@ -93,6 +94,19 @@ int generic_fadvise(struct file *file, loff_t offset, loff_t len, int advice) > file->f_mode &= ~FMODE_RANDOM; > spin_unlock(&file->f_lock); > break; > + case POSIX_FADV_MLOCK: > + /* Remove the cached pages. */ > + if (!mapping_unevictable(mapping)) { > + invalidate_inode_pages2_range(mapping, > + offset >> PAGE_SHIFT, > + (offset + len - 1) >> PAGE_SHIFT); > + > + /* set the mapping is unevictable */ > + filemap_invalidate_lock(mapping); > + mapping_set_inaccessible(mapping); > + filemap_invalidate_unlock(mapping); > + } > + fallthrough; > case POSIX_FADV_WILLNEED: > /* First and last PARTIAL page! */ > start_index = offset >> PAGE_SHIFT; > -- > 2.52.0.487.g5c8c507ade-goog >