From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935110AbcIPO3h (ORCPT ); Fri, 16 Sep 2016 10:29:37 -0400 Received: from mail-sn1nam01on0128.outbound.protection.outlook.com ([104.47.32.128]:36512 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757911AbcIPO31 (ORCPT ); Fri, 16 Sep 2016 10:29:27 -0400 From: KY Srinivasan To: KY Srinivasan , "gregkh@linuxfoundation.org" , "linux-kernel@vger.kernel.org" , "devel@linuxdriverproject.org" , "olaf@aepfle.de" , "apw@canonical.com" , "vkuznets@redhat.com" , "jasowang@redhat.com" , "leann.ogasawara@canonical.com" CC: Vivek Yadav Subject: RE: [PATCH 1/1] Drivers: hv: hv_util: Avoid dynamic allocation in time synch Thread-Topic: [PATCH 1/1] Drivers: hv: hv_util: Avoid dynamic allocation in time synch Thread-Index: AQHSECQx58KeIUTSzkudxMvYxrXOlaB8KExQ Date: Fri, 16 Sep 2016 14:13:26 +0000 Message-ID: References: <1474041638-17658-1-git-send-email-kys@exchange.microsoft.com> <1474041678-17701-1-git-send-email-kys@exchange.microsoft.com> In-Reply-To: <1474041678-17701-1-git-send-email-kys@exchange.microsoft.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=kys@microsoft.com; x-originating-ip: [103.194.12.37] x-ms-office365-filtering-correlation-id: 8fe78ad8-890d-4176-1b85-08d3de3ba0a4 x-microsoft-exchange-diagnostics: 1;DM5PR03MB2490;6:B3r4SZk7jXDvKXAfyy3Ki1Io49kJfAASk0BhQfY2xGzsWD1J0kM0BQi74u4xXPh295ILgAGWiRduDx8l70tl+ntptiaJxeGxNaMpi0dYx0L4dq5+zbNK5j+O7mBtF+lNCXl/PNBrDsZoai8kfJoJnb2y+XlWfRTlYA2CezRELU3F5hawElXeBowfEVneW51+5aQBK+4n2qkKc7a4EX1QmjLwep1JiIN1WjfJmjlrTNoJdd094Y1AddcolZFX1ZWw24ylU/GxQ6zAXOeiO5bFT+FBdKZQ3tihLrcGvu/uynFGm1p+Kc3XsDDXK/2klUYTPq5etS16Xd1xdtxuvyB6vQ==;5:Xnp4SmQVtfdHoUjYc/Ghy54w9RHARMnkMcufCe1/ZuXkFUngfRpQyymXds7MNSKrHryirKE5o2j9BraubPrJFA7tfuIywqrB9UUgjaC4g1WXPo68czJgpNGukmh/9ZtxFza9mDshNhmHEGo3q2wksA==;24:nACJw4EtzLp00OpCBFi9MKl9EtQR4lIPzJXkFvjbLULLatlvZvurjB4bbzCSsoGW6+eP9TCszyX0e3mxil/zYHbitmFaupk9oW7/XVnrhCI=;7:kw1Nn1FAWGY2sy5ygwZxxdoWhqgAgNuN3Ol2v7lLA19HteOfG+tjE2KYWajRusSwxDFaHtpeMmjj+5U+grKTdQ6V/yB0+dMUoOChJo4Kcc7xtRg75Ja9dHLslgBl2BzhBb1v25GO4vcwUJNr7Sml5A38E29j41HG/TAedqaGMXIqpi3E6IA6n6NPZNq6RXNyybQIlaZzpCUxsB7dz7Jo9zn+L3iot5mlh5mzuVx9prYGkxvDUlRPlJMPtAq8xLg2 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM5PR03MB2490; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(140211028294663)(198206253151910); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040176)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026)(61426038)(61427038);SRVR:DM5PR03MB2490;BCL:0;PCL:0;RULEID:;SRVR:DM5PR03MB2490; x-forefront-prvs: 0067A8BA2A x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(7916002)(13464003)(377454003)(199003)(189002)(92566002)(8990500004)(5001770100001)(1511001)(10090500001)(97736004)(76576001)(3280700002)(107886002)(2421001)(189998001)(8676002)(7736002)(5005710100001)(19580405001)(122556002)(2501003)(2561002)(68736007)(74316002)(81166006)(19580395003)(81156014)(10400500002)(7846002)(305945005)(10290500002)(2900100001)(54356999)(77096005)(2201001)(76176999)(2950100001)(105586002)(5002640100001)(33656002)(8936002)(50986999)(4001430100002)(99286002)(106356001)(5660300001)(9686002)(86362001)(3846002)(106116001)(586003)(3660700001)(11100500001)(102836003)(6116002)(87936001)(101416001)(66066001)(2906002)(86612001)(4326007)(7696004)(14444003);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR03MB2490;H:DM5PR03MB2490.namprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Sep 2016 14:13:26.7336 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2490 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id u8GETfbv013017 > -----Original Message----- > From: kys@exchange.microsoft.com [mailto:kys@exchange.microsoft.com] > Sent: Friday, September 16, 2016 9:31 PM > To: gregkh@linuxfoundation.org; linux-kernel@vger.kernel.org; > devel@linuxdriverproject.org; olaf@aepfle.de; apw@canonical.com; > vkuznets@redhat.com; jasowang@redhat.com; > leann.ogasawara@canonical.com > Cc: Vivek Yadav ; KY Srinivasan > > Subject: [PATCH 1/1] Drivers: hv: hv_util: Avoid dynamic allocation in time > synch > > From: Vivek yadav > > Under stress, we have seen allocation failure in time synch code. Avoid > this dynamic allocation. > > Signed-off-by: Vivek Yadav > Signed-off-by: K. Y. Srinivasan Greg, Please ignore this patch, It is already committed and got sent because of a glitch. Regards, K. Y > --- > drivers/hv/hv_util.c | 39 ++++++++++++++++++++++++++++----------- > 1 files changed, 28 insertions(+), 11 deletions(-) > > diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c > index 6286bdc..4aa3cb6 100644 > --- a/drivers/hv/hv_util.c > +++ b/drivers/hv/hv_util.c > @@ -64,9 +64,14 @@ static struct hv_util_service util_shutdown = { > .util_cb = shutdown_onchannelcallback, > }; > > +static int hv_timesync_init(struct hv_util_service *srv); > +static void hv_timesync_deinit(void); > + > static void timesync_onchannelcallback(void *context); > static struct hv_util_service util_timesynch = { > .util_cb = timesync_onchannelcallback, > + .util_init = hv_timesync_init, > + .util_deinit = hv_timesync_deinit, > }; > > static void heartbeat_onchannelcallback(void *context); > @@ -201,7 +206,6 @@ static void hv_set_host_time(struct work_struct > *work) > host_ts = ns_to_timespec(host_tns); > > do_settimeofday(&host_ts); > - kfree(wrk); > } > > /* > @@ -217,22 +221,24 @@ static void hv_set_host_time(struct work_struct > *work) > * typically used as a hint to the guest. The guest is under no obligation > * to discipline the clock. > */ > +static struct adj_time_work wrk; > static inline void adj_guesttime(u64 hosttime, u64 reftime, u8 flags) > { > - struct adj_time_work *wrk; > > - wrk = kmalloc(sizeof(struct adj_time_work), GFP_ATOMIC); > - if (wrk == NULL) > + /* > + * This check is safe since we are executing in the > + * interrupt context and time synch messages arre always > + * delivered on the same CPU. > + */ > + if (work_pending(&wrk.work)) > return; > > - wrk->host_time = hosttime; > - wrk->ref_time = reftime; > - wrk->flags = flags; > + wrk.host_time = hosttime; > + wrk.ref_time = reftime; > + wrk.flags = flags; > if ((flags & (ICTIMESYNCFLAG_SYNC | ICTIMESYNCFLAG_SAMPLE)) != > 0) { > - INIT_WORK(&wrk->work, hv_set_host_time); > - schedule_work(&wrk->work); > - } else > - kfree(wrk); > + schedule_work(&wrk.work); > + } > } > > /* > @@ -457,6 +463,17 @@ static struct hv_driver util_drv = { > .remove = util_remove, > }; > > +static int hv_timesync_init(struct hv_util_service *srv) > +{ > + INIT_WORK(&wrk.work, hv_set_host_time); > + return 0; > +} > + > +static void hv_timesync_deinit(void) > +{ > + cancel_work_sync(&wrk.work); > +} > + > static int __init init_hyperv_utils(void) > { > pr_info("Registering HyperV Utility Driver\n"); > -- > 1.7.4.1