Thread (164 messages) 164 messages, 20 authors, 2023-05-25

Re: [PATCH v7 04/14] mm/shmem: Support memfile_notifier

From: Chao Peng <hidden>
Date: 2022-07-13 07:48:57
Also in: kvm, linux-doc, linux-fsdevel, linux-kselftest, linux-mm, lkml, qemu-devel

On Tue, Jul 12, 2022 at 08:02:34PM +0200, Gupta, Pankaj wrote:
On 7/6/2022 10:20 AM, Chao Peng wrote:
quoted
From: "Kirill A. Shutemov" <redacted>

Implement shmem as a memfile_notifier backing store. Essentially it
interacts with the memfile_notifier feature flags for userspace
access/page migration/page reclaiming and implements the necessary
memfile_backing_store callbacks.

Signed-off-by: Kirill A. Shutemov <redacted>
Signed-off-by: Chao Peng <redacted>
---
  include/linux/shmem_fs.h |   2 +
  mm/shmem.c               | 109 ++++++++++++++++++++++++++++++++++++++-
  2 files changed, 110 insertions(+), 1 deletion(-)
...
quoted
+#ifdef CONFIG_MIGRATION
+static int shmem_migrate_page(struct address_space *mapping,
+			      struct page *newpage, struct page *page,
+			      enum migrate_mode mode)
+{
+	struct inode *inode = mapping->host;
+	struct shmem_inode_info *info = SHMEM_I(inode);
+
+	if (info->memfile_node.flags & MEMFILE_F_UNMOVABLE)
+		return -EOPNOTSUPP;
+	return migrate_page(mapping, newpage, page, mode);
Wondering how well page migrate would work for private pages
on shmem memfd based backend?
From high level:
  - KVM unset MEMFILE_F_UNMOVABLE bit to indicate it capable of
    migrating a page.
  - Introduce new 'migrate' callback(s) to memfile_notifier_ops for KVM
    to register.
  - The callback is hooked to migrate_page() here.
  - Once page migration requested, shmem calls into the 'migrate'
    callback(s) to perform additional steps for encrypted memory (For
    TDX we will call TDH.MEM.PAGE.RELOCATE).

Chao
quoted
+}
+#endif
+
  const struct address_space_operations shmem_aops = {
  	.writepage	= shmem_writepage,
  	.dirty_folio	= noop_dirty_folio,
@@ -3814,7 +3872,7 @@ const struct address_space_operations shmem_aops = {
  	.write_end	= shmem_write_end,
  #endif
  #ifdef CONFIG_MIGRATION
-	.migratepage	= migrate_page,
+	.migratepage	= shmem_migrate_page,
  #endif
  	.error_remove_page = shmem_error_remove_page,
  };
@@ -3931,6 +3989,51 @@ static struct file_system_type shmem_fs_type = {
  	.fs_flags	= FS_USERNS_MOUNT,
  };
 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help