pid_hasfn function conflict overview

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all

I have a small conflict with the pid_hashfn, I don't unsertand because
this function not use a simple MODULO for create a index in a table

With the act function , use shift, XOR and & bits operation for lookup the
unique ( with 32 maxium colision for bucket) index in a table, but with a
simple module of PIDHASHSZ -1 is the same operation.

This is the actual  :
#define pid_hashfn(x) ((((x) >>8)^(x))&(PIDHASH_SZ-1))

And with calculate de modulo :
#define pid_hashfn(x) ((x)&(PIDHASH_SZ-1))

With this small code i have calculated de collisions in a large of table

memset(&table,0,PIDHASH_SZ*sizeof(int));
for(k=0;k<32768;k++)
    table[pid_hashfn(k)]++;

for(k=0;k<PIDHASH_SZ;k++)
    printf("%d (%d)\n",k,table[k]);


-- 
Pau Freixes
www.lana2.com/pfreixes
$GNU/Linux user$


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux