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 Ã 17:48 +0200, Eric Dumazet a Ãcrit :
> uld add a seqcount (shared), and increment it each time one cpu
> changes global count.
> 
> _sum() could get an additional parameter, the max number of allowed
> changes during _sum() run.
> 
> If _sum() notices seqcount was changed too much, restart the loop.
> 
> s64 __percpu_counter_sum(struct percpu_counter *fbc, unsigned maxfuzzy)
> {
> 	s64 ret;
> 	unsigned int oldseq, newseq;
> 	int cpu;
> restart:
> 	oldseq = fbc->seqcount;
> 	smp_rmb();
> 	ret = fbc->count;
> 	for_each_online_cpu(cpu) {
> 		s32 *pcount = per_cpu_ptr(fbc->counters, cpu);
> 		ret += *pcount;
> 	}
> 	smp_rmb()
> 	newseq = fbc->count;

Sorry, it should be : 
	newseq = fbc->seqcount

> 	if (newseq - oldseq >= maxfuzzy)
> 		goto restart;
> 	return ret;
> }
> 
> 


--
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]