Date: Mon, 30 Mar 2015 10:51:51 +0200 From: Hans Petter Selasky <hps@selasky.org> To: Ian Lepore <ian@freebsd.org>, Gleb Smirnoff <glebius@FreeBSD.org> Cc: "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>, Adrian Chadd <adrian@freebsd.org>, "src-committers@freebsd.org" <src-committers@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, Fabien Thomas <fabient@freebsd.org> Subject: Re: svn commit: r280759 - head/sys/netinet Message-ID: <55190EA7.9010905@selasky.org> In-Reply-To: <1427666182.82583.4.camel@freebsd.org> References: <201503271326.t2RDQxd3056112@svn.freebsd.org> <20150328083443.GV64665@FreeBSD.org> <20150328191629.GY64665@FreeBSD.org> <5517B433.5010508@selasky.org> <CAJ-VmonU15_nEGVQNwR52deDf1TbPUz0oAMr%2B3zwNqU_9%2Bo1fw@mail.gmail.com> <20150329210757.GA64665@FreeBSD.org> <1427666182.82583.4.camel@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?55190EA7.9010905>
