From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753010AbbLJKSr (ORCPT ); Thu, 10 Dec 2015 05:18:47 -0500 Received: from mail-bn1bbn0101.outbound.protection.outlook.com ([157.56.111.101]:1604 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751735AbbLJKSn convert rfc822-to-8bit (ORCPT ); Thu, 10 Dec 2015 05:18:43 -0500 Authentication-Results: spf=pass (sender IP is 23.103.249.84) smtp.mailfrom=microsoft.com; linuxfoundation.org; dkim=none (message not signed) header.d=none;linuxfoundation.org; dmarc=pass action=none header.from=microsoft.com; From: Dexuan Cui 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 Thread-Topic: [PATCH V2 02/10] Drivers: hv: utils: run polling callback always in interrupt context Thread-Index: AQHREqN/B3uPQ5hvd0CAAnuI1+1NHp7EObOg Date: Thu, 10 Dec 2015 10:18:33 +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: <1446167566-19448-2-git-send-email-kys@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [141.251.197.68] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD024;1:aXctuV/vkPSMIKv9PAQBBlvJXm+IwjQvJIacuxw2l1ctPxErVSXzvi5IJkfcClzws0Up1mfJiviRFNxZECWyW5Z1fhSvaZX2wVICFcZgVGxqTrz319/fPAOG9G5b3LHSkowr5dg6Ms0zMFV8YdTrQdWy7NUvVOUECe8f7KLvN3W29NHmkz+oI2Erda/eBmdEHPzTGMiCkj4DQjGt2D/Bi5VULxGwe+iwtuO4P3rBdDI5LTtAfHl/ulhj0sgsU+RBVVj2+Pm5ujOBYpoONZHdaXV1/0yWiCChhz4thEjsPUpdMLrcJqyOwe/SeVC9AZ01lwD5FD7siSKasIQ1R7+y9uy04ggfx44mkSYK/KkZxRU8UkO4ztMUNgLI/e/3gqbqW5vMhmp6Rf40RSE8ihkVrw== X-Forefront-Antispam-Report: CIP:23.103.249.84;CTRY:;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(438002)(13464003)(199003)(164054003)(189002)(50986999)(76176999)(5003600100002)(108616004)(11100500001)(10400500002)(54356999)(97756001)(5005710100001)(2561002)(92566002)(2950100001)(10290500002)(6806005)(102836003)(5004730100002)(47776003)(5008740100001)(86362001)(24736003)(10090500001)(2501003)(66066001)(86612001)(2201001)(1511001)(2900100001)(33646002)(106116001)(23726003)(189998001)(1096002)(69596002)(6116002)(87936001)(1220700001)(19580395003)(551934003)(81156007)(50466002)(86146001)(2421001)(3846002)(586003)(107886002)(5001960100002)(46406003)(5001770100001)(19580405001)(16796002)(97736004)(106466001);DIR:OUT;SFP:1102;SCL:1;SRVR:SN2PR03MB045;H:064-smtp-out.microsoft.com;FPR:;SPF:Pass;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB045;2:JunHzDVTSa318ZLzTOqrfR0IivxNh89+76WNZ02hlGXaeR08njJp1QuD5kHiozGJIG1OIupcqF9EgyuxziYwu+70FR1IkCBO28ILuspxtb7KE7dL752oPcBV786734N0JN3ikz/2ft6NeGDYRdZkpw==;3:eUNf6zhAIPe3cig/gkJn9vNiXmarfVp1jYD08Cd/cTKvWh9BJURY1jXXUeig+M+3RE0nM+2w5aXO5b9hB9qd0XtKTiwp6Hu1HEls2519QVriyS5/5olNyHIUD5nUmVeD+N0R2bLE107AjVCQu3Qe+uuVUkgUZ9KEXCp8jmAOAyyNZAs4fyGTSWsvfrZsHCTuRj7fiHNHxuINnD/YKNZaX/KxeBTKeTaHWE/JyWk2cHKoW0KFjtdra8puLgQSau2Q;25:wXvLbIe9Gomo/os0c4MjSpWziqFmYA3DI4wNigU6aTsUsnJKTVnozRYcyYw0DXCZOa2a6nUWCxjEsxC495YL478SE7ZOIX+f5mX+6zNlMuZvy6ZRRI1sZDB5GDRwl+MHBY5obRaiMT4oDAdp6VXmZfBIeMzMvvuQRNMMon5r2FTPZxu9HfZ1sKoLKb3loBNXlMp3HdBC3/vskoalIvon03g3JfKB6q0NzSS/k9it3C4mIObKg68ojSiN8OFh+nCwr5eG/ZjJ/w+4H0rK7J5zqQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(8251501001);SRVR:SN2PR03MB045; X-O365EOP-Header: O365_EOP: Allow for Unauthenticated Relay X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB045;20:yyUq5AQRJQWj+MD9OfSLizaH6Zw/ELbyIZ/OhALKbzjVRXLNbO3yyajoEa64bJWFIBFyKasXzah7waFbpPn8FiKHn68u0bac15YDGqNvJLReJzlv54HscHWIuMMc70iN/+DtP3eX8rw1DxA0jRHhHTp0ujxvfNcCHusvSYWa5knNTzdbg2sTMMQju1KBq7/6NYkCNRgn+cfPwrMNtOXhx9Ulf1aNFsGd+fghalyeDv78QNgVPoHE1UulE7J5fqzvibtIW5mKCz9ULIazfBTfbAr70uvHMDP1klSwFiEEFMeJUkYm9Km7CwFoatHvIIj4pLqGLgnvv1/OqWeLF9l7xHIZW+yZbNBd1wpEa+1hSdqVwQU5RLN9fOuz9nDuWXm/OpNsINSzMw4vnT6IsaVQRbebCftjrh+v6kiujHSiXn6S6d/XpGTvI9WK0RXdtcopXd/7X5ROCxKotNGAXXoXarw68y26Ebbtobg2CWnlKLhDrr4FuATnNAsS2WpTfMR5deFkNzqC2HVPGrAI/pXs1CYc9qQ60vFNee6y+cDm49g82oFVHjyWc8+1AMOgo/OcpkHuR8Uv+OQLXgVZw6ccB5buCV6SlXj5hOclsFwR8bg= 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:SN2PR03MB045;BCL:0;PCL:0;RULEID:;SRVR:SN2PR03MB045; X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB045;4:xN3ucdpSSU2yCdzqDRXLQ5BVqrl0fcR6RCjPVfiValZZHNwmlsYwZnIQ+Rxym4ujlc3dP5zuEsJWAPKKo7kV2EIXQd17NABsT6Wa1BDbXFUbzBZ2mw7EHcj2ELiCXBtSV6/7saIpK33OSQBwJ06BYehsSMQng6T2mhpoU6ENctMgz4ykuqyRZtsa1v0FWSFedSIPL3KU2ZFEY/wjzCIuZCEBewOyikeqP4eukJ4sOiOAA3F5L5bJyM5wNRqA4FABJ486j7l/T+GWGrkSMl6i7bdYo6eDh/1yi8SidLePGN2ireuZ+XidQ554bcnOeZa8In3q4eME9NdPZjDi04LelSj8MdTCIXePn8Tgl2IhZjN6yvTDDgovx9wh7+GDR43KG2ZqglENkxMk9ISUHmbFMKTMlkPdy+99tcq9rVBsweGDESGTv/GeVp93DRUTfkQ9 X-Forefront-PRVS: 078693968A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN2PR03MB045;23:Cfhbq2kDJ+gYntAj2NewI5G/Qi5oJRkvSa+ZFH8TkF?= =?us-ascii?Q?IrDdyVqdJtHc+An3z5rOaMN7/ssRWjPBpNPSaq5YRZi0YB948rEJZQKQL+x8?= =?us-ascii?Q?feaSKKNJ1937LEjyrN9+t2HTsgdGdleYztN08OQeYj5pvtpUSPSluzoFmdzl?= =?us-ascii?Q?w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+vnsrWmfTW/O?= =?us-ascii?Q?qMDcC2zIOi8wRksYbzQoq2BlGxER173tvA/MW48Pmh5AYwv+945x5bd274Qe?= =?us-ascii?Q?yfOpIy3SdohbJhfcTxq/DjAc3/hl/Fyqppw1Dc3mPkuMQplIttSFPqSY1AxD?= =?us-ascii?Q?tK889Hgu9ja5EkRd42+ccod++7bIgUnGSX5PWIIkuph1GVfVg1VB3cr9+m/g?= =?us-ascii?Q?A3jvRv2KGnZyjySX25wf7WhvaA0mlNrhqN/HOtvJqwocBfkj4zpi35LKtxao?= =?us-ascii?Q?RphmNkuPERE0S1mSxyUyvjsotN/7bVN39wJI2N3NVpQ0WN2mePM/eO6Gav9v?= =?us-ascii?Q?F9OEZYaIXvfT1r56mDCJ0qPbPEaQqGpwU7qs8A4+IynIzBadJb7joqO1DJ8m?= =?us-ascii?Q?+WtucgV7567R8l+zz1PvnweS/ORFlwFDMpgGagXYA2yfDuA5kyFjUNuFnXlz?= =?us-ascii?Q?Qa/+a45WPT/BCGL996IPRQ1Bzt1ma+BZc=3D?= X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB045;5:tXBCsMyeHcGD8TXeYc1aJMZK33Ursd0VERxkGNYQD3eB1+YkNDrxaqIayVXWTWu3VLq0fV6t61xoJYwb1dUIfC81mHwhSmWFyrNvb7d0AJ9tJwpqwlKWpXe5HDh2Q+A5P1yhmrSUWNtptThe2oIhog==;24:ITGGnfjwgZ4uTJjg05jAb+it9t/KRCVktQRj0mkQAvA3LgfTGRBbVUxcVckB4d+0WoPFMMrjYF17g237nGvtNOsB6+ffP8gB3t3+n6afdx8= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2015 10:18:40.4178 (UTC) X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=72f988bf-86f1-41af-91ab-2d7cd011db47;Ip=[23.103.249.84];Helo=[064-smtp-out.microsoft.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB045 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----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? 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. Thanks, -- Dexuan