Author: hselasky
Date: Mon May 18 09:45:13 2020
New Revision: 361206
URL: https://svnweb.freebsd.org/changeset/base/361206

Log:
  MFC r360623:
  Optimise use of sg_page_count() in __sg_page_iter_next() in the LinuxKPI.
  No need to compute value twice.
  
  No functional change intended.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/scatterlist.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/scatterlist.h
==============================================================================
--- stable/11/sys/compat/linuxkpi/common/include/linux/scatterlist.h    Mon May 
18 09:44:26 2020        (r361205)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/scatterlist.h    Mon May 
18 09:45:13 2020        (r361206)
@@ -414,6 +414,8 @@ sg_page_count(struct scatterlist *sg)
 static inline bool
 __sg_page_iter_next(struct sg_page_iter *piter)
 {
+       unsigned int pgcount;
+
        if (piter->internal.nents == 0)
                return (0);
        if (piter->sg == NULL)
@@ -422,8 +424,11 @@ __sg_page_iter_next(struct sg_page_iter *piter)
        piter->sg_pgoffset += piter->internal.pg_advance;
        piter->internal.pg_advance = 1;
 
-       while (piter->sg_pgoffset >= sg_page_count(piter->sg)) {
-               piter->sg_pgoffset -= sg_page_count(piter->sg);
+       while (1) {
+               pgcount = sg_page_count(piter->sg);
+               if (likely(piter->sg_pgoffset < pgcount))
+                       break;
+               piter->sg_pgoffset -= pgcount;
                piter->sg = sg_next(piter->sg);
                if (--piter->internal.nents == 0)
                        return (0);
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to