From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-fsdevel@vger.kernel.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
intel-gfx@lists.freedesktop.org, linux-mm@kvack.org,
dri-devel@lists.freedesktop.org
Subject: [PATCH v2 6/9] i915: Use writeback_iter()
Date: Wed, 2 Apr 2025 16:00:00 +0100 [thread overview]
Message-ID: <20250402150005.2309458-7-willy@infradead.org> (raw)
In-Reply-To: <20250402150005.2309458-1-willy@infradead.org>
Convert from an inefficient loop to the standard writeback iterator.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 32 ++++++-----------------
1 file changed, 8 insertions(+), 24 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
index ae3343c81a64..5e784db9f315 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
@@ -305,36 +305,20 @@ void __shmem_writeback(size_t size, struct address_space *mapping)
.range_end = LLONG_MAX,
.for_reclaim = 1,
};
- unsigned long i;
+ struct folio *folio = NULL;
+ int error = 0;
/*
* Leave mmapings intact (GTT will have been revoked on unbinding,
- * leaving only CPU mmapings around) and add those pages to the LRU
+ * leaving only CPU mmapings around) and add those folios to the LRU
* instead of invoking writeback so they are aged and paged out
* as normal.
*/
-
- /* Begin writeback on each dirty page */
- for (i = 0; i < size >> PAGE_SHIFT; i++) {
- struct page *page;
-
- page = find_lock_page(mapping, i);
- if (!page)
- continue;
-
- if (!page_mapped(page) && clear_page_dirty_for_io(page)) {
- int ret;
-
- SetPageReclaim(page);
- ret = mapping->a_ops->writepage(page, &wbc);
- if (!PageWriteback(page))
- ClearPageReclaim(page);
- if (!ret)
- goto put;
- }
- unlock_page(page);
-put:
- put_page(page);
+ while ((folio = writeback_iter(mapping, &wbc, folio, &error))) {
+ if (folio_mapped(folio))
+ folio_redirty_for_writepage(&wbc, folio);
+ else
+ error = shmem_writeout(folio, &wbc);
}
}
--
2.47.2
next prev parent reply other threads:[~2025-04-02 15:00 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-02 14:59 [PATCH v2 0/9] Remove aops->writepage Matthew Wilcox (Oracle)
2025-04-02 14:59 ` [PATCH v2 1/9] 9p: Add a migrate_folio method Matthew Wilcox (Oracle)
2025-04-03 3:46 ` Dominique Martinet
2025-04-03 3:53 ` Matthew Wilcox
2025-04-02 14:59 ` [PATCH v2 2/9] vboxsf: Convert to writepages Matthew Wilcox (Oracle)
2025-04-02 14:59 ` [PATCH v2 3/9] migrate: Remove call to ->writepage Matthew Wilcox (Oracle)
2025-04-05 16:56 ` Zi Yan
2025-04-02 14:59 ` [PATCH v2 4/9] writeback: Remove writeback_use_writepage() Matthew Wilcox (Oracle)
2025-04-02 14:59 ` [PATCH v2 5/9] shmem: Add shmem_writeout() Matthew Wilcox (Oracle)
2025-04-02 15:00 ` Matthew Wilcox (Oracle) [this message]
2025-04-04 8:26 ` [PATCH v2 6/9] i915: Use writeback_iter() Christoph Hellwig
2025-04-04 13:40 ` Matthew Wilcox
2025-04-02 15:00 ` [PATCH v2 7/9] ttm: Call shmem_writeout() from ttm_backup_backup_page() Matthew Wilcox (Oracle)
2025-04-02 15:00 ` [PATCH v2 8/9] mm: Remove swap_writepage() and shmem_writepage() Matthew Wilcox (Oracle)
2025-04-02 15:00 ` [PATCH v2 9/9] fs: Remove aops->writepage Matthew Wilcox (Oracle)
2025-04-02 17:10 ` [PATCH v2 1/9] 9p: Add a migrate_folio method David Howells
2025-04-04 8:31 ` [PATCH v2 0/9] Remove aops->writepage Christoph Hellwig
2025-04-04 13:42 ` 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=20250402150005.2309458-7-willy@infradead.org \
--to=willy@infradead.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.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;
as well as URLs for NNTP newsgroup(s).