From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 3D8781BE16 for ; Wed, 4 Jul 2018 03:47:07 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jul 2018 18:47:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,306,1526367600"; d="scan'208";a="242438176" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga005.fm.intel.com with ESMTP; 03 Jul 2018 18:47:05 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 3 Jul 2018 18:47:05 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 3 Jul 2018 18:47:04 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.124]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.57]) with mapi id 14.03.0319.002; Wed, 4 Jul 2018 09:47:01 +0800 From: "Zhang, Qi Z" To: Thomas Monjalon CC: "dev@dpdk.org" , "Burakov, Anatoly" , "Ananyev, Konstantin" , "Richardson, Bruce" , "Yigit, Ferruh" , "Shelton, Benjamin H" , "Vangati, Narender" Thread-Topic: [dpdk-dev] [PATCH v8 04/19] ethdev: introduce device lock Thread-Index: AQHUEcfFbxDt7G1dj06vIuuMXtd6DqR8vnAAgAC+i3CAAA+dAIAAtvlg Date: Wed, 4 Jul 2018 01:47:00 +0000 Message-ID: <039ED4275CED7440929022BC67E7061153249CCA@shsmsx102.ccr.corp.intel.com> References: <20180607123849.14439-1-qi.z.zhang@intel.com> <3478184.SidI6Nhsfv@xps> <039ED4275CED7440929022BC67E7061153243573@SHSMSX103.ccr.corp.intel.com> <1712900.Rv84bhh2vl@xps> In-Reply-To: <1712900.Rv84bhh2vl@xps> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNjlmOTYxODgtNWQ3YS00MTBlLTllM2EtZTY0NjRkYmVkZmU3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoidlwvYXRNbmt4MXg5dGs2bEFpSWJrcXQyMEpIVGhKelwvc21zWnJWWUlYZVBZVm1kV1Z2K2t3TmswUUtVZkc5QktyIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v8 04/19] ethdev: introduce device lock X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jul 2018 01:47:08 -0000 > -----Original Message----- > From: Thomas Monjalon [mailto:thomas@monjalon.net] > Sent: Wednesday, July 4, 2018 6:14 AM > To: Zhang, Qi Z > Cc: dev@dpdk.org; Burakov, Anatoly ; Ananyev, > Konstantin ; Richardson, Bruce > ; Yigit, Ferruh ; She= lton, > Benjamin H ; Vangati, Narender > > Subject: Re: [dpdk-dev] [PATCH v8 04/19] ethdev: introduce device lock >=20 > 03/07/2018 17:08, Zhang, Qi Z: > > From: Thomas Monjalon [mailto:thomas@monjalon.net] > > > 02/07/2018 07:44, Qi Zhang: > > > > Introduce API rte_eth_dev_lock and rte_eth_dev_unlock to let > > > > application lock or unlock on specific ethdev, a locked device > > > > can't be detached, this help applicaiton to prevent unexpected > > > > device detaching, especially in multi-process envrionment. > > > > > > Trying to understand: a process of an application could try to > > > detach a port while another process is against this decision. > > > Why an application needs to be protected against itself? > > > > I think we can regard this as a help function, it help application to s= implified > the situation when one process want to detach a device while another one = is > still using it. > > Application can register a callback which can do to necessary clean up = (like > stop traffic, release memory ...) before device be detached. >=20 > Yes I agree such hook can be a good idea. >=20 >=20 > > > I guess it is only an application inter-process management. > > > If we really want to provide such helper in DPDK, it should not be > > > limited to ethdev. > > > > Once we move to eal layer, we will have rte_eal_dev_lock/unlock(devname= , > busname). > > But its also better we keep rte_eth_dev_lock/unlock to make ethdev API > > more completed (any port be locked means underline rte_device also be > locked?) and this is same for other device family. >=20 > No. Again, a port is not exactly a device. > There can be several ports per device. Yes, I know that. what I mean is, we should assume lock any port of that rte_device will prev= ent the device be detached. >=20 > I think the right place for this hook is in port-level API (ethdev, crypt= o, etc). And > as we improve only ethdev currently, without any common genericity for ot= her > device classes, it is probably fine in ethdev for now. > > > > > (for info, see class implementation: > > > https://patches.dpdk.org/patch/41605/) > > > > > > What about hardware unplug? > > > Can we detach the locked ports associated to the unplugged device? > > > > NO, we can't. > > But do you think, we need to introduce a "force detach" version, which = will > ignore all locks. >=20 > No, I don't think so. > I am just trying to show that you cannot really "lock" a port. > Maybe you should just rename those functions. > After all, it is just a pre-detach hook. > Wait, how is it different of RTE_ETH_EVENT_DESTROY callback? > Perhaps we just need to improve the handling of the DESTROY event? I have thought about this before. Not like RTE_ETH_EVENT_DESTROY and other event hook, the hook here need to = give feedback, pass or fail will impact the following behavior, this make i= t special, so I separate it from all exist rte_eth_event_type handle mechan= ism.=20 The alternative solution is=20 we just introduce a new event type like RTE_ETH_EVENT_PRE_DETACH and reuse = all exist API=20 rte_eth_dev_callback_register/rte_eth_dev_callback_unregister. But in _rte_eth_dev_callback_process we need to add a code branch for PRE_D= ETACH handle. If (event =3D RTE_ETH_EVENT_PRE_DETACH) <...>. else { <....> } And we may also need to keep rte_eth_dev_lock/unlock which will register a = default callback for PRE_DETACH. What do you think about? =20 >=20 >=20