How about bitscan instruction on x86 ?
Posted: Fri Oct 28, 2016 6:15 pm
Hi.
Have you even used 'bsf/bsr' instruction in your project ?
How about its performance?
I saw in a post(http://www.asmcommunity.net/forums/topic/?id=3771) that bitscan instruction is quite slow on pentium.
And another evidence, the do_softirq() function in kernel/softirq.c use repeatedly bit shift operation to traverse all 32 bits.
He didn't use 'bsr/bsf'.
Here is the code:
And I pick out the relevant code:
do {
if (active & 1)
h->action(h);
h++;
active >>= 1;
} while (active);
Have you even used 'bsf/bsr' instruction in your project ?
How about its performance?
I saw in a post(http://www.asmcommunity.net/forums/topic/?id=3771) that bitscan instruction is quite slow on pentium.
And another evidence, the do_softirq() function in kernel/softirq.c use repeatedly bit shift operation to traverse all 32 bits.
He didn't use 'bsr/bsf'.
Here is the code:
Code: Select all
asmlinkage void do_softirq()
{
int cpu = smp_processor_id();
__u32 active, mask;
if (in_interrupt())
return;
local_bh_disable();
local_irq_disable();
mask = softirq_mask(cpu);
active = softirq_active(cpu) & mask;
if (active) {
struct softirq_action *h;
restart:
/* Reset active bitmask before enabling irqs */
softirq_active(cpu) &= ~active;
local_irq_enable();
h = softirq_vec;
mask &= ~active;
do {
if (active & 1)
h->action(h);
h++;
active >>= 1;
} while (active);
local_irq_disable();
active = softirq_active(cpu);
if ((active &= mask) != 0)
goto retry;
}
local_bh_enable();
/* Leave with locally disabled hard irqs. It is critical to close
* window for infinite recursion, while we help local bh count,
* it protected us. Now we are defenceless.
*/
return;
retry:
goto restart;
}
do {
if (active & 1)
h->action(h);
h++;
active >>= 1;
} while (active);