From: John L. <mov...@us...> - 2001-08-14 18:02:38
|
Update of /cvsroot/oprofile/oprofile In directory usw-pr-cvs1:/tmp/cvs-serv25297 Modified Files: ChangeLog op_syscalls.c Log Message: fixes to the hash map ! Index: ChangeLog =================================================================== RCS file: /cvsroot/oprofile/oprofile/ChangeLog,v retrieving revision 1.76 retrieving revision 1.77 diff -u -d -r1.76 -r1.77 --- ChangeLog 2001/08/14 02:38:29 1.76 +++ ChangeLog 2001/08/14 18:02:33 1.77 @@ -1,5 +1,13 @@ 2001-08-14 John Levon <mo...@co...> + * op_syscalls.c: don't return negative hashes ! + revert dname len "fix" + use a much better hash function + + * dae/opd_proc.c: protect against negative hashes + +2001-08-14 John Levon <mo...@co...> + * op_syscalls.c: some small fixes * oprofile.c: add back unmasking code during set_gate, but only Index: op_syscalls.c =================================================================== RCS file: /cvsroot/oprofile/oprofile/op_syscalls.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- op_syscalls.c 2001/08/14 02:38:29 1.15 +++ op_syscalls.c 2001/08/14 18:02:33 1.16 @@ -169,6 +169,7 @@ hash_map = rvmalloc(PAGE_ALIGN(OP_HASH_MAP_SIZE)); if (!hash_map) return -EFAULT; + return 0; } @@ -238,14 +239,14 @@ spinlock_t map_lock = SPIN_LOCK_UNLOCKED; -inline static uint name_hash(const char *name, uint len) +inline static short name_hash(const char *name, uint len) { - uint hash=0; + short hash=0; while (len--) - hash = ((hash << 4) | (hash >> 28)) ^ name[len]; + hash = (hash + (name[len] << 4) + (name[len] >> 4)) * 11; - return hash % OP_HASH_MAP_NR; + return abs(hash % OP_HASH_MAP_NR); } /* empty ascending dname stack */ @@ -279,7 +280,7 @@ /* wind the dentries onto the stack pages */ for (;;) { - if (d->d_name.len >= OP_HASH_LINE) + if (d->d_name.len > OP_HASH_LINE) goto too_large; /* deleted ? */ @@ -322,7 +323,7 @@ goto next; /* nope, find another place in the table */ - value = (value + probe) % OP_HASH_MAP_NR; + value = abs((value + probe) % OP_HASH_MAP_NR); probe *= probe; if (value == firsthash) goto fulltable; |