Received: by 10.213.65.68 with SMTP id h4csp2121766imn; Sun, 8 Apr 2018 20:14:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx49v04PaWxj1HFBoE9WRAdKGVQKQpjxw48QIvNitHdSxdXv9N5w2SVWzPqg+ARKDsOR4ChPe X-Received: by 10.98.19.132 with SMTP id 4mr27415646pft.87.1523243283954; Sun, 08 Apr 2018 20:08:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243283; cv=none; d=google.com; s=arc-20160816; b=wRyWOKoiMCEhK5dTt4QDqaZ6vcZJWDW4x97lSxt6noJGY38osOTM64lGwBlhu4HOez Ko32eWlmjtXVIEGGc3u+Q0ff5EnzbjDfL7Ip7uHiHfDfaqfOiF26yky3JM/uTwfxLSEO 0HTkxpwaKDoPI0h4oFBk0jo9JbgJh+MIBx5WcVw4i3oCVzBNI/UTxGeZc2l0TfTtT6Qs zio9O7/kTSjirvbkPwv63zJi7oaKNXOey7Oku4Scth7e1Xiz1ccqW+vqpIhV6ju05cjo j+4ZdtBMUQF59oNWCN2RFdQ8FRgYnXZIAr8wQtyxBJ16sk+ejyuuoxN1xEREHfn0guOh r1IA== 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=IQ8HoETNxVG1yw+ePtUCXtzJNNkTh3dkiyBt0d54kXI=; b=F/5Dd6l+wgvhgBJThwNfYri9N0jLIkUvPbq25NK0A4BhWmlNzBaTV9nPN7dUmQVuzm cundd4Q4VoZQ6BWLwLE4/bLzSl41nCG5iq9U4hkoFRaanJK0VHsKWqJ2CDcv7Zno2Io+ oDIo0Aoy/+RZkd4wgB0DrWVJBLy0rCuVlRr4eGT3mnXqu2e4iIG/6ZLr7JGwiQ+kd+zr xc3q9KcBErZO8aO+chY9OYiacVQd3uHwlPJYOybS6v/P/L2IPYbL6vk3IF0jZnVLCMSf 7jGV+V+qLbbwQ32QzK1fIQwgisfTwmDDei5YKtoF1sNieq0/PblBfssrmtZsdel2Zat7 Efyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=k4rmkTZU; 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 61-v6si13761613plz.630.2018.04.08.20.07.22; Sun, 08 Apr 2018 20:08:03 -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=k4rmkTZU; 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 S1755875AbeDIA2h (ORCPT + 98 others); Sun, 8 Apr 2018 20:28:37 -0400 Received: from mail-bn3nam01on0096.outbound.protection.outlook.com ([104.47.33.96]:38912 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755812AbeDIA23 (ORCPT ); Sun, 8 Apr 2018 20:28:29 -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=IQ8HoETNxVG1yw+ePtUCXtzJNNkTh3dkiyBt0d54kXI=; b=k4rmkTZUrZTdZgG5qji1HwLldEPNY9UqNbubhdrSjnZQNGTkP/FL6NphfO3za4tkgYyo5iCaIGezKJFxLMi+Dgzuzyxnvs8ucB0Orvx+LxJl1QO7JDi2D3evVmO8iATn6QKuYogrdo84NMgcAXOvizkTFGCeds+tTiu9OeeqfX4= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0807.namprd21.prod.outlook.com (10.167.110.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.3; Mon, 9 Apr 2018 00:28:27 +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:28:27 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: WANG Cong , Jamal Hadi Salim , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 073/293] net_sched: move tcf_lock down after gen_replace_estimator() Thread-Topic: [PATCH AUTOSEL for 4.9 073/293] net_sched: move tcf_lock down after gen_replace_estimator() Thread-Index: AQHTz5kI5bHtrvQjqUOFH/ek0xZDHw== Date: Mon, 9 Apr 2018 00:23:51 +0000 Message-ID: <20180409002239.163177-73-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;DM5PR2101MB0807;7:D/tRZAlVNf8bonJJUqS6Df88p/5NtM66rOAIkNjfWx+3V9LyYPIQcVUXs04tfJv8fhjCk8KJLC9H6vecbUlK8sGhGrJQ3DgpkFbDBvcwpISgufWTDWQI5/EfMyjMhqM/87UyCo/NzSHosDnmfGbyeiDNeGKeS3KqHtfR1YoEJqfIcetwu3U413aOYDDOuYuI4KWxmC2bNNOeWfobgAsFsxZniW0TpXUVcZyicsV2x8PIk1FQQPjGLkI/dahAUku6;20:v52Rklh3Zu5KqyLumW/aXHJ2vbtwVkSXRYocE9tw90SAygjs0+S0vI/uICowYgQL4K2EQ6XAj45N3ODLesSuETHiuRPRHkBrzYRI9FYlUCDlCLF/RhSZYvFTI+yBa62BvnukaqykPNS95gP2M15QOizXVeWWVCAyoUIHK8Zu2rQ= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 7edc1f60-dadf-4714-fd6f-08d59db0d00d x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0807; x-ms-traffictypediagnostic: DM5PR2101MB0807: 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)(85827821059158)(17755550239193); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231221)(944501327)(52105095)(3002001)(6055026)(61426038)(61427038)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB0807;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0807; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(39860400002)(396003)(366004)(376002)(346002)(199004)(189003)(14454004)(4326008)(54906003)(25786009)(53936002)(2900100001)(1076002)(3280700002)(6486002)(186003)(2616005)(68736007)(110136005)(11346002)(10090500001)(6116002)(107886003)(3846002)(36756003)(8676002)(72206003)(22452003)(66066001)(26005)(39060400002)(6512007)(478600001)(3660700001)(81156014)(86362001)(81166006)(86612001)(7736002)(305945005)(8936002)(10290500003)(6436002)(105586002)(6666003)(316002)(575784001)(59450400001)(76176011)(5660300001)(476003)(106356001)(2906002)(6506007)(446003)(2501003)(99286004)(5250100002)(486006)(102836004)(97736004)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0807;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: +TYQNrUg+AmFvtSiCwxnDgrcUfD14O3zp7Kqk+N5qsxPdVtwsdtGzLQFWHTAj8sll05dcbnyM7mAnxpnumfWOdlmG7gcm4C7m2QOuT8Khjfr6KKkPtRWD56gdU1Q7J5DhPdyq+b8bMnzU2pFNewR6rppJgLll8TdE0u7CHRBUep4WFdINOXFi2rUEeIl2s8xRBQ5klbHa+hRB8DYrtTMBp5q5SPsJN3oI+9sfDzTBdmpjWygyeLaqzv2YWE+wGY4JSPn/pX1QUNKxpSSOcZNIUmL8cyv0OBFQcJsMQKtFSGJg7mVu2YUDyCDV4jQKXtgmU3NS1zLHXgFFZJBXgq3SeKeLF+MHvsQJ/xNb6LIKKYocKtOh+M/eJaUCxA02akFHOdDUahQg6FUG5p9yZa7Pao+2k0KHwj8pFy4oExvJgQ= 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: 7edc1f60-dadf-4714-fd6f-08d59db0d00d X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:23:51.3312 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0807 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: WANG Cong [ Upstream commit 74030603dfd9f76c0f279f19f1dd1ee3028fee7a ] Laura reported a sleep-in-atomic kernel warning inside tcf_act_police_init() which calls gen_replace_estimator() with spinlock protection. It is not necessary in this case, we already have RTNL lock here so it is enough to protect concurrent writers. For the reader, i.e. tcf_act_police(), it needs to make decision based on this rate estimator, in the worst case we drop more/less packets than necessary while changing the rate in parallel, it is still acceptable. Reported-by: Laura Abbott Reported-by: Nick Huber Cc: Jamal Hadi Salim Signed-off-by: Cong Wang Acked-by: Jamal Hadi Salim Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sched/act_police.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net/sched/act_police.c b/net/sched/act_police.c index d1bd248fe146..ca30796290aa 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -132,22 +132,22 @@ static int tcf_act_police_init(struct net *net, struc= t nlattr *nla, } } =20 - spin_lock_bh(&police->tcf_lock); if (est) { err =3D gen_replace_estimator(&police->tcf_bstats, NULL, &police->tcf_rate_est, &police->tcf_lock, NULL, est); if (err) - goto failure_unlock; + goto failure; } else if (tb[TCA_POLICE_AVRATE] && (ret =3D=3D ACT_P_CREATED || !gen_estimator_active(&police->tcf_bstats, &police->tcf_rate_est))) { err =3D -EINVAL; - goto failure_unlock; + goto failure; } =20 + spin_lock_bh(&police->tcf_lock); /* No failure allowed after this point */ police->tcfp_mtu =3D parm->mtu; if (police->tcfp_mtu =3D=3D 0) { @@ -193,8 +193,6 @@ static int tcf_act_police_init(struct net *net, struct = nlattr *nla, =20 return ret; =20 -failure_unlock: - spin_unlock_bh(&police->tcf_lock); failure: qdisc_put_rtab(P_tab); qdisc_put_rtab(R_tab); --=20 2.15.1