29 May, 2016

3 commits

  • This is just the infrastructure; there are no users yet.

    This is modelled on CONFIG_ARCH_RANDOM; a CONFIG_ symbol declares
    the existence of .

    That file may define its own versions of various functions, and define
    HAVE_* symbols (no CONFIG_ prefix!) to suppress the generic ones.

    Included is a self-test (in lib/test_hash.c) that verifies the basics.
    It is NOT in general required that the arch-specific functions compute
    the same thing as the generic, but if a HAVE_* symbol is defined with
    the value 1, then equality is tested.

    Signed-off-by: George Spelvin
    Cc: Geert Uytterhoeven
    Cc: Greg Ungerer
    Cc: Andreas Schwab
    Cc: Philippe De Muyter
    Cc: linux-m68k@lists.linux-m68k.org
    Cc: Alistair Francis
    Cc: Michal Simek
    Cc: Yoshinori Sato
    Cc: uclinux-h8-devel@lists.sourceforge.jp

    George Spelvin
     
  • The "simplified" prime multipliers made very bad hash functions, so get rid
    of them. This completes the work of 689de1d6ca.

    To avoid the inefficiency which was the motivation for the "simplified"
    multipliers, hash_64() on 32-bit systems is changed to use a different
    algorithm. It makes two calls to hash_32() instead.

    drivers/media/usb/dvb-usb-v2/af9015.c uses the old GOLDEN_RATIO_PRIME_32
    for some horrible reason, so it inherits a copy of the old definition.

    Signed-off-by: George Spelvin
    Cc: Antti Palosaari
    Cc: Mauro Carvalho Chehab

    George Spelvin
     
  • That's all that's ever asked for, and it makes the return
    type of hash_long() consistent.

    It also allows (upcoming patch) an optimized implementation
    of hash_64 on 32-bit machines.

    I tried adding a BUILD_BUG_ON to ensure the number of bits requested
    was never more than 32 (most callers use a compile-time constant), but
    adding to breaks the tools/perf compiler
    unless tools/perf/MANIFEST is updated, and understanding that code base
    well enough to update it is too much trouble. I did the rest of an
    allyesconfig build with such a check, and nothing tripped.

    Signed-off-by: George Spelvin

    George Spelvin
     

03 May, 2016

1 commit

  • This is a fairly minimal fixup to the horribly bad behavior of hash_64()
    with certain input patterns.

    In particular, because the multiplicative value used for the 64-bit hash
    was intentionally bit-sparse (so that the multiply could be done with
    shifts and adds on architectures without hardware multipliers), some
    bits did not get spread out very much. In particular, certain fairly
    common bit ranges in the input (roughly bits 12-20: commonly with the
    most information in them when you hash things like byte offsets in files
    or memory that have block factors that mean that the low bits are often
    zero) would not necessarily show up much in the result.

    There's a bigger patch-series brewing to fix up things more completely,
    but this is the fairly minimal fix for the 64-bit hashing problem. It
    simply picks a much better constant multiplier, spreading the bits out a
    lot better.

    NOTE! For 32-bit architectures, the bad old hash_64() remains the same
    for now, since 64-bit multiplies are expensive. The bigger hashing
    cleanup will replace the 32-bit case with something better.

    The new constants were picked by George Spelvin who wrote that bigger
    cleanup series. I just picked out the constants and part of the comment
    from that series.

    Cc: stable@vger.kernel.org
    Cc: George Spelvin
    Cc: Thomas Gleixner
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

11 Dec, 2014

1 commit

  • As there are now no remaining users of arch_fast_hash(), lets kill
    it entirely.

    This basically reverts commit 71ae8aac3e19 ("lib: introduce arch
    optimized hash library") and follow-up work, that is f.e., commit
    237217546d44 ("lib: hash: follow-up fixups for arch hash"),
    commit e3fec2f74f7f ("lib: Add missing arch generic-y entries for
    asm-generic/hash.h") and last but not least commit 6a02652df511
    ("perf tools: Fix include for non x86 architectures").

    Cc: Francesco Fusco
    Cc: Thomas Graf
    Cc: Arnaldo Carvalho de Melo
    Signed-off-by: Daniel Borkmann
    Signed-off-by: David S. Miller

    Daniel Borkmann
     

15 Nov, 2014

1 commit

  • This reverts commit e5a2c899957659cd1a9f789bc462f9c0b35f5150.

    Commit e5a2c899 introduced an alternative_call, arch_fast_hash2,
    that selects between __jhash2 and __intel_crc4_2_hash based on the
    X86_FEATURE_XMM4_2.

    Unfortunately, the alternative_call system does not appear to be
    suitable for use with C functions, as register usage is not handled
    properly for the called functions. The __jhash2 function in particular
    clobbers registers that are not preserved when called via
    alternative_call, resulting in a panic for direct callers of
    arch_fast_hash2 on older CPUs lacking sse4_2. It is possible that
    __intel_crc4_2_hash works merely by chance because it uses fewer
    registers.

    This commit was suggested as the source of the problem by Jesse
    Gross .

    Signed-off-by: Jay Vosburgh
    Signed-off-by: David S. Miller

    Jay Vosburgh
     

06 Nov, 2014

1 commit

  • By default the arch_fast_hash hashing function pointers are initialized
    to jhash(2). If during boot-up a CPU with SSE4.2 is detected they get
    updated to the CRC32 ones. This dispatching scheme incurs a function
    pointer lookup and indirect call for every hashing operation.

    rhashtable as a user of arch_fast_hash e.g. stores pointers to hashing
    functions in its structure, too, causing two indirect branches per
    hashing operation.

    Using alternative_call we can get away with one of those indirect branches.

    Acked-by: Daniel Borkmann
    Cc: Thomas Graf
    Signed-off-by: Hannes Frederic Sowa
    Signed-off-by: David S. Miller

    Hannes Frederic Sowa
     

14 Sep, 2014

1 commit

  • The hash_64() function historically does the multiply by the
    GOLDEN_RATIO_PRIME_64 number with explicit shifts and adds, because
    unlike the 32-bit case, gcc seems unable to turn the constant multiply
    into the more appropriate shift and adds when required.

    However, that means that we generate those shifts and adds even when the
    architecture has a fast multiplier, and could just do it better in
    hardware.

    Use the now-cleaned-up CONFIG_ARCH_HAS_FAST_MULTIPLIER (together with
    "is it a 64-bit architecture") to decide whether to use an integer
    multiply or the explicit sequence of shift/add instructions.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

18 Dec, 2013

1 commit

  • We introduce a new hashing library that is meant to be used in
    the contexts where speed is more important than uniformity of the
    hashed values. The hash library leverages architecture specific
    implementation to achieve high performance and fall backs to
    jhash() for the generic case.

    On Intel-based x86 architectures, the library can exploit the crc32l
    instruction, part of the Intel SSE4.2 instruction set, if the
    instruction is supported by the processor. This implementation
    is twice as fast as the jhash() implementation on an i7 processor.

    Additional architectures, such as Arm64 provide instructions for
    accelerating the computation of CRC, so they could be added as well
    in follow-up work.

    Signed-off-by: Francesco Fusco
    Signed-off-by: Daniel Borkmann
    Signed-off-by: Thomas Graf
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: David S. Miller

    Francesco Fusco
     

18 Mar, 2013

1 commit

  • Because hash_64() is called from the get_kprobe() inside
    int3 handler, kernel causes int3 recursion and crashes if
    kprobes user puts a probe on it.

    Usually hash_64() is inlined into caller function, but in
    some cases, it has instances by gcc's interprocedural
    constant propagation.

    This patch uses __always_inline instead of inline to
    prevent gcc from doing such things.

    Reported-by: Timo Juhani Lindfors
    Signed-off-by: Masami Hiramatsu
    Acked-by: Ananth N Mavinakayanahalli
    Cc: Pavel Emelyanov
    Cc: Jiri Kosina
    Cc: Nadia Yvette Chambers
    Cc: yrl.pp-manager.tt@hitachi.com
    Cc: David S. Miller
    Cc: Linus Torvalds
    Link: http://lkml.kernel.org/r/20130314115230.19690.39387.stgit@mhiramat-M0-7522
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     

06 Dec, 2012

1 commit


10 Aug, 2012

1 commit

  • Eric noticed, that when there will be devices with equal indices, some
    hash functions that use them will become less effective as they could.
    Fix this in advance by mixing the net_device address into the hash value
    instead of the device index.

    This is true for arp and ndisc hash fns. The netlabel, can and llc ones
    are also ifindex-based, but that three are init_net-only, thus will not
    be affected.

    Many thanks to David and Eric for the hash32_ptr implementation!

    Signed-off-by: Pavel Emelyanov
    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Pavel Emelyanov
     

18 Aug, 2011

1 commit


07 Feb, 2008

1 commit

  • The 32-bit version is more efficient (and apparently gives better hash
    results than the 64-bit version), so users who are only hashing a 32-bit
    quantity can now opt to use the 32-bit version explicitly, rather than
    promoting to a long.

    Signed-off-by: Matthew Wilcox
    Cc: William Lee Irwin III
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matthew Wilcox
     

17 Apr, 2005

1 commit

  • Initial git repository build. I'm not bothering with the full history,
    even though we have it. We can create a separate "historical" git
    archive of that later if we want to, and in the meantime it's about
    3.2GB when imported into git - space that would just make the early
    git days unnecessarily complicated, when we don't have a lot of good
    infrastructure for it.

    Let it rip!

    Linus Torvalds