From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zoltan Kiss Subject: Re: [PATCH] mbuf: add comment explaining confusing code Date: Tue, 31 Mar 2015 13:33:45 +0100 Message-ID: <551A9429.8030502@linaro.org> References: <1427404494-27256-1-git-send-email-bruce.richardson@intel.com> <20150327102956.GB5375@hmsreliant.think-freely.org> <20150327113238.GA11660@bricha3-MOBL3> <20150327140735.GG5375@hmsreliant.think-freely.org> <20150327143049.GB9972@bricha3-MOBL3> <20150327143841.GH5375@hmsreliant.think-freely.org> <20150327145526.GA10332@bricha3-MOBL3> <20150327164358.GI5375@hmsreliant.think-freely.org> <59AF69C657FD0841A61C55336867B5B0344F112F@IRSMSX103.ger.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Cc: "dev-VfR2kkLFssw@public.gmane.org" To: Don Provan , "Richardson, Bruce" , Neil Horman Return-path: In-Reply-To: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" Hi, On 30/03/15 18:39, Don Provan wrote: >>>>>>>>> if (likely (rte_mbuf_refcnt_read(m) == 1) || >>>>>>>>> likely (rte_mbuf_refcnt_update(m, -1) == 0)) > > In all the debate about atomics, I don't think anyone got around to pointing out that in the unlikely case that the refcnt is not 1, then it's equally unlikely that decrementing it will result in 0 despite the code's claim to the contrary. That's the part that confused me. Would it make sense to fix this while adding the comment? > -don > dprovan-NegutG5bDZheoWH0uzbU5w@public.gmane.org > I was thinking about that too, either remove it or turn it into "unlikely". Currently it suggest that "if there are more than one users, they are likely to release at the same time". If that's not true, we should remove it, but as Don said, it would hardly make a difference in real world cases as more than one users is not really a hot usecase, AFAIK. Regards, Zoltan