mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									7d9b05277a
								
							
						
					
					
						commit
						8d1d4b538b
					
				
					 2 changed files with 22 additions and 24 deletions
				
			
		| 
						 | 
					@ -94,6 +94,28 @@ static inline bool sg_is_last(struct scatterlist *sg)
 | 
				
			||||||
	return __sg_flags(sg) & SG_END;
 | 
						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_assign_page - Assign a given page to an SG entry
 | 
				
			||||||
 * @sg:		    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(struct scatterlist *sg);
 | 
				
			||||||
int sg_nents_for_len(struct scatterlist *sg, u64 len);
 | 
					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);
 | 
					struct scatterlist *sg_last(struct scatterlist *s, unsigned int);
 | 
				
			||||||
void sg_init_table(struct scatterlist *, unsigned int);
 | 
					void sg_init_table(struct scatterlist *, unsigned int);
 | 
				
			||||||
void sg_init_one(struct scatterlist *, const void *, unsigned int);
 | 
					void sg_init_one(struct scatterlist *, const void *, unsigned int);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,29 +13,6 @@
 | 
				
			||||||
#include <linux/uio.h>
 | 
					#include <linux/uio.h>
 | 
				
			||||||
#include <linux/folio_queue.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_nents - return total count of entries in scatterlist
 | 
				
			||||||
 * @sg:		The scatterlist
 | 
					 * @sg:		The scatterlist
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue