]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scatterlist: inline sg_next()
authorCaleb Sander Mateos <csander@purestorage.com>
Wed, 16 Apr 2025 16:06:13 +0000 (10:06 -0600)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 12 May 2025 00:54:08 +0000 (17:54 -0700)
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>
include/linux/scatterlist.h
lib/scatterlist.c

index 138e2f1bd08f2df20312fd35948626fec946bb36..0cdbfc42f15369e029cd71813c34a21c1734f8a3 100644 (file)
@@ -94,6 +94,28 @@ static inline bool sg_is_last(struct scatterlist *sg)
        return __sg_flags(sg) & SG_END;
 }
 
+/**
+ * sg_next - return the next scatterlist entry in a list
+ * @sg:                The current sg entry
+ *
+ * Description:
+ *   Usually the next entry will be @sg@ + 1, but if this sg element is part
+ *   of a chained scatterlist, it could jump to the start of a new
+ *   scatterlist array.
+ *
+ **/
+static inline struct scatterlist *sg_next(struct scatterlist *sg)
+{
+       if (sg_is_last(sg))
+               return NULL;
+
+       sg++;
+       if (unlikely(sg_is_chain(sg)))
+               sg = sg_chain_ptr(sg);
+
+       return sg;
+}
+
 /**
  * sg_assign_page - Assign a given page to an SG entry
  * @sg:                    SG entry
@@ -418,7 +440,6 @@ static inline void sg_init_marker(struct scatterlist *sgl,
 
 int sg_nents(struct scatterlist *sg);
 int sg_nents_for_len(struct scatterlist *sg, u64 len);
-struct scatterlist *sg_next(struct scatterlist *);
 struct scatterlist *sg_last(struct scatterlist *s, unsigned int);
 void sg_init_table(struct scatterlist *, unsigned int);
 void sg_init_one(struct scatterlist *, const void *, unsigned int);
index b58d5ef1a34b07c8aa015f54d72d190c8c1ad5e6..7582dfab7fe3c9c3e8bdffd0a3084c6336ce7cd0 100644 (file)
 #include <linux/uio.h>
 #include <linux/folio_queue.h>
 
-/**
- * sg_next - return the next scatterlist entry in a list
- * @sg:                The current sg entry
- *
- * Description:
- *   Usually the next entry will be @sg@ + 1, but if this sg element is part
- *   of a chained scatterlist, it could jump to the start of a new
- *   scatterlist array.
- *
- **/
-struct scatterlist *sg_next(struct scatterlist *sg)
-{
-       if (sg_is_last(sg))
-               return NULL;
-
-       sg++;
-       if (unlikely(sg_is_chain(sg)))
-               sg = sg_chain_ptr(sg);
-
-       return sg;
-}
-EXPORT_SYMBOL(sg_next);
-
 /**
  * sg_nents - return total count of entries in scatterlist
  * @sg:                The scatterlist