Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753960AbbLJXXM (ORCPT ); Thu, 10 Dec 2015 18:23:12 -0500 Received: from mail-bn1bon0119.outbound.protection.outlook.com ([157.56.111.119]:46544 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751043AbbLJXXK convert rfc822-to-8bit (ORCPT ); Thu, 10 Dec 2015 18:23:10 -0500 From: KY Srinivasan To: Dexuan Cui , "gregkh@linuxfoundation.org" , "linux-kernel@vger.kernel.org" , "devel@linuxdriverproject.org" , "olaf@aepfle.de" , "apw@canonical.com" , "vkuznets@redhat.com" , "jasowang@redhat.com" Subject: RE: [PATCH V2 02/10] Drivers: hv: utils: run polling callback always in interrupt context Thread-Topic: [PATCH V2 02/10] Drivers: hv: utils: run polling callback always in interrupt context Thread-Index: AQHREqNs9EyathPhHkS47FeNJvCQUJ7EQviAgADXb6A= Date: Thu, 10 Dec 2015 23:23:06 +0000 Message-ID: References: <1446167538-19409-1-git-send-email-kys@microsoft.com> <1446167566-19448-1-git-send-email-kys@microsoft.com> <1446167566-19448-2-git-send-email-kys@microsoft.com> In-Reply-To: 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: [2001:4898:80e8:3::344] x-microsoft-exchange-diagnostics: 1;BY2PR0301MB1656;5:HYekjLb0pBXZqZSWOfwAuGt/Lvf8qT4zVO7JNYb0DM0BRE2JKoQnnCVy5nIhvttvJCYkaO60uzbtMKm0De1QKSmxvEiX3CXJMNHD4te908Jga5HfnIalEOlownrbyKOE9NEtm7+fxe8uLj1z5Ex2dA==;24:/fEJHlT1I6R1LRqgEkjoI6mAyc+oAvhQlRSToOrmTCMN8q93CIicl+O4JUS5pMbOFDGEuHwQEnMfhYwvfAJP/Z3pUJix4VOdkD5Ki4WkJlI= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB1656; x-ld-processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(601004)(2401047)(520078)(8121501046)(5005006)(10201501046)(3002001)(61426038)(61427038);SRVR:BY2PR0301MB1656;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB1656; x-forefront-prvs: 078693968A x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(199003)(189002)(13464003)(377454003)(77096005)(2900100001)(81156007)(2950100001)(551934003)(101416001)(76176999)(50986999)(92566002)(33656002)(2421001)(93886004)(54356999)(2561002)(86612001)(40100003)(87936001)(86362001)(2201001)(97736004)(122556002)(105586002)(5001770100001)(5004730100002)(99286002)(106116001)(8990500004)(106356001)(11100500001)(74316001)(5005710100001)(10290500002)(10400500002)(2501003)(5002640100001)(5003600100002)(1511001)(586003)(107886002)(102836003)(189998001)(6116002)(5008740100001)(5001960100002)(1096002)(1220700001)(10090500001)(76576001)(19580395003)(19580405001)(3826002);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR0301MB1656;H:BY2PR0301MB1654.namprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Dec 2015 23:23:06.1618 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0301MB1656 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3986 Lines: 93 > -----Original Message----- > From: Dexuan Cui > Sent: Thursday, December 10, 2015 2:19 AM > 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 > Subject: RE: [PATCH V2 02/10] Drivers: hv: utils: run polling callback always in > interrupt context > > > -----Original Message----- > > From: devel [mailto:driverdev-devel-bounces@linuxdriverproject.org] On > Behalf > > Of K. Y. Srinivasan > > Sent: Friday, October 30, 2015 9:13 > > To: gregkh@linuxfoundation.org; linux-kernel@vger.kernel.org; > > devel@linuxdriverproject.org; olaf@aepfle.de; apw@canonical.com; > > vkuznets@redhat.com; jasowang@redhat.com > > Subject: [PATCH V2 02/10] Drivers: hv: utils: run polling callback always in > > interrupt context > > > > From: Olaf Hering > > > > All channel interrupts are bound to specific VCPUs in the guest > > at the point channel is created. While currently, we invoke the > > polling function on the correct CPU (the CPU to which the channel > > is bound to) in some cases we may run the polling function in > > a non-interrupt context. This potentially can cause an issue as the > > polling function can be interrupted by the channel callback function. > > Fix the issue by running the polling function on the appropriate CPU > > at interrupt level. Additional details of the issue being addressed by > > this patch are given below: > > > > Currently hv_fcopy_onchannelcallback is called from interrupts and also > > via the ->write function of hv_utils. Since the used global variables to > > maintain state are not thread safe the state can get out of sync. > > This affects the variable state as well as the channel inbound buffer. > > > > As suggested by KY adjust hv_poll_channel to always run the given > > callback on the cpu which the channel is bound to. This avoids the need > > for locking because all the util services are single threaded and only > > one transaction is active at any given point in time. > > > > Additionally, remove the context variable, they will always be the same as > > recv_channel. > > > > Signed-off-by: Olaf Hering > > Signed-off-by: K. Y. Srinivasan > > --- > > V2: Added the check to catch unsolicited daemon writes - Vitaly > > > > drivers/hv/hv_fcopy.c | 34 +++++++++++++--------------------- > > drivers/hv/hv_kvp.c | 28 ++++++++++------------------ > > drivers/hv/hv_snapshot.c | 29 +++++++++++------------------ > > drivers/hv/hyperv_vmbus.h | 6 +----- > > 4 files changed, 35 insertions(+), 62 deletions(-) > > (Sorry for not joining the discussion when the patch was firstly made) > > It looks the patch has not been Greg's tree yet. > > I have 2 questions about the patch: > > 1. hv_poll_channel() is invoked in fcopy_handle_handshake(), but not in > vss_handle_handshake() and kvp_handle_handshake(). > Why -- I guess we missed the vss/kvp cases somehow? I will fix this. > > 2. With the patch, hv_fcopy_onchannelcallback() can be invoked in the > tasklet (i.e., vmbus_on_event(). NB: local irq is enabled), and in the > hard irq handler(the IPI handler, e.g., > fcopy_poll_wrapper() -> fcopy_poll_wrapper()). > > Can the former be interrupted by the latter? > e.g., when the callback is running in the tasklet on vCPU0, > fcopy_timeout_func() or fcopy_on_msg() could send the IPI to > vCPU0 from another vCPU. Keep in mind that when the poll function is run, the state will not be HVUTIL_READY. The state will be set to HVUTIL_READY in the IPI handler. So, it is ok if the tasklet is interrupted by the IPI handler. Regards, K. Y -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/