Re: [RFC PATCH] net: add additional lock to qdisc to increase enqueue/dequeue fairness

Eric Dumazet
2010-03-23T21:18:23Z

Le mardi 23 mars 2010 à 21:54 +0100, Eric Dumazet a écrit :
> I wonder if ticket spinlocks are not the problem. Maybe we want a
> variant of spinlocks, so that cpu doing transmits can get the lock
> before other cpus...

Something like this portable implementation :

struct spinprio {
spinlock_t lock;
int highprio_cnt;
};

void spinprio_lock(struct spinprio *l)
{
while (1) {
spin_lock(&l->lock);
if (!l->highprio_cnt)
break;
spin_unlock(&l->lock);
cpu_relax();
}
}

void spinprio_unlock(struct spinprio *l)
{
spin_unlock(&l->lock);
}

void spinprio_relock(struct spinprio *l)
{
l->highprio_cnt = 1;
spin_lock(&l->lock);
l->highprio_cnt = 0;
}

We would have to use spinprio_unlock()/spinprio_relock() in
sch_direct_xmit()