From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0055.outbound.protection.outlook.com [104.47.41.55]) by dpdk.org (Postfix) with ESMTP id 286A458D8 for ; Thu, 22 Sep 2016 11:29:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=harmonic.onmicrosoft.com; s=selector1-harmonicinc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=1y+u/Jnc37EwigpafGHju8NZuqVRzUNR2Va56XNysBk=; b=mbb6b545PVSd96mG/ZKPTnlerrf55pqAx+JIj7ffvC0cxApHcPvEmjEV4fvrw/to9tPullZdvi/k+/UtFRQHfHL6CkB6DML39EEezFFsRUYRjQqll9akGx7i7pKzUroLoRMwZ57NNbiyj0JYUx7yUpk+t/zQ89Xm+G/iIp/XquY= Received: from MWHPR11MB1360.namprd11.prod.outlook.com (10.169.235.22) by MWHPR11MB1357.namprd11.prod.outlook.com (10.169.232.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.8; Thu, 22 Sep 2016 09:29:01 +0000 Received: from MWHPR11MB1360.namprd11.prod.outlook.com ([10.169.235.22]) by MWHPR11MB1360.namprd11.prod.outlook.com ([10.169.235.22]) with mapi id 15.01.0629.006; Thu, 22 Sep 2016 09:29:01 +0000 From: Vladyslav Buslov To: Stephen Hemminger , Ferruh Yigit CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] kni: add support for core_id param in single threaded mode Thread-Index: AQHSE23mmjhr3dPq70+BF5hO1nXy2aCEKW4AgAACTgCAABf+gIAAWawAgACh8hA= Date: Thu, 22 Sep 2016 09:29:00 +0000 Message-ID: References: <20160910135016.6468-2-vladyslav.buslov@harmonicinc.com> <20160920181637.26778-1-vladyslav.buslov@harmonicinc.com> <20160920113636.38b2ed2a@xeon-e3> <366f0b2a-abb6-9fdc-cd12-d79185d32c5e@intel.com> <20160921164444.6ea1030e@xeon-e3> In-Reply-To: <20160921164444.6ea1030e@xeon-e3> 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=Vladyslav.Buslov@harmonicinc.com; x-originating-ip: [95.67.66.62] x-ms-office365-filtering-correlation-id: 7b2ec47b-0f02-4eea-cfdf-08d3e2cae346 x-microsoft-exchange-diagnostics: 1; MWHPR11MB1357; 20:IwQeSZh/ie1RA9wob8Qy1OLPbLXlicslsmRbJr8+E7kVTFf2Awq4/DbVaGgNQUnQo4MCx4m+xv1/LuLQ8tHyHBvUaIcp4i4Dhfccndy8jIuFucNG0uPgbuDsyygwIsTM+rpI6tqr7e4m9HTnDjTaiHw8rhCx1UtbKPcjfXKytDg= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:MWHPR11MB1357; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:MWHPR11MB1357; BCL:0; PCL:0; RULEID:; SRVR:MWHPR11MB1357; x-forefront-prvs: 0073BFEF03 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(377454003)(199003)(24454002)(189002)(3280700002)(86362001)(105586002)(99286002)(106356001)(106116001)(7696004)(11100500001)(10400500002)(189998001)(7736002)(2900100001)(7846002)(2950100001)(74316002)(122556002)(5660300001)(92566002)(305945005)(5001770100001)(97736004)(8936002)(5002640100001)(68736007)(33656002)(66066001)(93886004)(76576001)(3660700001)(77096005)(54356999)(19580395003)(102836003)(3846002)(6116002)(19580405001)(4326007)(8676002)(50986999)(101416001)(81166006)(9686002)(87936001)(81156014)(586003)(76176999)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR11MB1357; H:MWHPR11MB1360.namprd11.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: harmonicinc.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: harmonicinc.com X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Sep 2016 09:29:00.8337 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 19294cf8-3352-4dde-be9e-7f47b9b6b73d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1357 Subject: Re: [dpdk-dev] [PATCH] kni: add support for core_id param in single threaded mode 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: Thu, 22 Sep 2016 09:29:03 -0000 > On Wed, 21 Sep 2016 19:23:47 +0100 > Ferruh Yigit wrote: >=20 > > On 9/21/2016 6:15 PM, Vladyslav Buslov wrote: > > >> On 9/20/2016 7:36 PM, Stephen Hemminger wrote: > > >>> On Tue, 20 Sep 2016 21:16:37 +0300 Vladyslav Buslov > > >>> wrote: > > >>> > > >>>> @@ -123,6 +125,9 @@ static int __net_init kni_init_net(struct net > *net) > > >>>> /* Clear the bit of device in use */ > > >>>> clear_bit(KNI_DEV_IN_USE_BIT_NUM, &knet- > >device_in_use); > > >>>> > > >>>> + mutex_init(&knet->kni_kthread_lock); > > >>>> + knet->kni_kthread =3D NULL; > > >>>> + > > >>> > > >>> Why not just use kzalloc() here? You would still need to init the > > >>> mutex etc, but it would be safer. > > >>> > > >> > > >> Hi Vladyslav, > > >> > > >> This is good suggestion, if you send a new version for this update, > > >> please keep my Ack. > > >> > > >> Thanks, > > >> ferruh > > > > > > Hi Ferruh, Stephen, > > > > > > Could you please elaborate on using kzalloc for this code. > > > Currently kni_thread_lock is value member of kni_net structure and > never explicitly allocated or deallocated. > > > Kni_kthread is pointer member of kni_net and is implicitly created an= d > destroyed by kthread_run, kthread_stop functions. > > > Which one of those do you suggest to allocate with kzalloc() and how > would it improve safety? > > > > > > > Currently: > > > > kni_init_net() { > > knet =3D kmalloc(..); > > .. > > mutex_init(..); > > knet->kni_thread =3D NULL; > > } > > > > If you allocate knet via kzalloc(), no need to assign NULL to > > kni_thread. Also this is safer because any uninitialized knet field > > will be zero instead of random value. > > > > This is what I understood at least J >=20 > Also any additional fields in knet will be set, avoiding any present or f= uture > uninitialized memory bugs. >=20 What about net_generic which is used instead of kmalloc in KNI code for new= er kernels? Quick skim through Linux code indicates that it doesn't zero out memory and= people memset it manually. Just add memset(0) in HAVE_SIMPLIFIED_PERNET_OPERATIONS code?