Re: [PATCH] percpu: preemptless __per_cpu_counter_add

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

 



Le jeudi 28 avril 2011 Ã 11:17 -0500, Christoph Lameter a Ãcrit :
> On Thu, 28 Apr 2011, Eric Dumazet wrote:
> 
> > > If _sum() notices seqcount was changed too much, restart the loop.
> 
> This does not address the issue of cpus adding batch -1 while the
> loop is going on.


Yes, it does, I left the needed changes to write side as an exercice ;)


For example, based on current linux-2.6 code


void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch)
{
        s64 count;

        preempt_disable();
        count = __this_cpu_read(*fbc->counters) + amount;
        if (count >= batch || count <= -batch) {
                spin_lock(&fbc->lock);
		fbc->seqcount++;
                fbc->count += count;
                __this_cpu_write(*fbc->counters, 0);
                spin_unlock(&fbc->lock);
        } else {
                __this_cpu_write(*fbc->counters, count);
        }
        preempt_enable();
}


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxxx  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]