svn commit: r280759 - head/sys/netinet

Hans Petter Selasky hps at selasky.org
Mon Mar 30 08:51:13 UTC 2015


Hi,

Like was mentioned here, maybe we need a global counter that is not 
accessed that frequently, and use per-cpu counters for the most frequent 
accesses. To keep the order somewhat sane, we need a global counter:

Pseudo code:

static int V_ip_id;

PER_CPU(V_ip_id_start);
PER_CPU(V_ip_id_end);

static uint16_t
get_next_id()
{
if (PER_CPU(V_ip_id_start) == PER_CPU(V_ip_id_end)) {
	next = atomic_add32(&V_ip_id, 256);
	V_ip_id_start = next;
	V_ip_id_end = next + 256;
}
id = V_ip_id_start++;
return (id);
}

--HPS


More information about the svn-src-head mailing list