From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0DF79A04DC; Tue, 20 Oct 2020 07:51:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4621DBAA8; Tue, 20 Oct 2020 07:51:02 +0200 (CEST) Received: from nat-hk.nvidia.com (nat-hk.nvidia.com [203.18.50.4]) by dpdk.org (Postfix) with ESMTP id 6696DBA7A; Tue, 20 Oct 2020 07:50:59 +0200 (CEST) Received: from HKMAIL104.nvidia.com (Not Verified[10.18.92.100]) by nat-hk.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Tue, 20 Oct 2020 13:50:57 +0800 Received: from HKMAIL104.nvidia.com (10.18.16.13) by HKMAIL104.nvidia.com (10.18.16.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 20 Oct 2020 05:50:55 +0000 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.43) by HKMAIL104.nvidia.com (10.18.16.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Tue, 20 Oct 2020 05:50:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aZoZFBsj88piwHniS+ByMlbAE7v1FcEsrx4IWBa0Wu+RJqjQOvUM8zIXNCftHCEelLVkC/53mCGgQaOU246s0NFb436YdiIq0PjXtc69cAKx1HK7YxCI3PhbtaVaeQLBHpWQUltez0rCrOy8nriUvsOUK7DfA2mb/horxqJ8grBONFZq2HnTZjV2SjNA22TPxDCYd5xzRD6d8KOZF2mGYey0snnMxU0XPZasdUzvD6ZOB9ENs2tkz6aCuTZs/EWRwhQqU78r7gXRTJqpbEmsQ0QdYUHkURK0yEC6TsoLVN9u6+azP1G5JV0lno1mzQktPzc7FlCcgiu1DEpIlc5u4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ALcpAHCTqKe7cqKzsTB0EKIyGUT3PL+lhdFK87pJHlU=; b=jXpL8KJJcya6ln3vkAkq1XyU2d9OjX6vPGcIKl1kBtpQWKzrhZSq4i7iU9j3982UQR1Tq3pGAI0onmbrJiPyQVpAO2YbuUfmOgZwfFGAH3XpXFKSJ36r6fKhF/O5ZQ2VRdIA29EF6nrMBuhnFdkyr/9fCiUJ2/nMohdxLZNCfPbYPuziq7leAXBpyBNLYaYdm2ZShSHrLy9+Wpkx7vpgs4Y5ap+Mq2uUuxgjwXN7RPEKWtZXfW6u81Eo4NknwFZh0IMMFcHqt2FVLHYNbzA38uMYx8dR2rmnLBsCz0NShZMIO7NmFpzjvT8185IJ2HsDImmi7KGgLNCL29VfbQ0aqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none Received: from MW2PR12MB2492.namprd12.prod.outlook.com (2603:10b6:907:8::19) by MWHPR1201MB0240.namprd12.prod.outlook.com (2603:10b6:301:58::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Tue, 20 Oct 2020 05:50:52 +0000 Received: from MW2PR12MB2492.namprd12.prod.outlook.com ([fe80::39f3:2b4b:6018:4b88]) by MW2PR12MB2492.namprd12.prod.outlook.com ([fe80::39f3:2b4b:6018:4b88%7]) with mapi id 15.20.3477.028; Tue, 20 Oct 2020 05:50:52 +0000 From: Matan Azrad To: NBU-Contact-longli , Long Li , Matan Azrad CC: "dev@dpdk.org" , "stable@dpdk.org" Thread-Topic: [PATCH] net/vdev_netvsc: Prevent alarm lost on failed device probe Thread-Index: AQHWoyoZruYPot+JAk2tlPdecNOsa6mc+TdAgAJwJICAAJk3oA== Date: Tue, 20 Oct 2020 05:50:52 +0000 Message-ID: References: <1602790385-13032-1-git-send-email-longli@linuxonhyperv.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=99fd5064-0836-40ac-9406-14ab91a2ce9f; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2020-10-19T20:32:01Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; authentication-results: microsoft.com; dkim=none (message not signed) header.d=none;microsoft.com; dmarc=none action=none header.from=nvidia.com; x-originating-ip: [77.126.110.58] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 76e51332-aa7b-4bc2-105e-08d874bc1ac2 x-ms-traffictypediagnostic: MWHPR1201MB0240: x-ld-processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr x-microsoft-antispam-prvs: x-ms-exchange-transport-forked: True x-ms-oob-tlc-oobclassifiers: OLM:525; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 34gCtXCHBVzRrg2tdC1ERaoPitBH+P3WQ7IkEKdMz+i5lINLQPxkS4e0BYJTFnsuVDcray8J5/WdsBWJ9ukCSX/fsjvl5Zrf4dlGIpuglwv+Nw43dWNWr2Wk0OMgOl4wCi6qzQNs7/r9Q7+JCBolfd3kcgzHfVJpt57nhARDQIfy7zRGtGJFse/S5JQOE/lgHkw9y24yH21VvJNchb0uNMITN2sodqTvKDEGzT8QzFV7XZn5e9vaQXqas94N+ir7aihZXPr0sZFGGE8LIm9zgPo7fYv5kdLhnKEqXxX7zt8UFA5v/lFS142qpDthILQrlsw2xjvcvU4OSw5WIGvZ5A== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW2PR12MB2492.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(136003)(346002)(376002)(396003)(366004)(76116006)(52536014)(71200400001)(9686003)(2906002)(83380400001)(5660300002)(64756008)(66446008)(66556008)(66476007)(66946007)(26005)(186003)(110136005)(316002)(478600001)(54906003)(8676002)(6506007)(55016002)(86362001)(33656002)(4326008)(8936002)(7696005); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: utEHMZyvyE34STg/1WOvPRZN4NVnTswblew3ryYBjAdZLkpWzpp/crp9rUnjukHGl2MF7Apf8e9NPRIib4dcFsGpjNgKpfNzAreaz2p6FZnY4SWJkmfHONfr4eAWzUlLnxoJ0mFPF/mCdSVIaFeYtJ8RJTxo91kFEXPpJBGq2tHA4gfFDA4kjKP3WlxqS+b756UJFwOwqKRz0YEKl5dFS/gLZZ9L+943h8Qnk7uMck3NEXHsN3TFOeAP5t4TvQ3UhNgHImB+XtH5sgR1bNgmQ+UaTTBGSWGh4Mv01L0tABPPFnVTjEKtqiSnS1GonEU9HQ4jMgRGdENTbGJvGkY13R4s69+i4hSEHC7teCKTS8GQsjERf5w7UQEoZWQGAejtHJkm+75X+kK9/D3zN18FKIH9qNg593qRxtOgWD8m1QAFctEQHrPJqjh+baKWATqhgJbuAqIuc1WlP4hxNtC0huQRcvRSxzBCsPm4dpfh0GUWHj+eiNg5U8SyITB5UL31FdP8Ux5TDfDf1Ozkcd90DnCGJZMdTKmjATfxGFWkvycPzIKm6NiGEvaZou89uZitoRDd/Ba8bxd3xVDIQS01ugyTXhdTkVYpS1SXJ/Gca6Uh2hWq9KRMfiyR6SI14DyLev57RP3XyGCkxtKn8FF/YQ== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW2PR12MB2492.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76e51332-aa7b-4bc2-105e-08d874bc1ac2 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Oct 2020 05:50:52.1656 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: OA6EHppuJZ6aq0ynh2LASP8VH7b0djVIOP5kmxRv49fTNiF2gu/MoQGoM+kbrCym4VaOB7tjSTnEMBan7E5Xtw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0240 X-OriginatorOrg: Nvidia.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1603173057; bh=ALcpAHCTqKe7cqKzsTB0EKIyGUT3PL+lhdFK87pJHlU=; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To: CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References: In-Reply-To:Accept-Language:Content-Language:X-MS-Has-Attach: X-MS-TNEF-Correlator:msip_labels:authentication-results: x-originating-ip:x-ms-publictraffictype: x-ms-office365-filtering-correlation-id:x-ms-traffictypediagnostic: x-ld-processed:x-microsoft-antispam-prvs: x-ms-exchange-transport-forked:x-ms-oob-tlc-oobclassifiers: x-ms-exchange-senderadcheck:x-microsoft-antispam: x-microsoft-antispam-message-info:x-forefront-antispam-report: x-ms-exchange-antispam-messagedata:Content-Type: Content-Transfer-Encoding:MIME-Version: X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-AuthSource: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-originalarrivaltime: X-MS-Exchange-CrossTenant-fromentityheader: X-MS-Exchange-CrossTenant-id:X-MS-Exchange-CrossTenant-mailboxtype: X-MS-Exchange-CrossTenant-userprincipalname: X-MS-Exchange-Transport-CrossTenantHeadersStamped:X-OriginatorOrg; b=LHo4b9h1lrSPnCR1vT8OdzsvD0RvErAJuawoxpAXed4E2SqvXZjcTjLJ7HWqkVCOI OLYmquFz0FYTMM30FD5/lLIQPqQXhfJgdiPAPLR8X2BX4NlJo6SyEniWb3gCrCuMxg v0VG+gkZYytWIztCJHNMTa4MUPoWQUPF1WZBCvzF+14cbwGADkQpybd3Fz4J4/XkqZ Ja1fGCy+zlw8u/pU2kihbAXSiSoWJ7Uu1mv0GX3raFdSvsUhKpm+Fab19VsY3QB0me sKTy9YCm6DfNLOErYuvSa5Nq0du6N1SJVV/czJaKs6PaA4wFpzjEm7wNt98JxLcT3u G0a3JEKRlyhMQ== Subject: Re: [dpdk-dev] [PATCH] net/vdev_netvsc: Prevent alarm lost on failed device probe 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" From: Long Li > > Subject: RE: [PATCH] net/vdev_netvsc: Prevent alarm lost on failed > > device probe > > > > > > > > From: Long Li > > > If a device probe fails, the alarm is canceled and will no longer > > > work for previously probed devices. > > > > > > Fix this by introducing a flag to track if alarm has been set. > > > Because it's possible that an alarm is triggered while probing is in > > > progress that may modify vdev_netvsc_ctx_list, introduce a lock to > protect it. > > > > > > Cc: stable@dpdk.org > > > Signed-off-by: Long Li > > > --- > > > drivers/net/vdev_netvsc/vdev_netvsc.c | 41 > > > +++++++++++++++++++++++++---------- > > > 1 file changed, 30 insertions(+), 11 deletions(-) > > > > > > diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c > > > b/drivers/net/vdev_netvsc/vdev_netvsc.c > > > index be8f19c..bd7e308 100644 > > > --- a/drivers/net/vdev_netvsc/vdev_netvsc.c > > > +++ b/drivers/net/vdev_netvsc/vdev_netvsc.c > > > @@ -76,6 +76,11 @@ struct vdev_netvsc_ctx { > > > /** Context list is common to all driver instances. */ static > > > LIST_HEAD(, > > > vdev_netvsc_ctx) vdev_netvsc_ctx_list =3D > > > LIST_HEAD_INITIALIZER(vdev_netvsc_ctx_list); > > > +/* Lock to protect concurrent accesses to vdev_netvsc_ctx_list */ > > > +static rte_rwlock_t vdev_netvsc_ctx_list_lock; > > > + > > > +/* Flag to track if alarm has been set */ static int > > > +vdev_netvsc_alarm_set; > > > > > > /** Number of entries in context list. */ static unsigned int > > > vdev_netvsc_ctx_count; @@ -454,19 +459,26 @@ static LIST_HEAD(, > > > vdev_netvsc_ctx) vdev_netvsc_ctx_list =3D > > > struct vdev_netvsc_ctx *ctx; > > > int ret; > > > > > > + rte_rwlock_write_lock(&vdev_netvsc_ctx_list_lock); > > > LIST_FOREACH(ctx, &vdev_netvsc_ctx_list, entry) { > > > ret =3D vdev_netvsc_foreach_iface(vdev_netvsc_device_= probe, 0, > > > ctx); > > > if (ret < 0) > > > break; > > > } > > > - if (!vdev_netvsc_ctx_count) > > > + rte_rwlock_write_unlock(&vdev_netvsc_ctx_list_lock); > > > + > > > + if (!vdev_netvsc_ctx_count) { > > > + vdev_netvsc_alarm_set =3D 0; > > > return; > > > + } > > > + > > > ret =3D rte_eal_alarm_set(VDEV_NETVSC_PROBE_MS * 1000, > > > vdev_netvsc_alarm, NULL); > > > if (ret < 0) { > > > DRV_LOG(ERR, "unable to reschedule alarm callback: %s= ", > > > rte_strerror(-ret)); > > > + vdev_netvsc_alarm_set =3D 0; > > > } > > > } > > > > > > @@ -698,34 +710,41 @@ static LIST_HEAD(, vdev_netvsc_ctx) > > > vdev_netvsc_ctx_list =3D > > > " device."); > > > goto error; > > > } > > > - rte_eal_alarm_cancel(vdev_netvsc_alarm, NULL); > > > + > > > + rte_rwlock_write_lock(&vdev_netvsc_ctx_list_lock); > > > /* Gather interfaces. */ > > > ret =3D vdev_netvsc_foreach_iface(vdev_netvsc_netvsc_probe, 1= , > > name, > > > kvargs, specified, &matched); > > > if (ret < 0) > > > - goto error; > > > + goto error_unlock; > > > if (specified && matched < specified) { > > > if (!force) { > > > DRV_LOG(ERR, "Cannot find the specified netvs= c device"); > > > - goto error; > > > + goto error_unlock; > > > } > > > /* Try to force probing on non-netvsc specified devic= e. */ > > > if > > > (vdev_netvsc_foreach_iface(vdev_netvsc_netvsc_probe, 0, > > name, > > > kvargs, specified, &mat= ched) < 0) > > > - goto error; > > > + goto error_unlock; > > > if (matched < specified) { > > > DRV_LOG(ERR, "Cannot find the specified devic= e"); > > > - goto error; > > > + goto error_unlock; > > > } > > > DRV_LOG(WARNING, "non-netvsc device was probed as > netvsc"); > > > } > > > - ret =3D rte_eal_alarm_set(VDEV_NETVSC_PROBE_MS * 1000, > > > + if (!vdev_netvsc_alarm_set) { > > > + ret =3D rte_eal_alarm_set(VDEV_NETVSC_PROBE_MS * 1000= , > > > vdev_netvsc_alarm, NULL); > > > - if (ret < 0) { > > > - DRV_LOG(ERR, "unable to schedule alarm callback: %s", > > > - rte_strerror(-ret)); > > > - goto error; > > > + if (ret < 0) > > > + DRV_LOG(ERR, "unable to schedule alarm callba= ck: %s", > > > + rte_strerror(-ret)); > > > + else > > > + vdev_netvsc_alarm_set =3D 1; > > > } > > > + > > > +error_unlock: > > > + rte_rwlock_write_unlock(&vdev_netvsc_ctx_list_lock); > > > + > > > error: > > > if (kvargs) > > > rte_kvargs_free(kvargs); > > > -- > > > > Hi > > > > Nice direction. > > > > As I understand from your patch it looks like you want to add support > > for the vdev_netvsc driver itself to be hot-plug aware - so it can be > > probed\removed in run-time (even after EAL initialization). > > So I think the title and commit log should be converted to this: > > net/vdev_netvsc: support driver instance hot-plug ... >=20 > Hi Matan, >=20 > Actually I was not trying to add support for hot-plug (although it made h= alf > way there). >=20 > The problem I'm trying to solve is on a system with multiple vdev_netvsc > interfaces. For example, if the system has eth1, eth2 .. eth10. What if t= he > probing on eth1 to eth9 succeed, but on eth10 fails? Current behavior is = that > we can still have DPDK run on eth1 to eth9, but without any alarms. Becau= se > the alarm is canceled while trying to probing eth10. Then once eth1 to et= h9 > lost VF, they won't get VF back because we don't have any alarms. >=20 > Long Ok, got you. So, why to manage critical sections in the code, better, to stop alarm befo= re adding a new device, and apply it back if the list of devices is not emp= ty. It will make it simpler, no? > > > > More things: > > Look on convention of the file - blank line only after variables > > declarations inside the blocks. > > > > Need to adjust also vdev_netvsc_vdev_remove to the feature. > > > > Matan