mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	Christian Brauner <brauner@kernel.org>
Subject: Re: [PATCH] [RFC] mm/fadvise: introduce POSIX_FADV_MLOCK
Date: Fri, 21 Nov 2025 04:22:32 +0000	[thread overview]
Message-ID: <aR_pCGtcc7ASeA77@casper.infradead.org> (raw)
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) <willy@infradead.org>
> Cc: Christian Brauner <brauner@kernel.org>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  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
> 

  reply	other threads:[~2025-11-21  4:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-21  3:27 Jaegeuk Kim
2025-11-21  4:22 ` Matthew Wilcox [this message]
2025-11-21  4:46   ` Jaegeuk Kim
2025-11-21 14:27     ` Matthew Wilcox
2025-11-21 18:02       ` Jaegeuk Kim
2025-11-21 19:52         ` Jaegeuk Kim
2025-11-21 19:58           ` Matthew Wilcox
2025-11-21 21:32             ` Jaegeuk Kim
2025-11-22  2:47               ` Matthew Wilcox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aR_pCGtcc7ASeA77@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=brauner@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®