On Thu, Mar 16, 2023 at 03:03:42PM +0100, Jan Beulich wrote: > On 16.03.2023 14:54, Roger Pau Monné wrote: > > On Tue, Mar 14, 2023 at 08:56:29PM +0000, Volodymyr Babchuk wrote: > >> +{ > >> + return atomic_read(&refcnt->refcnt); > >> +} > >> + > >> +static inline void refcnt_get(refcnt_t *refcnt) > >> +{ > >> + int old = atomic_add_unless(&refcnt->refcnt, 1, 0); > >> + > >> + if ( unlikely(old < 0) || unlikely (old + 1 < 0) ) > > ^ extra space > > > > You want a single unlikely for both conditions. > > Are you sure? My experience was generally the other way around: likely() > and unlikely() become ineffectual as soon as the compiler needs more > than one branch for the inner construct (ie generally for and && or ||).
Oh, OK, never mind then. We have examples of both in the code base. Roger.