From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id F004671 for ; Mon, 29 Sep 2014 11:44:18 +0200 (CEST) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by fmsmga102.fm.intel.com with ESMTP; 29 Sep 2014 02:50:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,619,1406617200"; d="scan'208";a="480698096" Received: from irsmsx101.ger.corp.intel.com ([163.33.3.153]) by azsmga001.ch.intel.com with ESMTP; 29 Sep 2014 02:50:35 -0700 Received: from irsmsx155.ger.corp.intel.com (163.33.192.3) by IRSMSX101.ger.corp.intel.com (163.33.3.153) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 29 Sep 2014 10:50:01 +0100 Received: from irsmsx104.ger.corp.intel.com ([169.254.5.248]) by IRSMSX155.ger.corp.intel.com ([169.254.14.152]) with mapi id 14.03.0195.001; Mon, 29 Sep 2014 10:50:00 +0100 From: "Ananyev, Konstantin" To: "Wodkowski, PawelX" , Neil Horman Thread-Topic: [dpdk-dev] [PATCH v2] Change alarm cancel function to thread-safe: Thread-Index: AQHP2MAqmY9s5RkexE+yRGxj2kXnOpwR4sKAgAAPjwCAABZmAIAAZLsAgADPUACAAB2vsIAAAhgAgAAUZmCAAAJtAIAACzAAgAALEACAAB2GAIAAGaqAgALq0gCAAE0RAIAAsPTwgAA1SuA= 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> In-Reply-To: Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH v2] Change alarm cancel function to thread-safe: X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Sep 2014 09:44:19 -0000 > -----Original Message----- > From: Wodkowski, PawelX > Sent: Monday, September 29, 2014 7:41 AM > To: Neil Horman; Ananyev, Konstantin > Cc: dev@dpdk.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