Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 298789
b: refs/heads/master
c: f68e556
h: refs/heads/master
i:
  298787: be3d7ee
v: v3
  • Loading branch information
Linus Torvalds committed Apr 6, 2012
1 parent 5086f66 commit 6333d6b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 33 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 23f347ef63aa36b5a001b6791f657cd0e2a04de3
refs/heads/master: f68e556e23d1a4176b563bcb25d8baf2c5313f91
46 changes: 46 additions & 0 deletions trunk/arch/x86/include/asm/word-at-a-time.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef _ASM_WORD_AT_A_TIME_H
#define _ASM_WORD_AT_A_TIME_H

/*
* This is largely generic for little-endian machines, but the
* optimal byte mask counting is probably going to be something
* that is architecture-specific. If you have a reliably fast
* bit count instruction, that might be better than the multiply
* and shift, for example.
*/

#ifdef CONFIG_64BIT

/*
* Jan Achrenius on G+: microoptimized version of
* the simpler "(mask & ONEBYTES) * ONEBYTES >> 56"
* that works for the bytemasks without having to
* mask them first.
*/
static inline long count_masked_bytes(unsigned long mask)
{
return mask*0x0001020304050608ul >> 56;
}

#else /* 32-bit case */

/* Carl Chatfield / Jan Achrenius G+ version for 32-bit */
static inline long count_masked_bytes(long mask)
{
/* (000000 0000ff 00ffff ffffff) -> ( 1 1 2 3 ) */
long a = (0x0ff0001+mask) >> 23;
/* Fix the 1 for 00 case */
return a & mask;
}

#endif

#define REPEAT_BYTE(x) ((~0ul / 0xff) * (x))

/* Return the high bit set in the first byte that is a zero */
static inline unsigned long has_zero(unsigned long a)
{
return ((a - REPEAT_BYTE(0x01)) & ~a) & REPEAT_BYTE(0x80);
}

#endif /* _ASM_WORD_AT_A_TIME_H */
35 changes: 3 additions & 32 deletions trunk/fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1407,18 +1407,9 @@ static inline int can_lookup(struct inode *inode)
*/
#ifdef CONFIG_DCACHE_WORD_ACCESS

#ifdef CONFIG_64BIT
#include <asm/word-at-a-time.h>

/*
* Jan Achrenius on G+: microoptimized version of
* the simpler "(mask & ONEBYTES) * ONEBYTES >> 56"
* that works for the bytemasks without having to
* mask them first.
*/
static inline long count_masked_bytes(unsigned long mask)
{
return mask*0x0001020304050608ul >> 56;
}
#ifdef CONFIG_64BIT

static inline unsigned int fold_hash(unsigned long hash)
{
Expand All @@ -1428,15 +1419,6 @@ static inline unsigned int fold_hash(unsigned long hash)

#else /* 32-bit case */

/* Carl Chatfield / Jan Achrenius G+ version for 32-bit */
static inline long count_masked_bytes(long mask)
{
/* (000000 0000ff 00ffff ffffff) -> ( 1 1 2 3 ) */
long a = (0x0ff0001+mask) >> 23;
/* Fix the 1 for 00 case */
return a & mask;
}

#define fold_hash(x) (x)

#endif
Expand Down Expand Up @@ -1464,17 +1446,6 @@ unsigned int full_name_hash(const unsigned char *name, unsigned int len)
}
EXPORT_SYMBOL(full_name_hash);

#define REPEAT_BYTE(x) ((~0ul / 0xff) * (x))
#define ONEBYTES REPEAT_BYTE(0x01)
#define SLASHBYTES REPEAT_BYTE('/')
#define HIGHBITS REPEAT_BYTE(0x80)

/* Return the high bit set in the first byte that is a zero */
static inline unsigned long has_zero(unsigned long a)
{
return ((a - ONEBYTES) & ~a) & HIGHBITS;
}

/*
* Calculate the length and hash of the path component, and
* return the length of the component;
Expand All @@ -1490,7 +1461,7 @@ static inline unsigned long hash_name(const char *name, unsigned int *hashp)
len += sizeof(unsigned long);
a = *(unsigned long *)(name+len);
/* Do we have any NUL or '/' bytes in this word? */
mask = has_zero(a) | has_zero(a ^ SLASHBYTES);
mask = has_zero(a) | has_zero(a ^ REPEAT_BYTE('/'));
} while (!mask);

/* The mask *below* the first high bit set */
Expand Down

0 comments on commit 6333d6b

Please sign in to comment.