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
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to