ChangeSet 1.2199.14.24, 2005/03/23 12:06:51-08:00, [EMAIL PROTECTED]

        [CRYPTO]: Do scatterwalk_whichbuf inline.
        
        scatterwalk_whichbuf is called once for each block which could be as
        small as 8/16 bytes.  So it makes sense to do that work inline.
        
        It's also a bit inflexible since we may want to use the temporary buffer
        even if the block doesn't cross page boundaries.  In particular, we want
        to do that when the source and destination are the same.
        
        So let's replace it with scatterwalk_across_pages.
        
        I've also simplified the check in scatterwalk_across_pages.  It is
        sufficient to only check len_this_page.
        
        Signed-off-by: David S. Miller <[EMAIL PROTECTED]>



 cipher.c      |   12 ++++++++++--
 scatterwalk.c |   10 ----------
 scatterwalk.h |    7 ++++++-
 3 files changed, 16 insertions(+), 13 deletions(-)


diff -Nru a/crypto/cipher.c b/crypto/cipher.c
--- a/crypto/cipher.c   2005-03-26 17:22:48 -08:00
+++ b/crypto/cipher.c   2005-03-26 17:22:48 -08:00
@@ -11,6 +11,7 @@
  * any later version.
  *
  */
+#include <linux/compiler.h>
 #include <linux/kernel.h>
 #include <linux/crypto.h>
 #include <linux/errno.h>
@@ -72,8 +73,15 @@
 
                scatterwalk_map(&walk_in, 0);
                scatterwalk_map(&walk_out, 1);
-               src_p = scatterwalk_whichbuf(&walk_in, bsize, tmp_src);
-               dst_p = scatterwalk_whichbuf(&walk_out, bsize, tmp_dst);
+
+               src_p = walk_in.data;
+               if (unlikely(scatterwalk_across_pages(&walk_in, bsize)))
+                       src_p = tmp_src;
+
+               dst_p = walk_out.data;
+               if (unlikely(scatterwalk_across_pages(&walk_out, bsize)))
+                       dst_p = tmp_dst;
+
                in_place = scatterwalk_samebuf(&walk_in, &walk_out,
                                               src_p, dst_p);
 
diff -Nru a/crypto/scatterwalk.c b/crypto/scatterwalk.c
--- a/crypto/scatterwalk.c      2005-03-26 17:22:48 -08:00
+++ b/crypto/scatterwalk.c      2005-03-26 17:22:48 -08:00
@@ -28,16 +28,6 @@
        KM_SOFTIRQ1,
 };
 
-void *scatterwalk_whichbuf(struct scatter_walk *walk, unsigned int nbytes, 
void *scratch)
-{
-       if (nbytes <= walk->len_this_page &&
-           (((unsigned long)walk->data) & (PAGE_CACHE_SIZE - 1)) + nbytes <=
-           PAGE_CACHE_SIZE)
-               return walk->data;
-       else
-               return scratch;
-}
-
 static void memcpy_dir(void *buf, void *sgdata, size_t nbytes, int out)
 {
        if (out)
diff -Nru a/crypto/scatterwalk.h b/crypto/scatterwalk.h
--- a/crypto/scatterwalk.h      2005-03-26 17:22:48 -08:00
+++ b/crypto/scatterwalk.h      2005-03-26 17:22:48 -08:00
@@ -42,7 +42,12 @@
               walk_in->data == src_p && walk_out->data == dst_p;
 }
 
-void *scatterwalk_whichbuf(struct scatter_walk *walk, unsigned int nbytes, 
void *scratch);
+static inline int scatterwalk_across_pages(struct scatter_walk *walk,
+                                          unsigned int nbytes)
+{
+       return nbytes > walk->len_this_page;
+}
+
 void scatterwalk_start(struct scatter_walk *walk, struct scatterlist *sg);
 int scatterwalk_copychunks(void *buf, struct scatter_walk *walk, size_t 
nbytes, int out);
 void scatterwalk_map(struct scatter_walk *walk, int out);
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to