From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D084C282E3 for ; Sun, 26 May 2019 19:16:26 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id B53A82075E for ; Sun, 26 May 2019 19:16:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=Mellanox.com header.i=@Mellanox.com header.b="BppN5H1k" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B53A82075E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8736CF11; Sun, 26 May 2019 21:16:24 +0200 (CEST) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40044.outbound.protection.outlook.com [40.107.4.44]) by dpdk.org (Postfix) with ESMTP id A5982A49 for ; Sun, 26 May 2019 21:16:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MCQCuFZ724XTbi1r3eagtEY+azS756zKh8EyZJq8gOU=; b=BppN5H1kXqVbEsuUBoXIQMFGoy0KvCHF4GtvuUs/y4gPGwIFwfIzs5HSeOzFXpAh66NO9UC4ez1ayY0ZZ0BC4OUwO7NBq4D//JuRgYPkWf1vxKxlDONwTc8dfEuH+wB7OwlsCguTO7miuI3vMsuledQLGLFCp5SzEIgswUukgkg= Received: from AM0PR0502MB3795.eurprd05.prod.outlook.com (52.133.45.150) by AM0PR0502MB3953.eurprd05.prod.outlook.com (52.133.33.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1922.15; Sun, 26 May 2019 19:16:22 +0000 Received: from AM0PR0502MB3795.eurprd05.prod.outlook.com ([fe80::8c0:a6ef:6abc:334d]) by AM0PR0502MB3795.eurprd05.prod.outlook.com ([fe80::8c0:a6ef:6abc:334d%7]) with mapi id 15.20.1922.021; Sun, 26 May 2019 19:16:22 +0000 From: Shahaf Shuler To: Slava Ovsiienko , "dev@dpdk.org" CC: Yongseok Koh Thread-Topic: [dpdk-dev] [PATCH] net/mlx5: fix event handler uninstall Thread-Index: AQHVEtvoKrBmukrfWkmaEKfMartXO6Z9yPgA Date: Sun, 26 May 2019 19:16:22 +0000 Message-ID: References: <1558776365-28511-1-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1558776365-28511-1-git-send-email-viacheslavo@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=shahafs@mellanox.com; x-originating-ip: [31.154.10.105] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: af30591f-4db0-4188-d92f-08d6e20ea3c0 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600148)(711020)(4605104)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:AM0PR0502MB3953; x-ms-traffictypediagnostic: AM0PR0502MB3953: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 0049B3F387 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(39860400002)(346002)(396003)(136003)(376002)(199004)(189003)(33656002)(186003)(14444005)(6436002)(478600001)(99286004)(73956011)(3846002)(66446008)(68736007)(76116006)(66556008)(64756008)(6116002)(26005)(66476007)(71190400001)(71200400001)(5660300002)(11346002)(476003)(52536014)(446003)(486006)(76176011)(14454004)(8676002)(86362001)(2906002)(66066001)(7696005)(102836004)(74316002)(6506007)(8936002)(6246003)(110136005)(305945005)(53936002)(256004)(55016002)(66946007)(25786009)(2501003)(316002)(81166006)(4326008)(229853002)(81156014)(9686003)(7736002)(107886003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB3953; H:AM0PR0502MB3795.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: hhW31xmtaPyfytPP4AMUI1zp4VZwhwD7W5PT9RzGEBVRdwY6TN/X1FEy5hxqE+IEAxe7vl8HsEiROy66lfb1KfAiKXOq+QEPTvBm34qUFibAuNkfNIFHVglN//9aLozwSpk4ZvDtEnPuLM6iSsHnQRwu3Roai7TzN+HSTbFhWOMXpe0DNYcXaB4w/5afrn+MdulUgzSrQXTYu2u4SkiXSZW8DpO+W8lYtnTOj3TLxbkKplSyFZZByddXD6/byGt93fT4Ar5op1Ae/UMzvIJVcxsSFOYVq1fhwPFownJlMr9Ec8zIQrrAqzskl6fRuHkvHUl1Gi0DAfuNKtIBQ/xTQuvfhk3L7HTdiszpI2fSfSUbjwgmBW3oAFBPPnN7FKPY5AQgrYJO81tT6OockHOTgrrIeVJ2WDNdSutxVbXruM4= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: af30591f-4db0-4188-d92f-08d6e20ea3c0 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 May 2019 19:16:22.3508 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: shahafs@mellanox.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB3953 Subject: Re: [dpdk-dev] [PATCH] net/mlx5: fix event handler uninstall 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Slava, Saturday, May 25, 2019 12:26 PM, Of Viacheslav Ovsiienko: > Subject: [dpdk-dev] [PATCH] net/mlx5: fix event handler uninstall >=20 > When device is being closed and tries to unregister interrupt callback, t= here is > a chance the handler is still active (called in context of eal_intr_threa= d_main > thread). If so the rte_intr_callback_unregister returns -EAGAIN and keeps > the handler registered, causing crash when underlaying resourse is gone > away. >=20 > This race condition may happen if event handling in application takes a l= ong > time. We should check the return code of unregistering routine and try ag= ain > to unregister the handler. The diagnostic messages are shown once a > second, while trying to unregister. >=20 > Fixes: 028b2a28c3cb ("net/mlx5: update event handler for multiport IB > devices") >=20 > Signed-off-by: Viacheslav Ovsiienko > Acked-by: Yongseok Koh > --- [...] > + */ > +void > +mlx5_intr_callback_unregister(const struct rte_intr_handle *handle, > + rte_intr_callback_fn cb_fn, void *cb_arg) { > + /* > + * Try to reduce timeout management overhead by not calling > + * the timer related routines on the first iteration. If the > + * unregistering succeeds on first call there will be no > + * timer calls at all. > + */ > + uint64_t twait =3D 0; > + uint64_t start =3D 0; > + > + do { > + int ret; > + > + ret =3D rte_intr_callback_unregister(handle, cb_fn, cb_arg); > + if (ret >=3D 0) > + return; > + if (ret !=3D -EAGAIN) { > + DRV_LOG(INFO, "failed to unregister interrupt" > + " handler (error: %d)", ret); > + assert(false); > + return; > + } > + if (twait) { > + struct timespec onems; > + > + /* Wait one millisecond and try again. */ > + onems.tv_sec =3D 0; > + onems.tv_nsec =3D NS_PER_S / MS_PER_S; I get the below when trying to compile on top of Bluefield: /.autodirect/swgwork/shahafs/workspace/dpdk.org/drivers/net/mlx5/mlx5_ethde= v.c:1272:20: error: 'NS_PER_S' undeclared (first use in this function); did= you mean 'NB_SEGS'? onems.tv_nsec =3D NS_PER_S / MS_PER_S; ^~~~~~~~ NB_SEGS /.autodirect/swgwork/shahafs/workspace/dpdk.org/drivers/net/mlx5/mlx5_ethde= v.c:1272:20: note: each undeclared identifier is reported only once for eac= h function it appears in /.autodirect/swgwork/shahafs/workspace/dpdk.org/drivers/net/mlx5/mlx5_ethde= v.c:1272:31: error: 'MS_PER_S' undeclared (first use in this function); did= you mean 'NS_PER_S'? onems.tv_nsec =3D NS_PER_S / MS_PER_S; ^~~~~~~~ NS_PER_S /.autodirect/swgwork/shahafs/workspace/dpdk.org/drivers/net/mlx5/mlx5_ethde= v.c:1275:9: error: implicit declaration of function 'rte_get_timer_cycles';= did you mean 'rte_get_ptype_name'? [-Werror=3Dimplicit-function-declaratio= n] if ((rte_get_timer_cycles() - start) <=3D twait) ^~~~~~~~~~~~~~~~~~~~ rte_get_ptype_name /.autodirect/swgwork/shahafs/workspace/dpdk.org/drivers/net/mlx5/mlx5_ethde= v.c:1275:9: error: nested extern declaration of 'rte_get_timer_cycles' [-We= rror=3Dnested-externs] /.autodirect/swgwork/shahafs/workspace/dpdk.org/drivers/net/mlx5/mlx5_ethde= v.c:1284:12: error: implicit declaration of function 'rte_get_timer_hz'; di= d you mean 'rte_gettid'? [-Werror=3Dimplicit-function-declaration] twait =3D rte_get_timer_hz(); ^~~~~~~~~~~~~~~~ rte_gettid /.autodirect/swgwork/shahafs/workspace/dpdk.org/drivers/net/mlx5/mlx5_ethde= v.c:1284:12: error: nested extern declaration of 'rte_get_timer_hz' [-Werro= r=3Dnested-externs]