Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scatterlist: inline sg_next()

sg_next() is a short function called frequently in I/O paths. Define it
in the header file so it can be inlined into its callers.

Link: https://lkml.kernel.org/r/20250416160615.3571958-1-csander@purestorage.com
Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Cc: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Caleb Sander Mateos and committed by
Andrew Morton
8d1d4b53 7d9b0527

+22 -24
+22 -1
include/linux/scatterlist.h
··· 95 95 } 96 96 97 97 /** 98 + * sg_next - return the next scatterlist entry in a list 99 + * @sg: The current sg entry 100 + * 101 + * Description: 102 + * Usually the next entry will be @sg@ + 1, but if this sg element is part 103 + * of a chained scatterlist, it could jump to the start of a new 104 + * scatterlist array. 105 + * 106 + **/ 107 + static inline struct scatterlist *sg_next(struct scatterlist *sg) 108 + { 109 + if (sg_is_last(sg)) 110 + return NULL; 111 + 112 + sg++; 113 + if (unlikely(sg_is_chain(sg))) 114 + sg = sg_chain_ptr(sg); 115 + 116 + return sg; 117 + } 118 + 119 + /** 98 120 * sg_assign_page - Assign a given page to an SG entry 99 121 * @sg: SG entry 100 122 * @page: The page ··· 440 418 441 419 int sg_nents(struct scatterlist *sg); 442 420 int sg_nents_for_len(struct scatterlist *sg, u64 len); 443 - struct scatterlist *sg_next(struct scatterlist *); 444 421 struct scatterlist *sg_last(struct scatterlist *s, unsigned int); 445 422 void sg_init_table(struct scatterlist *, unsigned int); 446 423 void sg_init_one(struct scatterlist *, const void *, unsigned int);
-23
lib/scatterlist.c
··· 14 14 #include <linux/folio_queue.h> 15 15 16 16 /** 17 - * sg_next - return the next scatterlist entry in a list 18 - * @sg: The current sg entry 19 - * 20 - * Description: 21 - * Usually the next entry will be @sg@ + 1, but if this sg element is part 22 - * of a chained scatterlist, it could jump to the start of a new 23 - * scatterlist array. 24 - * 25 - **/ 26 - struct scatterlist *sg_next(struct scatterlist *sg) 27 - { 28 - if (sg_is_last(sg)) 29 - return NULL; 30 - 31 - sg++; 32 - if (unlikely(sg_is_chain(sg))) 33 - sg = sg_chain_ptr(sg); 34 - 35 - return sg; 36 - } 37 - EXPORT_SYMBOL(sg_next); 38 - 39 - /** 40 17 * sg_nents - return total count of entries in scatterlist 41 18 * @sg: The scatterlist 42 19 *