questions on calc_delta_mine() in sched.c

Joel Schopp
2008-05-01T20:45:57Z

Ingo,

I have a few questions regarding this code in kernel/sched.c

static unsigned long
calc_delta_mine(unsigned long delta_exec, unsigned long weight,
struct load_weight *lw)
{
u64 tmp;

if (unlikely(!lw->inv_weight))
lw->inv_weight = (WMULT_CONST-lw->weight/2) / (lw->weight+1);

Q1) This code is hit often in scenarios I run, is this really unlikely for
others?
Q2) The rest of the code in sched.c seems to make inv_weight ==
WMULT_CONST/weight and I was wondering if you could explain why this
instance is different.
Q3) That division is pretty expensive, could we sacrifice some accuracy and
do a precompute table? Do you have another idea how we could get rid of
the divide?

-Joel Schopp