Received: by 10.223.185.116 with SMTP id b49csp3196868wrg; Mon, 5 Mar 2018 16:18:52 -0800 (PST) X-Google-Smtp-Source: AG47ELvKXFjj2Gq6GDlV6ezYH5wRjDoKpuNK58m7mfkO9lxcTp9/2UiUzm/RTcllcnaaeXVTvTPk X-Received: by 2002:a17:902:ab8c:: with SMTP id f12-v6mr14592260plr.171.1520295532228; Mon, 05 Mar 2018 16:18:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520295532; cv=none; d=google.com; s=arc-20160816; b=L6R3KKtlBs6Xj3NToM4LTLmMt+ONdsQxAUTj+Ip7l3MgbOfqQp8t4gRSknxORQ2uNG 3QyDsDVx4YzMR3p6PpC97ma4g0mg1B7Sm6GKIBppxxdHLdyIj/5WA8zNRkNSDeG2TxCX +t3J9sbzmkwLCo9C3zTpCp20h7Sn3qfMcutOj1N6xXx15xxCzY6jSQmH5S60goD3Fjkw iuVRFFxwkjRmIXAjIusYkT+pxPMCiN16xjjbz+y28+jRpWBO1rRAd5xN72HK2weAFKyy hZ2eAAPE7YG/H38sVTUEaQQ+m/oLYW0c4jDP3p6T/4odo/Foa1fHEo7Ngs4+jYoRm4ko 8iHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:msip_labels :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=FkALAnp8EcKKExX8t+z78xK0d5KPyUInbJntbniWKSU=; b=V2Kf0PoXc5QJl44TZXvDn40Bb0WkCa5c9umtiqp5pATIGlJAbafwuqO8EqZ0wtwBN5 Us1EZ0bRusHWoFImquVZRrfbG3BbtUIipwjolUsIjJAelJ3Einxvyh3OposVGaceau1s 898YB6eDxzAHSZ95u8EFEtB7jWhdOafV/NmNN2U7pjkAGKZPivTPmNdXY0co0hbJ9iA+ 6a1/6LXC3uc9kHIdxfN6JW43sgn93hwxlrk7sIO210XRwMrGZXIzv5BbP8uik0dqoGoZ 8ipZNkszpMPYcLJ8onn7hK4iHm07QMYFcGk0OBXCoCEKwdwCCgvBCtf5IdHS9WPtXAqb L4jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=eHOtYGpo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l3si10991157pfi.178.2018.03.05.16.18.35; Mon, 05 Mar 2018 16:18:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=eHOtYGpo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932933AbeCFARb (ORCPT + 99 others); Mon, 5 Mar 2018 19:17:31 -0500 Received: from mail-pu1apc01on0099.outbound.protection.outlook.com ([104.47.126.99]:40736 "EHLO APC01-PU1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932885AbeCFAR0 (ORCPT ); Mon, 5 Mar 2018 19:17:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=FkALAnp8EcKKExX8t+z78xK0d5KPyUInbJntbniWKSU=; b=eHOtYGpoNdcZnUQuj8JoQIs0Qk/alwyV6DItxAjcDCazCNJvCirROztHm1T6bIv1y0ll/eeeebD8LRwwSBOcVtjjQwXul/9EvauzpA5XNI92BT9SvyJXaw8gidGh1x2NYq9NgQe4WStQqpfTTlDE4NosnGRBFlQXhrIw8AfbyOc= Received: from KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM (10.170.167.17) by KL1P15301MB0085.APCP153.PROD.OUTLOOK.COM (10.170.161.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.7; Tue, 6 Mar 2018 00:17:06 +0000 Received: from KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM ([10.170.167.17]) by KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM ([10.170.167.17]) with mapi id 15.20.0588.001; Tue, 6 Mar 2018 00:17:06 +0000 From: Dexuan Cui To: "Michael Kelley (EOSG)" , "bhelgaas@google.com" , "linux-pci@vger.kernel.org" , KY Srinivasan , Stephen Hemminger , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" CC: "linux-kernel@vger.kernel.org" , "driverdev-devel@linuxdriverproject.org" , Haiyang Zhang , "vkuznets@redhat.com" , "marcelo.cerri@canonical.com" , Jack Morgenstein , "stable@vger.kernel.org" Subject: RE: [PATCH v2 5/6] PCI: hv: hv_pci_devices_present(): only queue a new work when necessary Thread-Topic: [PATCH v2 5/6] PCI: hv: hv_pci_devices_present(): only queue a new work when necessary Thread-Index: AQHTtLdILulEelG7Ik+GDDlpqOy57KPCTzkAgAAF6iA= Date: Tue, 6 Mar 2018 00:17:06 +0000 Message-ID: References: <20180305192134.32207-1-decui@microsoft.com> <20180305192134.32207-6-decui@microsoft.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=mikelley@ntdev.microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2018-03-05T23:47:30.5230940Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic; Sensitivity=General authentication-results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; x-originating-ip: [2001:4898:80e8::46e] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;KL1P15301MB0085;7:UuUOmIdmV0vArSFHt0GwKkLzaeBg4DJt+DnKAt8XyG5xptmqlG6hvFoB/nk48cFYxD+y5YfRbHUdbW+fA+UFESl2zeSfKrZ1kDPrslMR7rZfjoDv5iZ5C7lGMh5wkQJYOk8MdeioK0OH/nbOy5mBwJlrbbVO9HLqahjGOj3I/UFYGBqyhZYXGJ9NXJwfJH3Awer8srTYC7BxF1cD4e5gvuPlMNQt+DqZ3kvpHKta6Hs1E69NvIhVJnRsw65PwHqI;20:5mQ0bEkfYuPj9P05VYG+sLokoJAgKaOTBuK1yXh2wl7YexqxBNVCsz1R/jfXyfACNy4IYL0FrpV7SuIIn9b7qt52xGQw349ez35MnJZJslZWSIIuqGF/xGPtI1tZeOLaiT6RG9GrzdbZZXUmi9KMHnUsixR8o1Mf/zQE6I91UNU= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 5516826e-b1bd-4152-23b8-08d582f79872 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(2017052603328)(7193020);SRVR:KL1P15301MB0085; x-ms-traffictypediagnostic: KL1P15301MB0085: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(8121501046)(5005006)(3002001)(10201501046)(3231220)(944501244)(52105095)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123560045)(20161123564045)(6072148)(201708071742011);SRVR:KL1P15301MB0085;BCL:0;PCL:0;RULEID:;SRVR:KL1P15301MB0085; x-forefront-prvs: 06036BD506 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39860400002)(39380400002)(366004)(396003)(376002)(346002)(199004)(189003)(305945005)(81166006)(81156014)(106356001)(2201001)(10090500001)(316002)(99286004)(5660300001)(54906003)(97736004)(86612001)(74316002)(6506007)(33656002)(1511001)(86362001)(105586002)(102836004)(59450400001)(7416002)(22452003)(8990500004)(8936002)(8676002)(110136005)(7696005)(46003)(7736002)(6116002)(3280700002)(2501003)(6436002)(2906002)(25786009)(2950100002)(55016002)(10290500003)(53936002)(3660700001)(68736007)(14454004)(76176011)(77096007)(2900100001)(478600001)(9686003)(4326008)(229853002)(6246003);DIR:OUT;SFP:1102;SCL:1;SRVR:KL1P15301MB0085;H:KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Q9WSljVYY2desXwXVg+BErO5ehRhquFyXDi02rtp+kFFTBLHjEnzRqrjLSgW8NvNuldoozxJioVV955OzsaPSfiVLwlcrw0QWN2AHZ/dwWgo2nw5ZJhlww9n+s1RyYK0NUAPY+/B8u7oEPX0Y+22TFvpA3rlv7t8g2AOYKXoz9ZffEuJnVXGouoT0gnJLhWTRxHQADmp0sp09V/VFS/IyfYaIsXQIXybubIRwn17nYpDezHBSm8gLcaLb3MjE87M6OHxIFZndzEVziqhQ47HhEAgtd8c1Mq5kOoF3Exa7WNgUE6y9ic2Ut9jd5W61qlAwbky0/CNO5ktmSovI1BKvg== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5516826e-b1bd-4152-23b8-08d582f79872 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Mar 2018 00:17:06.3768 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1P15301MB0085 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > From: Michael Kelley (EOSG) > Sent: Monday, March 5, 2018 15:48 > > @@ -1756,11 +1757,23 @@ static void hv_pci_devices_present(struct > hv_pcibus_device > > *hbus, > > } > > > > spin_lock_irqsave(&hbus->device_list_lock, flags); > > + > > + /* > > + * If pending_dr is true, we have already queued a work, > > + * which will see the new dr. Otherwise, we need to > > + * queue a new work. > > + */ > > + pending_dr =3D !list_empty(&hbus->dr_list); > > list_add_tail(&dr->list_entry, &hbus->dr_list); > > - spin_unlock_irqrestore(&hbus->device_list_lock, flags); >=20 > A minor point: The spin_unlock_irqrestore() call can > stay here. Once we have the list status in a local variable > and the new entry is added to the list, nothing bad can > happen if we drop the spin lock. At worst, and very unlikely, > we'll queue work when some other thread has already queued > work to process the list entry, but that's no big deal. I'd argue > for keeping the code covered by a spin lock as small as possible. >=20 > Michael I agree. Will fix this in v3. > > > > - get_hvpcibus(hbus); > > - queue_work(hbus->wq, &dr_wrk->wrk); > > + if (pending_dr) { > > + kfree(dr_wrk); > > + } else { > > + get_hvpcibus(hbus); > > + queue_work(hbus->wq, &dr_wrk->wrk); > > + } > > + > > + spin_unlock_irqrestore(&hbus->device_list_lock, flags); > > } To receive more comments from others, I'll hold off v3 until tomorrow. Thanks, -- Dexuan