Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Mar 2015 08:16:46 -0700
From:      Adrian Chadd <adrian@freebsd.org>
To:        Hans Petter Selasky <hps@selasky.org>
Cc:        "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, Gleb Smirnoff <glebius@freebsd.org>, "src-committers@freebsd.org" <src-committers@freebsd.org>, Fabien Thomas <fabient@freebsd.org>
Subject:   Re: svn commit: r280759 - head/sys/netinet
Message-ID:  <CAJ-VmonU15_nEGVQNwR52deDf1TbPUz0oAMr%2B3zwNqU_9%2Bo1fw@mail.gmail.com>
In-Reply-To: <5517B433.5010508@selasky.org>
References:  <201503271326.t2RDQxd3056112@svn.freebsd.org> <20150328083443.GV64665@FreeBSD.org> <20150328191629.GY64665@FreeBSD.org> <5517B433.5010508@selasky.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 29 March 2015 at 01:13, Hans Petter Selasky <hps@selasky.org> wrote:
> On 03/28/15 20:16, Gleb Smirnoff wrote:
>>
>> +uint16_t
>> +ip_newid(void)
>> +{
>> +
>> +       counter_u64_add(V_ip_id, 1);
>> +       return (htons((*(uint64_t *)zpcpu_get(V_ip_id)) & 0xffff));
>> +}
>
>
> Technically you would need to enter a critical section here, so that the
> current process doesn't get swapped to a different CPU between the counter
> add and the zpcpu_get.

+10000 here.

You can get preempted and shifted to another CPU at almost any point
in time you're not explicitly asking not to be. It's.. frustrating.




-adrian



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ-VmonU15_nEGVQNwR52deDf1TbPUz0oAMr%2B3zwNqU_9%2Bo1fw>