All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: baoquan.he@linux.dev, akpm@linux-foundation.org,
	chrisl@kernel.org, usama.arif@linux.dev, kasong@tencent.com,
	nphamcs@gmail.com, shikemeng@huaweicloud.com,
	youngjun.park@lge.com, linux-mm@kvack.org,
	Jani Nikula <jani.nikula@linux.intel.com>,
	Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	Tvrtko Ursulin <tursulin@ursulin.net>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Christian Koenig <christian.koenig@amd.com>,
	Huang Rui <ray.huang@amd.com>,
	Matthew Auld <matthew.auld@intel.com>,
	Matthew Brost <matthew.brost@intel.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: better shmem writeback interface for drm, was: Re: [PATCH 1/8] shmem: provide a shmem_write_folio wrapper
Date: Tue, 9 Jun 2026 10:55:34 +0200	[thread overview]
Message-ID: <20260609085534.GA12980@lst.de> (raw)
In-Reply-To: <20260601113449.3464734-2-hch@lst.de>

Sashiko complains about a lot of pre-existing issues in i915/ttm here:

https://sashiko.dev/#/patchset/20260601113449.3464734-1-hch%40lst.de

This might be a good time to fix these, and as part of it provide
saner interfaces for drm.  The i915 case look like a plain writeback
range, which looks somewhat easy.  I don't really get what the ttm
code is trying to do.

Any takers to get drm out of messing with these lowlevel shmemfs
internals?

On Mon, Jun 01, 2026 at 01:34:27PM +0200, Christoph Hellwig wrote:
> Provide a wrapper for the shmem abuses in drm to preparare for swap I/O
> refactoring by keepin swap_iocb handling entirely contained in mm/.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 2 +-
>  drivers/gpu/drm/ttm/ttm_backup.c          | 2 +-
>  include/linux/shmem_fs.h                  | 5 +----
>  mm/shmem.c                                | 7 ++++++-
>  mm/swap.h                                 | 4 ++++
>  5 files changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> index 06543ae60706..ef9440166295 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> @@ -325,7 +325,7 @@ void __shmem_writeback(size_t size, struct address_space *mapping)
>  		if (folio_mapped(folio))
>  			folio_redirty_for_writepage(&wbc, folio);
>  		else
> -			error = shmem_writeout(folio, NULL, NULL);
> +			error = shmem_write_folio(folio);
>  	}
>  }
>  
> diff --git a/drivers/gpu/drm/ttm/ttm_backup.c b/drivers/gpu/drm/ttm/ttm_backup.c
> index 81df4cb5606b..c5b813a563e7 100644
> --- a/drivers/gpu/drm/ttm/ttm_backup.c
> +++ b/drivers/gpu/drm/ttm/ttm_backup.c
> @@ -117,7 +117,7 @@ ttm_backup_backup_page(struct file *backup, struct page *page,
>  	if (writeback && !folio_mapped(to_folio) &&
>  	    folio_clear_dirty_for_io(to_folio)) {
>  		folio_set_reclaim(to_folio);
> -		ret = shmem_writeout(to_folio, NULL, NULL);
> +		ret = shmem_write_folio(to_folio);
>  		if (!folio_test_writeback(to_folio))
>  			folio_clear_reclaim(to_folio);
>  		/*
> diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
> index acb8dd961b45..f35c752f27af 100644
> --- a/include/linux/shmem_fs.h
> +++ b/include/linux/shmem_fs.h
> @@ -12,8 +12,6 @@
>  #include <linux/userfaultfd_k.h>
>  #include <linux/bits.h>
>  
> -struct swap_iocb;
> -
>  /* inode in-kernel data */
>  
>  #ifdef CONFIG_TMPFS_QUOTA
> @@ -122,8 +120,7 @@ static inline bool shmem_mapping(const struct address_space *mapping)
>  void shmem_unlock_mapping(struct address_space *mapping);
>  struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
>  					pgoff_t index, gfp_t gfp_mask);
> -int shmem_writeout(struct folio *folio, struct swap_iocb **plug,
> -		struct list_head *folio_list);
> +int shmem_write_folio(struct folio *folio);
>  void shmem_truncate_range(struct inode *inode, loff_t start, uoff_t end);
>  int shmem_unuse(unsigned int type);
>  
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 56c23a7b15c7..d10735e49b25 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -1738,7 +1738,12 @@ int shmem_writeout(struct folio *folio, struct swap_iocb **plug,
>  	folio_mark_dirty(folio);
>  	return AOP_WRITEPAGE_ACTIVATE;	/* Return with folio locked */
>  }
> -EXPORT_SYMBOL_GPL(shmem_writeout);
> +
> +int shmem_write_folio(struct folio *folio)
> +{
> +	return shmem_writeout(folio, NULL, NULL);
> +}
> +EXPORT_SYMBOL_GPL(shmem_write_folio);
>  
>  #if defined(CONFIG_NUMA) && defined(CONFIG_TMPFS)
>  static void shmem_show_mpol(struct seq_file *seq, struct mempolicy *mpol)
> diff --git a/mm/swap.h b/mm/swap.h
> index 77d2d14eda42..4f86ef338a60 100644
> --- a/mm/swap.h
> +++ b/mm/swap.h
> @@ -473,4 +473,8 @@ static inline unsigned int folio_swap_flags(struct folio *folio)
>  }
>  
>  #endif /* CONFIG_SWAP */
> +
> +int shmem_writeout(struct folio *folio, struct swap_iocb **plug,
> +		struct list_head *folio_list);
> +
>  #endif /* _MM_SWAP_H */
> -- 
> 2.53.0
> 
---end quoted text---


  parent reply	other threads:[~2026-06-09  8:55 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01 11:34 better block swap batching and a different take on swap_ops v2 Christoph Hellwig
2026-06-01 11:34 ` [PATCH 1/8] shmem: provide a shmem_write_folio wrapper Christoph Hellwig
2026-06-04  9:43   ` Baoquan He
2026-06-05 17:07   ` Nhat Pham
2026-06-09  8:55   ` Christoph Hellwig [this message]
2026-06-01 11:34 ` [PATCH 2/8] mm: merge writeout into pageout Christoph Hellwig
2026-06-04  9:44   ` Baoquan He
2026-06-05 17:07   ` Nhat Pham
2026-06-09  8:49   ` 7.2 candidate? was: " Christoph Hellwig
2026-06-09  9:22     ` David Hildenbrand (Arm)
2026-06-01 11:34 ` [PATCH 3/8] mm/swap: introduce struct swap_io_ctx Christoph Hellwig
2026-06-04 10:58   ` Baoquan He
2026-06-05 17:41   ` Nhat Pham
2026-06-09  8:43     ` Christoph Hellwig
2026-06-01 11:34 ` [PATCH 4/8] mm/swap: also use struct swap_iocb for block I/O Christoph Hellwig
2026-06-04 10:59   ` Baoquan He
2026-06-04 11:37   ` Baoquan He
2026-06-01 11:34 ` [PATCH 5/8] mm/swap: remove count_swpout_vm_event Christoph Hellwig
2026-06-04 11:37   ` Baoquan He
2026-06-05 17:50   ` Nhat Pham
2026-06-01 11:34 ` [PATCH 6/8] mm/swap: use swap_ops to register swap device's methods Christoph Hellwig
2026-06-05 17:53   ` Nhat Pham
2026-06-01 11:34 ` [PATCH 7/8] mm/swap: remove SWP_FS_OPS Christoph Hellwig
2026-06-05  5:21   ` Baoquan He
2026-06-09  8:45     ` Christoph Hellwig
2026-06-05 17:58   ` Nhat Pham
2026-06-01 11:34 ` [PATCH 8/8] mm/vmstat: add NRSWP{IN,OUT} counters Christoph Hellwig
2026-06-05  7:16   ` Baoquan He
2026-06-09  8:46     ` Christoph Hellwig
2026-06-05 17:48   ` Nhat Pham
2026-06-01 13:29 ` better block swap batching and a different take on swap_ops v2 Baoquan He
2026-06-01 14:50   ` Christoph Hellwig
2026-06-01 15:17     ` Baoquan He
2026-06-01 15:25       ` Christoph Hellwig

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=20260609085534.GA12980@lst.de \
    --to=hch@lst.de \
    --cc=airlied@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=baoquan.he@linux.dev \
    --cc=chrisl@kernel.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=kasong@tencent.com \
    --cc=linux-mm@kvack.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=matthew.auld@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=mripard@kernel.org \
    --cc=nphamcs@gmail.com \
    --cc=ray.huang@amd.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=shikemeng@huaweicloud.com \
    --cc=simona@ffwll.ch \
    --cc=tursulin@ursulin.net \
    --cc=tzimmermann@suse.de \
    --cc=usama.arif@linux.dev \
    --cc=youngjun.park@lge.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.