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: <50EA28FA.8040205@opensuse.org>
Date:	Sun, 06 Jan 2013 22:46:34 -0300
From:	Cristian Rodríguez <crrodriguez@...nsuse.org>
To:	Theodore Ts'o <tytso@....edu>
CC:	linux-ext4@...r.kernel.org
Subject: Re: [PATCH] lib/ext2fs: Use __builtin_popcount when available Signed-off-by: Cristian Rodríguez <crrodriguez@...nsuse.org>

El dom 06 ene 2013 22:31:56 CLST, Theodore Ts'o escribió:
> On Sun, Jan 06, 2013 at 09:53:47PM -0300, Cristian Rodríguez wrote:
>>
>> Yeah, I asked GCC developers exactly this, was told to fill a
>> enhancement request.
>
> If you could also sned them a bug/enhancement request to use a more
> optimized version of __popcountdi2, that would be great.  I'm not sure
> it helps e2fsprogs much, since it's too hard for us to tell whether we
> are using a version of the gcc runtime that has a optimized or
> unuptomized version of builtin_popcount().
>
> But since it doesn't make that much difference, my preference is to
> just ignore builtin_popcount() for now.  If someone is really using
> 128TB ext4 file systems, and cares about that extra 6 seconds of CPU,
> it's probably going to require the ugly approach of using x86 asm
> statements to determine whether or not we're running on a CPU that
> supports the popcount instruction or not....

with a recent compiler it goes something like this..

unsigned int popcnt(unsigned int w) __attribute__ ((ifunc 
("resolve_popcnt")));

__attribute__ ((__target__ ("popcnt")))
static unsigned int hw_popcnt(unsigned int w)
{
    return __builtin_popcount(w);
}

static unsigned int soft_popcnt(unsigned int w)
{
    return __builtin_popcount(w);
}

static void (*resolve_popcnt (void)) (void)
{
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
    __builtin_cpu_init();
    if (__builtin_cpu_supports("popcnt"))
        return hw_popcnt;
#else
    unsigned int eax, ebx, ecx, edx;
    if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
        if (ecx & bit_POPCNT)
            return hw_popcnt;
#endif
    /* If magic does not work, or running old cpu.. */
        return soft_popcnt;
}

then call "popcnt" function in the code, this flies in x86 && ELF && 
GCC >= 4.6 only though.
The CPU detection code only runs once at load time btw.



--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ