The patch titled Subject: scatterlist: add sg_set_folio() has been added to the -mm mm-unstable branch. Its filename is scatterlist-add-sg_set_folio.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/scatterlist-add-sg_set_folio.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx> Subject: scatterlist: add sg_set_folio() Date: Wed, 21 Jun 2023 17:45:47 +0100 This wrapper for sg_set_page() lets drivers add folios to a scatterlist more easily. We could, perhaps, do better by using a different page in the folio if offset is larger than UINT_MAX, but let's hope we get a better data structure than this before we need to care about such large folios. Link: https://lkml.kernel.org/r/20230621164557.3510324-4-willy@xxxxxxxxxxxxx Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/scatterlist.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) --- a/include/linux/scatterlist.h~scatterlist-add-sg_set_folio +++ a/include/linux/scatterlist.h @@ -141,6 +141,30 @@ static inline void sg_set_page(struct sc sg->length = len; } +/** + * sg_set_folio - Set sg entry to point at given folio + * @sg: SG entry + * @folio: The folio + * @len: Length of data + * @offset: Offset into folio + * + * Description: + * Use this function to set an sg entry pointing at a folio, never assign + * the folio directly. We encode sg table information in the lower bits + * of the folio pointer. See sg_page() for looking up the page belonging + * to an sg entry. + * + **/ +static inline void sg_set_folio(struct scatterlist *sg, struct folio *folio, + size_t len, size_t offset) +{ + WARN_ON_ONCE(len > UINT_MAX); + WARN_ON_ONCE(offset > UINT_MAX); + sg_assign_page(sg, &folio->page); + sg->offset = offset; + sg->length = len; +} + static inline struct page *sg_page(struct scatterlist *sg) { #ifdef CONFIG_DEBUG_SG _ Patches currently in -mm which might be from willy@xxxxxxxxxxxxx are afs-convert-pagevec-to-folio_batch-in-afs_extend_writeback.patch mm-add-__folio_batch_release.patch scatterlist-add-sg_set_folio.patch i915-convert-shmem_sg_free_table-to-use-a-folio_batch.patch drm-convert-drm_gem_put_pages-to-use-a-folio_batch.patch mm-remove-check_move_unevictable_pages.patch pagevec-rename-fbatch_count.patch i915-convert-i915_gpu_error-to-use-a-folio_batch.patch net-convert-sunrpc-from-pagevec-to-folio_batch.patch mm-remove-struct-pagevec.patch mm-rename-invalidate_mapping_pagevec-to-mapping_try_invalidate.patch mm-remove-references-to-pagevec.patch mm-remove-unnecessary-pagevec-includes.patch