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]
Message-ID: <CAHp75VeGFB+j+2T7JmARw5pCkgo7Kz0HXde7mKrTsaGhSSN05g@mail.gmail.com>
Date:	Mon, 18 Jul 2011 22:05:05 +0300
From:	Andy Shevchenko <andy.shevchenko@...il.com>
To:	Alexey Dobriyan <adobriyan@...il.com>
Cc:	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH 2/2] lib: call native hex_to_bin() inside _kstrtoull()

Anyway, I wrote the small performance test case (you can see it in a
new series), which shows significant reduction of the performance
(~12%). So, just drop this patch.

On Mon, Jul 18, 2011 at 1:31 PM, Alexey Dobriyan <adobriyan@...il.com> wrote:
> On Mon, Jul 18, 2011 at 11:23 AM, Andy Shevchenko
> <andriy.shevchenko@...ux.intel.com> wrote:
>> --- a/lib/kstrtox.c
>> +++ b/lib/kstrtox.c
>> @@ -39,25 +39,18 @@ static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res)
>>        acc = 0;
>>        ok = 0;
>>        while (*s) {
>> -               unsigned int val;
>> +               int val;
>>
>> -               if ('0' <= *s && *s <= '9')
>> -                       val = *s - '0';
>> -               else if ('a' <= TOLOWER(*s) && TOLOWER(*s) <= 'f')
>> -                       val = TOLOWER(*s) - 'a' + 10;
>> -               else if (*s == '\n' && *(s + 1) == '\0')
>> +               if (unlikely(*s == '\n' && *(s + 1) == '\0'))
>>                        break;
>> -               else
>> -                       return -EINVAL;
>>
>> -               if (val >= base)
>> +               val = hex_to_bin(*s++);
>> +               if (val >= base || val < 0)
>>                        return -EINVAL;
>>                if (acc > div_u64(ULLONG_MAX - val, base))
>>                        return -ERANGE;
>>                acc = acc * base + val;
>>                ok = 1;
>> -
>> -               s++;
>>        }
>>        if (!ok)
>>                return -EINVAL;
>
> 1. unlikely() and s++ move don't have anything to do with changes
> 2. I don't understand desire to use some half-thought out API,
>   in fact, restricting to radix 16 is arbitrary.
>   Without such restriction hex_to_bin doesn't make sense.
> --
> 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/
>



-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ