Linux Audio

Check our new training course

Embedded Linux Audio

Check our new training course
with Creative Commons CC-BY-SA
lecture materials

Bootlin logo

Elixir Cross Referencer

Loading...

#include <linux/percpu_counter.h>
#include <linux/sched.h>

void percpu_counter_mod(struct percpu_counter *fbc, long amount)
{
	int cpu = get_cpu();
	long count = fbc->counters[cpu].count;

	count += amount;
	if (count >= FBC_BATCH || count <= -FBC_BATCH) {
		spin_lock(&fbc->lock);
		fbc->count += count;
		spin_unlock(&fbc->lock);
		count = 0;
	}
	fbc->counters[cpu].count = count;
	put_cpu();
}