From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5B6DCCD6E79 for ; Tue, 9 Jun 2026 09:05:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E697E89E33; Tue, 9 Jun 2026 09:05:20 +0000 (UTC) X-Greylist: delayed 580 seconds by postgrey-1.36 at gabe; Tue, 09 Jun 2026 09:05:20 UTC Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0612589E33 for ; Tue, 9 Jun 2026 09:05:20 +0000 (UTC) Received: by verein.lst.de (Postfix, from userid 2407) id 3E29468BEB; Tue, 9 Jun 2026 10:55:35 +0200 (CEST) Date: Tue, 9 Jun 2026 10:55:34 +0200 From: Christoph Hellwig 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 , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Christian Koenig , Huang Rui , Matthew Auld , Matthew Brost , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , 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 Message-ID: <20260609085534.GA12980@lst.de> References: <20260601113449.3464734-1-hch@lst.de> <20260601113449.3464734-2-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260601113449.3464734-2-hch@lst.de> User-Agent: Mutt/1.5.17 (2007-11-01) X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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 > --- > 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 > #include > > -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---