Received: by 10.213.65.68 with SMTP id h4csp2115059imn; Sun, 8 Apr 2018 20:05:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+d0FEWGU6OoWdBbQJV8CNK1eAHNVdzVnF9/bsf4tOvLIvPpue8cDQtv6cqwPtWpgKS+X0i X-Received: by 10.101.69.133 with SMTP id o5mr23678147pgq.156.1523243133992; Sun, 08 Apr 2018 20:05:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243133; cv=none; d=google.com; s=arc-20160816; b=P2BgXakMduV1EBDNRCQy+/n7xmxQYwhdcXql8DSCZDcqltXhz/BkAvCsGmzYoeYbkI 5HR/z+eiIGDZoWSrJhofV25c3A+SJZbHn8MEU65mGvwvRQMm2QQt0pCMzt+W3Zf4hSpu ypLciRgA7O+nX9qpIw+uMBHZm3xYr2kb72Zg/hh49p0oeunbUUoyw7mqjlmZOk3Aae9k EE21ArxfVDx6+29jJbpMqP5bBobfJoML3jRW4tgeCvPGoRte9XzeDHNyrlszUMPopdn/ qpGh1bsc2WouI1cmFSbuHlgqguSBiFs5joHINB9Q0MJWCRxGAoAXAx9bhk5KCohidrVF +DPw== 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: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=wIyr0FhEn/vTJ/Fc1FIUgk66gQ+Ux6FtihVmEYqNdHk=; b=G2Q5ouAnSj662UavV+yFeKqqbY+GEepB/MiGICY7gIy1u9TPNw81voiPsoiZNGAx4E gwMnHTiixaAZJBFY8HPM0pz99BVIEdsjbdS//yp3aETcxlzaqe6GS0hjPR+HRpgRfMjs 7bduVtanopoLugBeKE9GPHm7GQCU6aWjFFvzaPCSLCnIGw48Ahbodf0QZjfE1YJELbmG fidONmPP1atrmz3ih87V+S473+BDZ3ejSUJ3NG2UtTeUbG/w0xz+xFxfQ/CsPsulcUpQ pQxvgEYECBcHWhfL4totu38qP0aIgKhAWEzgY80/CimzAHXcQG1P3ZC0/92qdySRN/P2 lGPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=gbJG9XEv; 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 o69si11908315pfi.322.2018.04.08.20.04.57; Sun, 08 Apr 2018 20:05:33 -0700 (PDT) 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=gbJG9XEv; 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 S1755489AbeDIA05 (ORCPT + 99 others); Sun, 8 Apr 2018 20:26:57 -0400 Received: from mail-cys01nam02on0098.outbound.protection.outlook.com ([104.47.37.98]:9607 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754330AbeDIA0o (ORCPT ); Sun, 8 Apr 2018 20:26:44 -0400 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=wIyr0FhEn/vTJ/Fc1FIUgk66gQ+Ux6FtihVmEYqNdHk=; b=gbJG9XEvNna+53syhRMqocRcvQE64Q/z0e9+DqxZCSWoX/j/dIfeqNO9AUNhoHOP74I4OsDp/2TDsICd66HkBunTPEVuURgBT4rjZAu/s2d/t14r7+fH9Rckubf8yk1rNmJ3lZRgcebWmf+cndE5QR2qRcs6deYYpJuN9NhX8Xs= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1015.namprd21.prod.outlook.com (52.132.133.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:26:37 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:26:37 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: "Paul E. McKenney" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 013/293] rcu: Make synchronize_rcu_mult() check for duplicates Thread-Topic: [PATCH AUTOSEL for 4.9 013/293] rcu: Make synchronize_rcu_mult() check for duplicates Thread-Index: AQHTz5jpoc1keyMGgE+O0ZXLVRl4Gg== Date: Mon, 9 Apr 2018 00:22:58 +0000 Message-ID: <20180409002239.163177-13-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1015;7:Q18nVxacFZ9wEPPYrJUBBsjH0aI4xxaTs/aXrQ8Fo6hdCIWXjNrgDOhhdf0dwkS46w3NwkwWcas2yS9r/S5X+BgDrw1Kpnqm9IlCPXYsp3MrDGWGQaeeoJ5D1p3uHMjXtpLwwaev5xQzHFULd6WQ4yM9D+1oH0lFesva3xA2l4htLzlStKW/VmOtn7GNcEZpzkjRJCJIBCZo0Sq34aktdJboNs2MyazUY5wCERYOI2bBgOYESXDg/x89jgI/AmQg;20:tNiqBpnVqJ3xcVOmZ0jD9FNMUSJqKqxcUlmotP8NmHdF0rpSO4HNnO3y81/c2R0cl+4FGyfPtsMssVjnqP2wzMNqPzrZE78V4EhFqNg1/F6XMhV/NW2dpg/Sf/vVOLhq53kgMOxYifEmbq1lI0Ri/P3vW7txi9FXZbbxx/w3WMo= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: d766530e-f67a-44d5-2962-08d59db08e7d x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1015; x-ms-traffictypediagnostic: DM5PR2101MB1015: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(104084551191319); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1015;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1015; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(39380400002)(376002)(346002)(366004)(189003)(199004)(53936002)(4326008)(478600001)(72206003)(3280700002)(2616005)(14454004)(305945005)(5250100002)(3660700001)(2501003)(2900100001)(54906003)(110136005)(86362001)(1076002)(107886003)(6506007)(36756003)(446003)(68736007)(6512007)(7736002)(486006)(2906002)(5660300001)(6436002)(3846002)(86612001)(6486002)(66066001)(11346002)(575784001)(476003)(6666003)(59450400001)(26005)(10090500001)(316002)(22452003)(8676002)(81156014)(81166006)(6116002)(105586002)(99286004)(186003)(106356001)(76176011)(25786009)(97736004)(10290500003)(102836004)(8936002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1015;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: l7cR3swnH/qDORkW6ocB37BL0xaZrOYW0qZF864ESfqqdk+2R9HM3EeQFZqf+oiH+rxcDFens5H8gyRNNM4Agi1OkENLTzLqXw64GxgqMNpv/84MZOVod1oTYZMgMYk4pjM+ndpJ6IXmFwvmrLzUjJ6aEmOFha6EFiGN64LfZvsLr96/yjmeeX8au1Nejc5SHRLb6z215OPz0uWPxGiAfiewnhPXunyC/Nqng0CyIC7EayC/6V96lo2DbhSC9d+dnEGUkMmoOfo3lF04kffA7aBm6bjX4twt3eR01U8wEYhegf8Tcz6X98VYvMfdUMnRRLbIBoWUqGN3rf9LWDHK06mBct9kMbq5mUAZERx2uCfNvWdjM8RPjmfnV0nQGTGaSCku2fSbEHXeZEj+vdMvkZTEaec+0w5bKDabCLjOoy4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: d766530e-f67a-44d5-2962-08d59db08e7d X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:22:58.0341 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1015 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Paul E. McKenney" [ Upstream commit 68ab0b4263224157f4d0c0e42854169a183d7534 ] Currently, doing synchronize_rcu_mult(call_rcu, call_rcu) might (or might not) wait for two RCU grace periods. One approach is of course "don't do that!", but in CONFIG_PREEMPT=3Dn kernels, synchronize_rcu_mult(call_rcu, call_rcu_sched) does exactly that. This results in an ugly #ifdef in sched_cpu_deactivate(). This commit therefore makes __wait_rcu_gp() check for duplicates, which in turn allows duplicates to be passed to synchronize_rcu_mult() without risk of waiting twice on the same type of grace period. Signed-off-by: Paul E. McKenney Signed-off-by: Sasha Levin --- kernel/rcu/update.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c index 4f6db7e6a117..2164c9cc6fd8 100644 --- a/kernel/rcu/update.c +++ b/kernel/rcu/update.c @@ -346,6 +346,7 @@ void __wait_rcu_gp(bool checktiny, int n, call_rcu_func= _t *crcu_array, struct rcu_synchronize *rs_array) { int i; + int j; =20 /* Initialize and register callbacks for each flavor specified. */ for (i =3D 0; i < n; i++) { @@ -357,7 +358,11 @@ void __wait_rcu_gp(bool checktiny, int n, call_rcu_fun= c_t *crcu_array, } init_rcu_head_on_stack(&rs_array[i].head); init_completion(&rs_array[i].completion); - (crcu_array[i])(&rs_array[i].head, wakeme_after_rcu); + for (j =3D 0; j < i; j++) + if (crcu_array[j] =3D=3D crcu_array[i]) + break; + if (j =3D=3D i) + (crcu_array[i])(&rs_array[i].head, wakeme_after_rcu); } =20 /* Wait for all callbacks to be invoked. */ @@ -366,7 +371,11 @@ void __wait_rcu_gp(bool checktiny, int n, call_rcu_fun= c_t *crcu_array, (crcu_array[i] =3D=3D call_rcu || crcu_array[i] =3D=3D call_rcu_bh)) continue; - wait_for_completion(&rs_array[i].completion); + for (j =3D 0; j < i; j++) + if (crcu_array[j] =3D=3D crcu_array[i]) + break; + if (j =3D=3D i) + wait_for_completion(&rs_array[i].completion); destroy_rcu_head_on_stack(&rs_array[i].head); } } --=20 2.15.1