From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Ananyev, Konstantin" Subject: Re: [PATCH v2] Change alarm cancel function to thread-safe: Date: Mon, 29 Sep 2014 09:50:00 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258213874C5@IRSMSX104.ger.corp.intel.com> References: <20140926114630.GA3930@hmsreliant.think-freely.org> <20140926134014.GB3930@hmsreliant.think-freely.org> <20140926150156.GB5619@hmsreliant.think-freely.org> <2601191342CEEE43887BDE71AB9772582137D88E@IRSMSX104.ger.corp.intel.com> <20140926162134.GE5619@hmsreliant.think-freely.org> <2601191342CEEE43887BDE71AB9772582137D95F@IRSMSX104.ger.corp.intel.com> <20140926193905.GH5619@hmsreliant.think-freely.org> <2601191342CEEE43887BDE71AB9772582138410B@IRSMSX104.ger.corp.intel.com> <20140928204754.GC4012@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "dev-VfR2kkLFssw@public.gmane.org" To: "Wodkowski, PawelX" , Neil Horman Return-path: In-Reply-To: Content-Language: en-US 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" > -----Original Message----- > From: Wodkowski, PawelX > Sent: Monday, September 29, 2014 7:41 AM > To: Neil Horman; Ananyev, Konstantin > Cc: dev-VfR2kkLFssw@public.gmane.org > Subject: RE: [dpdk-dev] [PATCH v2] Change alarm cancel function to thread= -safe: >=20 > > Yes, this is my concern exactly. > > > > > If that's so, then I suppose we can do: make alarm_cancel() to retur= n a > > negative value for the case #3 (-EINPROGRESS or something). > > > Something like: > > > ... > > > if (ap->executing =3D=3D 0) { > > > LIST_REMOVE(ap,next); > > > rte_free(ap); > > > count++; > > > ap =3D ap_prev; > > > } else if (pthread_equal(ap->executing_id, pthread_self()) =3D=3D 0) = { > > > executing++; > > > } else { > > > ret =3D -EINPROGRESS; > > > } > > > ... > > > return ((ret !=3D 0) ? ret : count); > > > > > > So the return value will be > 0 for #1, 0 for #2, <0 for #3. > > > As I remember, you already suggested something similar in one of the = previous > > mails. > > Yes, I rolled the API changes I suggested in with this model, because I= wanted > > to be able to do precise specification of a timer instance to cancel, b= ut if > > we're not ready to make that change, I think what you propose above wou= ld be > > suffficient. Theres some question as to weather we would cancel timers= that > > are > > still pending on a return of -EINPROGRESS, but I think if we document i= t > > accordingly, then it can be worked out just fine. > > > > Best > > Neil > > >=20 > Image how you will be damned by someone that not even notice you change > and he Is managing some kind of resource based on returned number of > set/canceled timers. If you suddenly start returning negative values how = those > application will behave? Silently changing returned value domain is evil = in its > pure form. As I can see the impact is very limited. Only code that does check for (rte_alarm_cancel(...) =3D=3D 0/ !=3D 0) insi= de alarm callback function might be affected.=20 >>From other side, indeed, there could exist situations, when the caller need= s to know was the alarm successfully cancelled or not.=20 And if not by what reason.=20 >=20 > From my point of view, problem is virtual because this is user applicatio= n task to > know what it can and what it not. If you really want to inform user appli= cation > about timer state you can introduce API call which will interrogate timer= s list > and return appropriate value, but for god sake, do not introduce untracea= ble bugs. >=20 > Pawel