From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00074.outbound.protection.outlook.com [40.107.0.74]) by dpdk.org (Postfix) with ESMTP id AA88CF72; Wed, 16 Jan 2019 07:34:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E73lEf35XVNxvgLavd2OpWuDjNK8uvOcG/s9K2zgLAo=; b=KaBMWGZp11wuLiMU1hePdF0fPwH+cqVuiKT+fx8V4kjZ6uTKGOFFxrZkkMqAucjKh2KJZUcw9JGnBgg3KDheWdLh8Isz8S5E7+4pQ60YQP4pZkv7WC76HnsIugUpcbyNEQaqmfYeTpEsAyxwOppG2DoJt99Sr2NaZdE9m0RZ0ko= Received: from DB7PR08MB3385.eurprd08.prod.outlook.com (20.176.238.90) by DB7PR08MB3452.eurprd08.prod.outlook.com (20.176.238.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.26; Wed, 16 Jan 2019 06:34:13 +0000 Received: from DB7PR08MB3385.eurprd08.prod.outlook.com ([fe80::a8d9:72eb:1c7f:c69f]) by DB7PR08MB3385.eurprd08.prod.outlook.com ([fe80::a8d9:72eb:1c7f:c69f%2]) with mapi id 15.20.1516.019; Wed, 16 Jan 2019 06:34:13 +0000 From: "Phil Yang (Arm Technology China)" To: Ferruh Yigit , "dev@dpdk.org" CC: "stable@dpdk.org" , "he.qiao17@zte.com.cn" , Igor Ryzhov , Dan Gora Thread-Topic: [PATCH] examples/kni: fix crash while handling userspace request Thread-Index: AQHUrPeye5DtjSrK4kSJhFqC2nFRU6Wxbd8w Date: Wed, 16 Jan 2019 06:34:13 +0000 Message-ID: References: <20190115172802.72238-1-ferruh.yigit@intel.com> In-Reply-To: <20190115172802.72238-1-ferruh.yigit@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Phil.Yang@arm.com; x-originating-ip: [113.29.88.7] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB7PR08MB3452; 6:h5weGXzkDdEaILzS2EqAA+yGMKasZ9vF0xSYh41dlhpP+jzCO6EbgiISc1t4boJaK6nh4Odr8u5G8ixRDJbraO/61GDT5fVVD5a32UlSZv4L82OWolAAia4P8Z29ODJwH4F54GZXC5P0fWzKGE+DHEeGKINaH8H9V5qbTCT03Bftg+J/ZdRgiAepInYehf2daLDlY8a/poKMVe7LaP17Cz7uKAL+UgK8Ji/6NZ4Le3d0PVZ9d9uhkQRI4r4Oe508NKw0iCSLrPAkr3Qmd2RQWI6/ZDnPhPnmdfh8++Me6QebN8QEvDCLre1gYMd+RLXULfwwSNH8mGcASkwsCv2mY3TmNM1kd2Y/IkxIcAVcGmJf+CLqn+GfhaGfRXaqpinfQ5eDaRqsTJhE+6dFhkCw8vI4BICuBmj5F/RQ3Fj4hWw1FWkwsh3GlGQytWu7VUJBAaZj8Y6aU10eFhO5F02ayw==; 5:U4yntQt8nogfcxTJ/XMSj/TUC8z4/KMU3i9kwgxcjnNhDCfUb7ZpWg1/9SVMVob+i+lJ4RN8PedE5kpsoWGYQsk80DO+YiH/anpRu1hEtnzg2VfRTfLeBiwAhJ0SMO7vkgCgzu2Z1y3tufKKeOYzzVHvnLkXoO+poZ5uVwnlwkHxTXTXYvY+bCzee4Zl7C3qb9qJfdUbifi5gpSh/EBJSA==; 7:1ekbD0mH+BgOGPUVeMXj3JHS0xPyW/Nt2QIMtRGMfVFDMKRSxqHi5NRNaHMwlvdbkLjr2O7kNR5ZJyHkIfOb/I8Q7/6YDOgklDMEBvOYQb6GKs6yEqUBFG5FNg7F+utZ6MXhZyoWgYYfHDU326oOqQ== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 8831af81-3adc-4606-af68-08d67b7ca19d x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB7PR08MB3452; x-ms-traffictypediagnostic: DB7PR08MB3452: x-microsoft-antispam-prvs: x-forefront-prvs: 091949432C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(376002)(39860400002)(136003)(346002)(366004)(40434004)(13464003)(199004)(189003)(9686003)(186003)(14454004)(2906002)(8936002)(71190400001)(71200400001)(6436002)(6116002)(3846002)(486006)(2501003)(478600001)(97736004)(55016002)(76176011)(72206003)(229853002)(7696005)(11346002)(476003)(66066001)(446003)(106356001)(74316002)(6246003)(5660300001)(54906003)(110136005)(256004)(81156014)(68736007)(55236004)(86362001)(53936002)(102836004)(26005)(33656002)(105586002)(99286004)(8676002)(81166006)(7736002)(316002)(4326008)(5024004)(14444005)(25786009)(53546011)(6506007)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR08MB3452; H:DB7PR08MB3385.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: FTJwpMONAva/TsDVgwihfuVM3u9xn2kmYXTZTHh8pzvxzwGB2SNJsZtjISfio3FBsexzRIMjgN8gADfXym+wDDmV7c3QC4WwjWBD4F2F1InpskrtQanfHu+MIPxKfCahgPtPxCZmu2GVeU6ruRq1TVQEZ/LMMmQOiGF0MfdIREmQYagMIPN8IISLbdhRcPiGn2pdc5xz7usK7ok3mtumI0K7tx2MXjNh1MWTvCgXY2bhgWgmM5C0BUNH5GdK8grHslGlUpLrV3XfCtKCxEFrKKXMj4RrFyLjej/1Gq3ylKCs7T7SMrqVe3qNVSt/5rxE6axV5EGZDwqr7RIUEjyBLg/4xaKA5/iuBgkqsN02lno/1LuT3MRaU/GhKXJpr2/y2GZjP952PezxCf/NLqIo8CZPqOcDb//lis+4aC+4svg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8831af81-3adc-4606-af68-08d67b7ca19d X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jan 2019 06:34:13.6505 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3452 Subject: Re: [dpdk-dev] [PATCH] examples/kni: fix crash while handling userspace request 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, 16 Jan 2019 06:34:14 -0000 Hi Ferruh, > -----Original Message----- > From: Ferruh Yigit > Sent: Wednesday, January 16, 2019 1:28 AM > To: dev@dpdk.org > Cc: stable@dpdk.org; he.qiao17@zte.com.cn; Igor Ryzhov > ; Phil Yang (Arm Technology China) > ; Dan Gora > Subject: [PATCH] examples/kni: fix crash while handling userspace request > > When KNI interface receives RTE_KNI_REQ_CFG_NETWORK_IF request, it > stap/start the physical device which as a result of stop() can free all t= he mbufs in > its queue. > Meanwhile sample application continues to read from KNI interface queues = and > push into device queues. This simultaneous access may cause a crash, cras= h log > can be found at defect description. > > As a solution KNI sample application can do the proper synchronization, a= nd > stop transfer between KNI interface and physical interface while physical= device > stop/started. > > Bugzilla ID: 116 > Fixes: 3fc5ca2f6352 ("kni: initial import") > Cc: stable@dpdk.org > > Signed-off-by: Ferruh Yigit > --- > Cc: he.qiao17@zte.com.cn > I am not able to re-produce the defect can you please test with this patc= h? > > And another concern is performance affect of this patch, new check is add= ed > into fast path. Cc'ed a few more people for comment: > Cc: Igor Ryzhov > Cc: Phil Yang > Cc: Dan Gora > --- > examples/kni/main.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/examples/kni/main.c b/examples/kni/main.c index > c468ffd19..a8ce07e2a 100644 > --- a/examples/kni/main.c > +++ b/examples/kni/main.c > @@ -132,6 +132,7 @@ static int kni_config_network_interface(uint16_t port= _id, > uint8_t if_up); static int kni_config_mac_address(uint16_t port_id, uint= 8_t > mac_addr[]); > > static rte_atomic32_t kni_stop =3D RTE_ATOMIC32_INIT(0); > +static rte_atomic32_t kni_pause =3D RTE_ATOMIC32_INIT(0); > > /* Print out statistics on packets handled */ static void @@ -276,6 +27= 7,7 @@ > main_loop(__rte_unused void *arg) { > uint16_t i; > int32_t f_stop; > +int32_t f_pause; > const unsigned lcore_id =3D rte_lcore_id(); > enum lcore_rxtx { > LCORE_NONE, > @@ -304,8 +306,11 @@ main_loop(__rte_unused void *arg) > kni_port_params_array[i]->port_id); > while (1) { > f_stop =3D rte_atomic32_read(&kni_stop); > +f_pause =3D rte_atomic32_read(&kni_pause); > if (f_stop) > break; > +if (f_pause) > +continue; > kni_ingress(kni_port_params_array[i]); > } > } else if (flag =3D=3D LCORE_TX) { > @@ -314,8 +319,11 @@ main_loop(__rte_unused void *arg) > kni_port_params_array[i]->port_id); > while (1) { > f_stop =3D rte_atomic32_read(&kni_stop); > +f_pause =3D rte_atomic32_read(&kni_pause); > if (f_stop) > break; > +if (f_pause) > +continue; > kni_egress(kni_port_params_array[i]); > } > } else > @@ -807,12 +815,16 @@ kni_config_network_interface(uint16_t port_id, > uint8_t if_up) > RTE_LOG(INFO, APP, "Configure network interface of %d %s\n", > port_id, if_up ? "up" : "down"); > > +rte_atomic32_inc(&kni_pause); > + > if (if_up !=3D 0) { /* Configure network interface up */ > rte_eth_dev_stop(port_id); > ret =3D rte_eth_dev_start(port_id); > } else /* Configure network interface down */ > rte_eth_dev_stop(port_id); > > +rte_atomic32_dec(&kni_pause); > + > if (ret < 0) > RTE_LOG(ERR, APP, "Failed to start port %d\n", port_id); > > -- > 2.17.2 Acked-by: Phil Yang Thanks, Phil Yang IMPORTANT NOTICE: The contents of this email and any attachments are confid= ential and may also be privileged. If you are not the intended recipient, p= lease notify the sender immediately and do not disclose the contents to any= other person, use it for any purpose, or store or copy the information in = any medium. Thank you.