lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 23 Sep 2011 15:11:21 +0300
From:	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:	Denys Vlasenko <vda.linux@...glemail.com>
Cc:	linux-kernel@...r.kernel.org,
	OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>
Subject: Re: [PATCH] fat: don't use custom hex_to_bin()

On Fri, 2011-09-23 at 14:05 +0200, Denys Vlasenko wrote: 
> On Fri, Sep 23, 2011 at 1:32 PM, Andy Shevchenko
> <andriy.shevchenko@...ux.intel.com> wrote:
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> > Cc: OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>
> > ---
> >  fs/fat/namei_vfat.c |   22 ++++++----------------
> >  1 files changed, 6 insertions(+), 16 deletions(-)
> >
> > diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
> > index bb3f29c..09cec4c 100644
> > --- a/fs/fat/namei_vfat.c
> > +++ b/fs/fat/namei_vfat.c
> > @@ -21,6 +21,8 @@
> >  #include <linux/slab.h>
> >  #include <linux/buffer_head.h>
> >  #include <linux/namei.h>
> > +#include <linux/kernel.h>
> > +
> >  #include "fat.h"
> >
> >  /*
> > @@ -505,7 +507,6 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
> >             struct nls_table *nls)
> >  {
> >        const unsigned char *ip;
> > -       unsigned char nc;
> >        unsigned char *op;
> >        unsigned int ec;
> >        int i, k, fill;
> > @@ -530,21 +531,10 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
> >                                                return -EINVAL;
> >                                        ec = 0;
> >                                        for (k = 1; k < 5; k++) {
> > -                                               nc = ip[k];
> > -                                               ec <<= 4;
> > -                                               if (nc >= '0' && nc <= '9') {
> > -                                                       ec |= nc - '0';
> > -                                                       continue;
> > -                                               }
> > -                                               if (nc >= 'a' && nc <= 'f') {
> > -                                                       ec |= nc - ('a' - 10);
> > -                                                       continue;
> > -                                               }
> > -                                               if (nc >= 'A' && nc <= 'F') {
> > -                                                       ec |= nc - ('A' - 10);
> > -                                                       continue;
> > -                                               }
> > -                                               return -EINVAL;
> > +                                               int val = hex_to_bin(ip[k]);
> > +                                               if (val < 0)
> > +                                                       return -EINVAL;
> > +                                               ec = (ec << 4) | val;
> >                                        }
> >                                        *op++ = ec & 0xFF;
> >                                        *op++ = ec >> 8;
> 
> Function call per byte?
4 times in our case per 16 bit.

> That's expensive!
By the way, you can do those optimizations across the kernel. There are
dozens of places where one or few bytes are converted per half-byte.

> Can't we have a function which converts many sequential bytes?
We have one, but it doesn't return any error. We could wait until Mimi
integrates his patch series.


-- 
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Intel Finland Oy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ