From patchwork Sun Dec 6 23:59:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11954641 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69460C4167B for ; Mon, 7 Dec 2020 00:01:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31ABC22E03 for ; Mon, 7 Dec 2020 00:01:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728659AbgLGAA5 (ORCPT ); Sun, 6 Dec 2020 19:00:57 -0500 Received: from mail-eopbgr80054.outbound.protection.outlook.com ([40.107.8.54]:57805 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727661AbgLGAA4 (ORCPT ); Sun, 6 Dec 2020 19:00:56 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T5kMenTQubz3YtWuXqa/9xqBvgk9EUZguTgfF22nikDfuSM9ltRVvqMBHXgsk/laS9Cfit2dTIfrA6c3ZrcrmbR8Jifh8EQ/ZGO+wCLKp8hhLZkFuP05lHg3/0Gpw3uw3sAJFjpkX54c0huiNLVM1tFgu3CIMzWmR2QrR8hR412EhefrCJytt8q8ib1GOpOXj59ndJ83+DQO9sUbVOlVOVgYMMg+9s1TROCBggY+buSxi08peCAeoW14B5ahNY80+PtcYhQwVoI2ApsAY5dwIPlh95m75tPFD5g8lmjMNkBfirAXv3RzohFzmGGT9mIzoZh9jzLyUlym2M1hmIrpsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Xlyqz3yJ9njuGgQBhsUP396C/6uizMYwO6C+RU7vrhw=; b=oOIWH7C/pt794AsK3N2hWxIfxJ8I2VX4Ilo9Nj+wnU1EwTq6e2PgTSHkYemFNNkZv5IznRIsMtIiAz5J5LW6l5a2FMZGJiB5khMnwCwtle8xib3w3qjtKVTuJU0iGrqfzKq8GCnSdSQfotXISsS5MpetPO76E6f2nE946wMzb2dlaZVkQAe75O9bMCNJ26VbBDuv3bwc4ha8/SYYRdna0cIRvugN0tTUEwZPPCUQb/zP8pvBXB/YPbjU1vyPUqUEvcVYpJIq66lYPzFh441FTL5Lmj+TtqaDgqOoMwE0XD59r33RfKGHSK0HDQ13sTGeO0TNX+5V9e4JS8qEDhIZXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Xlyqz3yJ9njuGgQBhsUP396C/6uizMYwO6C+RU7vrhw=; b=C1EmycvCPuskpujXPq/eDecYd4YnLh66xnt/4kk4qTJ+omeHPNP0fwxoOFP0HzKxE4/kzSv7MOEn/sfXBJMoxk4CVQM+RNBWN4VFpge7Jjo0Wq/3csRKUiluvjbIHrocd3F/QuvGKEw7sSPLNx8mHGBCEv9OyN2C44hpH8Eeg2I= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VE1PR04MB6637.eurprd04.prod.outlook.com (2603:10a6:803:126::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17; Sun, 6 Dec 2020 23:59:59 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Sun, 6 Dec 2020 23:59:59 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , Paul Gortmaker , Pablo Neira Ayuso , Jiri Benc , Cong Wang , Jamal Hadi Salim , Stephen Hemminger , Eric Dumazet , George McCollister , Oleksij Rempel , Leon Romanovsky Subject: [RFC PATCH net-next 01/13] RDMA/mlx4: remove bogus dev_base_lock usage Date: Mon, 7 Dec 2020 01:59:07 +0200 Message-Id: <20201206235919.393158-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201206235919.393158-1-vladimir.oltean@nxp.com> References: <20201206235919.393158-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21 via Frontend Transport; Sun, 6 Dec 2020 23:59:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5cfb7128-4e78-46d4-663a-08d89a4309eb X-MS-TrafficTypeDiagnostic: VE1PR04MB6637: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A8120M89+dz3pUb6PuMOQ8VegO934esILN2+3kjUb8CecTysNn32g41EjmjohYirkttJoxbYCdoK4ng74xAVE0DrQ7cM+PcEXMIw/C54mHGrt1CmDDoQ4gwVrl8BDFsRrYWslY4TOrVwp41KDGuvLMJpnNfyxh9y4H2bX7KQLiDzmjncIrg8hPstWB+cUXiPgoZP13t1AJUzl8XeEJCkbFwWtI3sFA9Ly6fdcb6nAS1DNN7eKoYZTTLGkXfrByNjzRuG4bc0BwbTx3Qxw31TkhEHKtmsCa4vno+dExmaqnpkICu12S9I4ImKGxaz808yQselNY1JXsfdADBYFy7ybXMReosYfSI1lb6EoLcQQnp1PdY3hNUnzRq4MNVTFbkT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(366004)(136003)(39860400002)(376002)(6506007)(52116002)(5660300002)(66946007)(66556008)(26005)(8676002)(2906002)(8936002)(1076003)(316002)(4744005)(110136005)(54906003)(478600001)(44832011)(7416002)(6512007)(186003)(6486002)(16526019)(6666004)(36756003)(956004)(4326008)(86362001)(66476007)(69590400008)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: qv0IIiYZQaBmM/S0e65Tu9ZnE9PleUGzGvs1/lZYu3bohZcJE3k2Jyp2qO7OEHH+tCf6tHAnWpmQUzYoX29DbPhESWzFYan+na8Kx1AdAi6VvQ0+cn7sG03iSnb4Hchk1i3sMuO4HNI82uvfgn75sB8Sxnijj+XAJrnbawIcUJRPY3rDG7aDwgGfVI23Jgoa00lyKVDww0qj8U9QSaMuoqivwxIRxgX92rlEFKqfSTaY4F9O+jf1zLC0MxUxwTPfRol8kgr4hKYeJeh3a6wTQgH/V3qSaeBusFqWx8besG7qxyq1DtF1gwE2sMdWWoDMp0Ez+CSfQLLeLqMFLjOzi5DOHKMfWLCvVgpYnJKAMRJSpR/eVlxgxHYwRi3934j7Yywx7PcsSR7xIG3rSwmCzKCB0if5jfOZ/ju8psYTqjh6hbo47G/ASkG+s6uIuRRX8rDYQRYX9rNYcGBQMFS5xKGRWFVE57ygReNJqIuhJtH/xukjdYYtlplh5nX0R5gHSUESMiUoOt7ccPLmBbT/zM551flVfmWcdkR+E4AGQdSVyvvasY2ERSuXG0fxYimfhu8h7zdrMtAiiiOe/WWNLhHJ3VtkZRH3bKU/2NbFZB6ZTQ6nHqV6AandIQ8dhq0CbGPO4ENAUgQyNyFLT9blhoB9FeGBbUAnhJg/UwG8quMyrukYyEv4LS9j92E6VymiiDddBY1jTf225c1BAo2ltVNlKsCEzX77vHWZU2kQkx5DbrUiMJ1Hz1nE05BrS2m4qJIz0EbEQXiMJga/racZUQzfpr/YiS+whVZxML9ZmuIjh967lvS+maZxqUYWGxjndpXRlG6SX4QOXX3zd6Ef7PTmEGsP9piNP4bDS7cXJOXLRX9gKVHgNuleychr3j2DBK+cJIQ5pIdASpZbQhxs81xIDP27+SXdSK6nkFTuBNYO5l15rUOaTLUljGdy7fCyTWYJ4W5o7JeMpbUeubgMGeM3P0tfcgj7cq2t2fnSCok9lRFnRlQfv9uffd5fmnXs X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5cfb7128-4e78-46d4-663a-08d89a4309eb X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2020 23:59:59.6291 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uE8KA1pMOQRM6XqsNez5FZlKPNXDzq+iJ037BRWBfUmjkb78UeSwT3v/7jUm1RcsWEvfaSEkYQzFBesZqYuh+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6637 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The dev_base_lock does not protect dev->dev_addr, so it serves no purpose here. Cc: Leon Romanovsky Signed-off-by: Vladimir Oltean Reviewed-by: Leon Romanovsky --- drivers/infiniband/hw/mlx4/main.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index f0864f40ea1a..e3cd402c079a 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -2265,10 +2265,7 @@ static void mlx4_ib_update_qps(struct mlx4_ib_dev *ibdev, u64 release_mac = MLX4_IB_INVALID_MAC; struct mlx4_ib_qp *qp; - read_lock(&dev_base_lock); new_smac = mlx4_mac_to_u64(dev->dev_addr); - read_unlock(&dev_base_lock); - atomic64_set(&ibdev->iboe.mac[port - 1], new_smac); /* no need for update QP1 and mac registration in non-SRIOV */ From patchwork Sun Dec 6 23:59:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11954639 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A17FAC1B0D8 for ; Mon, 7 Dec 2020 00:01:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6273F22D08 for ; Mon, 7 Dec 2020 00:01:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728708AbgLGABC (ORCPT ); Sun, 6 Dec 2020 19:01:02 -0500 Received: from mail-eopbgr80049.outbound.protection.outlook.com ([40.107.8.49]:17892 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728660AbgLGABC (ORCPT ); Sun, 6 Dec 2020 19:01:02 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vapw5e+2uRkKGIbZOxupO+vjK8V7IoraCq6djLnzoVj+iNT9wLMHBOcUgICx/L2kOnVWPhGcNSHy4Mx1ncPllDv18leh4m0zX56RrfZVQIZBdX5aaTryiJfTdTkkmCXpgn34bA5HP1+1rU1ymIX0PrxJQ4GKQ2Uwv+I3/aCm7k6V5mcj9WN+TUQw1lmE05u7E2/0riKru/vFQB1Zip9DtH0xdZpQobE8UfxSs+Y4VJXpza23N15KA6qJFIOB9LWEyGd4ricBBu1xhILiBzDYZ2uGTSMQkMPiPqdLVnrjn3JBm9fLpYqKtDCoBt1J2klqUUlMiWi5T0qoUW8hMh8XEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=InZDUjB2Yptqic8dtqVlEoAc88AHwGBKZuhguQm1BB0=; b=NSzbAw69iuheyVBbZF1EZyoyQtU9tdIGhHyexhoaxw2orrYUmSlHJoHfiXw1Oy4mic3lVlMna18MQ1a7hI2upTyuxDjLXLiO6x+dJC3x4T7iLrpvH66T3TaQcOXAHdmgYrfJ8Mf9DAD0Cf/NU72djOBRh8GlLWJIVMgoDkZmzBdC8QyUckpi+qlJUMNNFSerNEi7EwnGpdB8FtQUPV+NyugUSaRj+sMO5lqLFNN0TL2UxHw8JQSaypw0Fxl47SViTDvQiw7JmgrRvLddxlXWm5v2OSPwT3xYpFE6FtBirAXTzoZHsyYvRFAmJSGYsiE2ALOTolebkLnoWuBbiSmt+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=InZDUjB2Yptqic8dtqVlEoAc88AHwGBKZuhguQm1BB0=; b=ieICDkcSNK9jZBFXEN3b5NTOzFieS9/xeqVzUykS5HLFNGaKjh5ExjJ7WV5MO1APNac4VDqioHZe3JkI75REEWEhchj10vBqIRinl0Jn7DmSRu3QbB0h/l1qP5yHE8/cuOtUiouQNj5vvlLblzeNg0a5L8H3tr3gpwoQ2hETL1o= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VE1PR04MB6637.eurprd04.prod.outlook.com (2603:10a6:803:126::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17; Mon, 7 Dec 2020 00:00:00 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Mon, 7 Dec 2020 00:00:00 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , Paul Gortmaker , Pablo Neira Ayuso , Jiri Benc , Cong Wang , Jamal Hadi Salim , Stephen Hemminger , Eric Dumazet , George McCollister , Oleksij Rempel Subject: [RFC PATCH net-next 02/13] net: mark dev_base_lock for deprecation Date: Mon, 7 Dec 2020 01:59:08 +0200 Message-Id: <20201206235919.393158-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201206235919.393158-1-vladimir.oltean@nxp.com> References: <20201206235919.393158-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21 via Frontend Transport; Sun, 6 Dec 2020 23:59:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e9b70b48-7509-466b-debb-08d89a430a75 X-MS-TrafficTypeDiagnostic: VE1PR04MB6637: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j7lonmbxlzIutfPcx8CSR2Yq92WR+OW14JgOsc3JJxXYd3y+428baKnWPVVZ9NzFxGKhxlbpce7IPDyebBqc4ZhGAdipAadbvDgdHR/pzJVrpsNcYeC95TvmqzM8Tjfn22NKPJO30uvXXN0idJ8F5zN7Jw9uV1WDtCPcCmnnuiqNciLv2wPFPOPlR0WBFfQu4KdoA9gDwSHaZ3p0sJcmzJRuF2ftklPu+o0D1OGfERTxdOKW+j9m1uC5604fThXQaV0BvNTn/7+sfbx0ylZK7C4ZOOkevI/KpuAqQILCg1L60OpZJmwAZ6jQ/omkp391JbSXJF1ZuzlNc35Xhuiax8Oo+ROEffMwYDlDIIg0ODFIT0p3I9vIYiYRh2Q/9k27d2u3lnHApHLXIw4kvSCGKOdzCW1IiJ3KPAKMQbqGmu20dWgb6Frg5TmFlbWmrh8/RJ3+7lcOQ24MoSEI4ibwSQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(366004)(136003)(39860400002)(376002)(6506007)(52116002)(5660300002)(66946007)(66556008)(26005)(8676002)(2906002)(8936002)(1076003)(316002)(110136005)(54906003)(478600001)(966005)(44832011)(7416002)(6512007)(186003)(6486002)(16526019)(6666004)(36756003)(956004)(4326008)(86362001)(66476007)(69590400008)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: VP7cE8xEYOBt1czK77S4WhWnr2tNzwjnolmAxyi0ZXWFlKsmW01h1lSKf3gujDYKBkSJfmEcwSPtDSkH95SdH01meQNm5wV+VzldY+koPYrYR0UjkOUKhovmUe7zDMlG/II/OBmaxVjEIPSClZhz1Cvj6RHFFXssjsjW20u/QneKQWh1A4R4YiVuzru/fHjELXY/oQZrXu3+7oAuBJ/vhCQ6Cckx6o//lD90//XCihQR468Thxmk0r3K43BC6BkF7fGA5eynuUGNp4THdJovIaRmr4JOQuMrItqstFX0en8+McMAzK9WhodNB0m8/sjVC7Pmycm3kchH1cGqvMsdwbKBnMp/uahbAchYMt4c9+LrnmrL32WL1cXgiK3lbCMjKhbvLE4ZIY0ZKGGkMj0Qi72WcFziu1sBj/QHAlRg/pX82F1R7Yn9bMmzghmd0LprTGeVb9usYNe7szSnc09hxjtFckJZu6eYoOOUvklFnWDr6yo1DhL4IWX1Z4IY8aL888AscymkQ864eX9nW6yGgaTQxQBpOE3lXIi5Dcs75hGz1xusRCu7jZewKtDaZZT02XNXA/E1kZHhn6nHd6Xmd+BKolEo/nweFTaPM0Tbim5b3rIwVbNYfSZNmvMy2ftUJfTu2rMledN4fTR0EbAIUwuvFPo1K6ESI+y64n8jUikAncedA71Dwjbr4V2rNw0gMVp7bwVVlVIq5jTma/DPEMlynA7091G+jeWedEN7Yf2aOdKHODMJABDXTKnGDR7Z95kAoFZIfT0m0AaOyWFE+0wpFmPdzS6wnD2XYQkmzXstmsv3Gi9eZHrEQ2xSgGABNrEIMdcQ7wA3BwGOLsA9020XH1Mu0EVl3Bs3nFr2V/jJtr4GjTx/fMlqUlgULtvnWz+TM3gVSBxBDUyGc7k8gm1/WDMgxC4XDUSADWErwiuaqgh4VImDPEmau8rED1ddZlrd+P+R21FPUArmAT3iGxTpzVS97tYqD0R+2FqbQ8k= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9b70b48-7509-466b-debb-08d89a430a75 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2020 00:00:00.3687 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: KRedQ6wfL1cP/+tblQmRTM9si2wo7Bw2g+vH7qWFblcJHLSbXOagFXTxYezF2qvuxNmbKTID+DFOaEu48T8nMg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6637 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC There is a movement to eliminate the usage of dev_base_lock, which exists since as far as I could track the kernel history down (the "7a2deb329241 Import changeset" commit from the bitkeeper branch). The dev_base_lock approach has multiple issues: - It is global and not per netns. - Its meaning has mutated over the years and the vast majority of current users is using it to protect against changes of network device state, as opposed to changes of the interface list. - It is overlapping with other protection mechanisms introduced in the meantime, which have higher performance for readers, like RCU introduced in 2009 by Eric Dumazet for kernel 2.6. The old comment that I just deleted made this distinction: writers protect only against readers by holding dev_base_lock, whereas they need to protect against other writers by holding the RTNL mutex. This is slightly confusing/incorrect, since a rwlock_t cannot have more than one concurrently running writer, so that explanation does not justify why the RTNL mutex would be necessary. Instead, Stephen Hemminger makes this clarification here: https://lore.kernel.org/netdev/20201129211230.4d704931@hermes.local/T/#u | There are really two different domains being covered by locks here. | | The first area is change of state of network devices. This has traditionally | been covered by RTNL because there are places that depend on coordinating | state between multiple devices. RTNL is too big and held too long but getting | rid of it is hard because there are corner cases (like state changes from userspace | for VPN devices). | | The other area is code that wants to do read access to look at list of devices. | These pure readers can/should be converted to RCU by now. Writers should hold RTNL. This patch edits the comment for dev_base_lock, minimizing its role in the protection of network interface lists, and clarifies that it is has other purposes as well. Signed-off-by: Vladimir Oltean --- net/core/dev.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index d33099fd7a20..701a326682e8 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -169,23 +169,22 @@ static int call_netdevice_notifiers_extack(unsigned long val, static struct napi_struct *napi_by_id(unsigned int napi_id); /* - * The @dev_base_head list is protected by @dev_base_lock and the rtnl - * semaphore. - * - * Pure readers hold dev_base_lock for reading, or rcu_read_lock() - * - * Writers must hold the rtnl semaphore while they loop through the - * dev_base_head list, and hold dev_base_lock for writing when they do the - * actual updates. This allows pure readers to access the list even - * while a writer is preparing to update it. - * - * To put it another way, dev_base_lock is held for writing only to - * protect against pure readers; the rtnl semaphore provides the - * protection against other writers. - * - * See, for example usages, register_netdevice() and - * unregister_netdevice(), which must be called with the rtnl - * semaphore held. + * The network interface list of a netns (@net->dev_base_head) and the hash + * tables per ifindex (@net->dev_index_head) and per name (@net->dev_name_head) + * are protected using the following rules: + * + * Pure readers should hold rcu_read_lock() which should protect them against + * concurrent changes to the interface lists made by the writers. Pure writers + * must serialize by holding the RTNL mutex while they loop through the list + * and make changes to it. + * + * It is also possible to hold the global rwlock_t @dev_base_lock for + * protection (holding its read side as an alternative to rcu_read_lock, and + * its write side as an alternative to the RTNL mutex), however this should not + * be done in new code, since it is deprecated and pending removal. + * + * One other role of @dev_base_lock is to protect against changes in the + * operational state of a network interface. */ DEFINE_RWLOCK(dev_base_lock); EXPORT_SYMBOL(dev_base_lock); From patchwork Sun Dec 6 23:59:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11954647 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C615CC4361B for ; Mon, 7 Dec 2020 00:01:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 99B7722D07 for ; Mon, 7 Dec 2020 00:01:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728761AbgLGABc (ORCPT ); Sun, 6 Dec 2020 19:01:32 -0500 Received: from mail-eopbgr80082.outbound.protection.outlook.com ([40.107.8.82]:2436 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728715AbgLGABc (ORCPT ); Sun, 6 Dec 2020 19:01:32 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XMrNUKQfWANdMWHHoTW2QQXfsYnfloO2RlDWxr0pagU0x1QXBlc1FXGsXI64FkiApn28ll7KtZdpuNdqJAqK7mTVwTIospxbVSrh3ZtjPIOp3e7J4zpSVmbsmx4jlvbwb0NwB884UEdptbmPb0ITs5S1JtTcyvAYKq+FnR4RD5w472lN+qVHBFJcn3/DdIYdtxpaJI/EXr6NhoKWk6NHrn8Q5kF9XnntKkUHTw+0XzjoM/7LjNl61PZ4uv0uzFGwR2MFPoo+2fpXbzK5JydckDW0DndQAMDG2IYIDwxYcMaT4nwpeSaQjKYNVvrPx7Ws7y99+49eFaWbIDAWWelFoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aY0/IkAWKznNa/gL2l77XEYt95zVr83h8i2p05YcBcw=; b=CODp55VgplN1caT2Tp2r6hfKmSTmm0+QZvXL1+z3M+J7CA7/VvvEYi14hkVnS27fnkN9iaSXXTzrOmMjmcTIzEpADIrzH9XCBX/5T7rxbqoIALvWHWhpirSPZ6uuOkmwo0M2M5k3LExgm16HGwGFw/ZiyMUg/vcpeQNdXxGrrcOdcklwExgg0YBdE3gJeYYfjGe97Vi/jPags7y1BX2rNsRRO1VyUrVU2VjD0zWHaMMylF+h7gO3ZpXT9Ni5IyuL6tjdBXlnvJSz1cEZTkzryA+IVgGpB8fQu+h/xS8udaLiiVYp882ckV9YvPSSA2AXA8ech00rXHOssgBWQc483A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aY0/IkAWKznNa/gL2l77XEYt95zVr83h8i2p05YcBcw=; b=IlgKghUqJnqLYHJeEd9R4K7iiBu/Iy61RVhicAsDaJtEIg2qjZSDmLJrma59tdeCxrlvEBARAqa3DGRzdZnNshoCOdZbmeXeBGcgxMWeWYtMZDuQy1+2IVKhT1nHl5xioSJOduqJ81q66ctLi8MN/EEZXnD7OOVhZTI7fhGeDjg= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VE1PR04MB6637.eurprd04.prod.outlook.com (2603:10a6:803:126::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17; Mon, 7 Dec 2020 00:00:01 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Mon, 7 Dec 2020 00:00:01 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , Paul Gortmaker , Pablo Neira Ayuso , Jiri Benc , Cong Wang , Jamal Hadi Salim , Stephen Hemminger , Eric Dumazet , George McCollister , Oleksij Rempel Subject: [RFC PATCH net-next 03/13] net: introduce a mutex for the netns interface lists Date: Mon, 7 Dec 2020 01:59:09 +0200 Message-Id: <20201206235919.393158-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201206235919.393158-1-vladimir.oltean@nxp.com> References: <20201206235919.393158-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21 via Frontend Transport; Mon, 7 Dec 2020 00:00:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 786714ef-2c81-498b-1f8c-08d89a430af6 X-MS-TrafficTypeDiagnostic: VE1PR04MB6637: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ez+mzGfHkQY6Rr8TUTSyMRknHRPtYAardN75t9iDybg/WHe9yaNZUwcEZ9EpGHAIS9BM7NlggUaGXfxFrcFoZxGl89cngCEf0Q0rDuCVU0zMNPYOa3cfj39IT7kFUwvxviuJvdWNWjplW7H1OsgMoYGIPrEHXDVmuXH1O5nGbENeW4D5nPxDkS4SGeKNNd3g2q1U0G4GimMzodF8snBlAw7HnktDKWlO+m8grP57GAhSV5IEhWSA8pUroBSamCTBI4aggS2Auv2KpVWYEhymMVIlvwnn/lRnMZQFqhER1dHvmTCBrDvSZTpDvq+GWGn0FWMZcV7/zESnLnrakpiIxDc9+kOSDupx+AMinPhPrAhgNCAkuonLm0ojTyPRFLdj X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(366004)(136003)(39860400002)(376002)(6506007)(52116002)(5660300002)(66946007)(66556008)(26005)(8676002)(2906002)(8936002)(1076003)(316002)(110136005)(54906003)(478600001)(44832011)(7416002)(6512007)(186003)(6486002)(16526019)(36756003)(956004)(4326008)(86362001)(66476007)(69590400008)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: tB+CK+We1gyU+Rh3Md+2ho4D9ktaWeSCURxJ7g3P1zDVGsBOnjS99i7axLwAAmTg6papUEWYtccwKSa7hjZxMB4dCraL9qAsEkskdlNc8J2Feq6noyBsNqHZVB2itdjM2FsffKMWCilUHj5AvB00FSMOhrepml3AORnVnCjN9C64X2o15yeRp9QCirfTjVSDv9eOGRM3tUJDv3Ei+KJ63iQlbUDjD25ZM1LNvjwtYliFx8I9EUQAS+Tm7aF/OxGo+U/hM9K7H/P/tmDofapaynx9CnIKzxOPfP3YzMJfudckFdREheGPFLMQM2r37M2LlqcdVrMCSKxtZbunpx9vYTll22qDomcW5uCtpbeOeU8qLKIHpj3yfrmuEIuYiJNyI/IVf6sNkaNfVq4VreKQk42B6CWu6My06sC5UNzJp4bvEUeOJw2dRt3OO6KulHltVXnhsO27AogpfGKKALOBE3PmbA8ArN5n4rwX/yU0q/hrBPQCNuqcvf6u1KJrY5i8pxiJM1MGq9M3cr8PFKSxtIMa4t5YPdRRxWJUAOM4W1wFusSeqkxm9DbsnUT9F7SvI5Biv1NZBtPSk/5IOe3pbOfjI7NayM+VzVuuJ3CtEzLSgVxdHxkReV0fgx42r3RzAzejYDLwOyVqHdArqzk/t4G/qqbZ79sjx0EskV7s6xuvXDs3HfnYKasNE5Zen6mMZrS/MXR0BG32w1txHHUa5ZKwke4bcNELdYyHKLoi3se8107ykB3lBZez+6PQECe+mVOqZGjEucAdxzsNWwpPIXmYtiqeyhyOxQ053YPXtkMgae6QnOSkiktPyobmjdGdAXiDtMN1PVfD7kpd2MxtpfdorHx9t6BgpERwJWkZBTK7bnc5FEGYfmWTnqoWZ/3eK3GoKHQpyHjzvSaoFZmHA7ZhkYrU/6YljS/wtNPMrL0Zlt+nEya+CbUMOfqliALk/LRhraeD4tFztdeVZ3tBFZm5g9Q3v8449Fwd7zUX4UI= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 786714ef-2c81-498b-1f8c-08d89a430af6 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2020 00:00:01.2852 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HQecPmU2H+hPxha1j41N4cp302viZf4VfXoyt5eLVICk50BzwhS2sS3uSbvbshcega9s/mbI4HODS0zOsB8ygQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6637 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Currently, any writer that wants to alter the lists of network interfaces (either the plain list net->dev_base_head, or the hash tables net->dev_index_head and net->dev_name_head) can keep other writers at bay using the RTNL mutex. However, the RTNL mutex has become a very contended resource over the years, so there is a movement to do finer grained locking. This patch adds one more way for writers to the network interface lists to serialize themselves. We assume that all writers to the network interface lists are easily identifiable because the write side of dev_base_lock also needs to be held (note that some instances of that were deliberately skipped, since they only dealt with protecting the operational state of the netdev). Holding the RTNL mutex is now optional for new code that alters the lists, since all relevant writers were made to also hold the new lock. Signed-off-by: Vladimir Oltean --- include/net/net_namespace.h | 5 +++++ net/core/dev.c | 44 +++++++++++++++++++++++++------------ 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 29567875f428..90826982843d 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h @@ -105,6 +105,11 @@ struct net { struct hlist_head *dev_index_head; struct raw_notifier_head netdev_chain; + /* Serializes writers to @dev_base_head, @dev_name_head + * and @dev_index_head + */ + struct mutex netdev_lists_lock; + /* Note that @hash_mix can be read millions times per second, * it is critical that it is on a read_mostly cache line. */ diff --git a/net/core/dev.c b/net/core/dev.c index 701a326682e8..18904acb7797 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -175,13 +175,16 @@ static struct napi_struct *napi_by_id(unsigned int napi_id); * * Pure readers should hold rcu_read_lock() which should protect them against * concurrent changes to the interface lists made by the writers. Pure writers - * must serialize by holding the RTNL mutex while they loop through the list - * and make changes to it. + * must serialize by holding the @net->netdev_lists_lock mutex while they loop + * through the list and make changes to it. + * + * It is possible to hold the RTNL mutex for serializing the writers too, but + * this should be avoided in new code due to lock contention. * * It is also possible to hold the global rwlock_t @dev_base_lock for * protection (holding its read side as an alternative to rcu_read_lock, and - * its write side as an alternative to the RTNL mutex), however this should not - * be done in new code, since it is deprecated and pending removal. + * its write side as an alternative to @net->netdev_lists_lock), however this + * should not be done in new code, since it is deprecated and pending removal. * * One other role of @dev_base_lock is to protect against changes in the * operational state of a network interface. @@ -360,12 +363,14 @@ static void list_netdevice(struct net_device *dev) ASSERT_RTNL(); + mutex_lock(&net->netdev_lists_lock); write_lock_bh(&dev_base_lock); list_add_tail_rcu(&dev->dev_list, &net->dev_base_head); netdev_name_node_add(net, dev->name_node); hlist_add_head_rcu(&dev->index_hlist, dev_index_hash(net, dev->ifindex)); write_unlock_bh(&dev_base_lock); + mutex_unlock(&net->netdev_lists_lock); dev_base_seq_inc(net); } @@ -375,16 +380,20 @@ static void list_netdevice(struct net_device *dev) */ static void unlist_netdevice(struct net_device *dev) { + struct net *net = dev_net(dev); + ASSERT_RTNL(); /* Unlink dev from the device chain */ + mutex_lock(&net->netdev_lists_lock); write_lock_bh(&dev_base_lock); list_del_rcu(&dev->dev_list); netdev_name_node_del(dev->name_node); hlist_del_rcu(&dev->index_hlist); write_unlock_bh(&dev_base_lock); + mutex_unlock(&net->netdev_lists_lock); - dev_base_seq_inc(dev_net(dev)); + dev_base_seq_inc(net); } /* @@ -850,11 +859,11 @@ EXPORT_SYMBOL_GPL(dev_fill_metadata_dst); * @net: the applicable net namespace * @name: name to find * - * Find an interface by name. Must be called under RTNL semaphore - * or @dev_base_lock. If the name is found a pointer to the device - * is returned. If the name is not found then %NULL is returned. The - * reference counters are not incremented so the caller must be - * careful with locks. + * Find an interface by name. Must be called under RTNL semaphore, + * @net->netdev_lists_lock or @dev_base_lock. If the name is found, + * a pointer to the device is returned. If the name is not found then + * %NULL is returned. The reference counters are not incremented so the + * caller must be careful with locks. */ struct net_device *__dev_get_by_name(struct net *net, const char *name) @@ -920,8 +929,8 @@ EXPORT_SYMBOL(dev_get_by_name); * Search for an interface by index. Returns %NULL if the device * is not found or a pointer to the device. The device has not * had its reference counter increased so the caller must be careful - * about locking. The caller must hold either the RTNL semaphore - * or @dev_base_lock. + * about locking. The caller must hold either the RTNL semaphore, + * @net->netdev_lists_lock or @dev_base_lock. */ struct net_device *__dev_get_by_index(struct net *net, int ifindex) @@ -1330,15 +1339,19 @@ int dev_change_name(struct net_device *dev, const char *newname) netdev_adjacent_rename_links(dev, oldname); + mutex_lock(&net->netdev_lists_lock); write_lock_bh(&dev_base_lock); netdev_name_node_del(dev->name_node); write_unlock_bh(&dev_base_lock); + mutex_unlock(&net->netdev_lists_lock); synchronize_rcu(); + mutex_lock(&net->netdev_lists_lock); write_lock_bh(&dev_base_lock); netdev_name_node_add(net, dev->name_node); write_unlock_bh(&dev_base_lock); + mutex_unlock(&net->netdev_lists_lock); ret = call_netdevice_notifiers(NETDEV_CHANGENAME, dev); ret = notifier_to_errno(ret); @@ -9379,8 +9392,9 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack, * @net: the applicable net namespace * * Returns a suitable unique value for a new device interface - * number. The caller must hold the rtnl semaphore or the - * dev_base_lock to be sure it remains unique. + * number. + * The caller must hold the rtnl semaphore, @net->netdev_lists_lock or the + * @dev_base_lock to be sure it remains unique. */ static int dev_new_index(struct net *net) { @@ -10958,6 +10972,8 @@ static int __net_init netdev_init(struct net *net) if (net->dev_index_head == NULL) goto err_idx; + mutex_init(&net->netdev_lists_lock); + RAW_INIT_NOTIFIER_HEAD(&net->netdev_chain); return 0; From patchwork Sun Dec 6 23:59:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11954643 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FC3BC4361B for ; Mon, 7 Dec 2020 00:01:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 271A8230F9 for ; Mon, 7 Dec 2020 00:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728739AbgLGABL (ORCPT ); Sun, 6 Dec 2020 19:01:11 -0500 Received: from mail-eopbgr80058.outbound.protection.outlook.com ([40.107.8.58]:53705 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728660AbgLGABL (ORCPT ); Sun, 6 Dec 2020 19:01:11 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MkFqdNIz2Lhr0AtqSwT9fnWP9tHax9eALqvWjmhsI+aTCP2OPSTcdwVH0VaVHW2aMI61DOtihy2GptdC6KVBs/51OUmRF1U+h+2BkZHEqZu1xm7LrOLku8BNuaDEAB1ydfseGdaxHwnlG8zPJVugC9emOVaQACsxjvBo159mkKmkDDDlT+U8AeAceR3Fk52XlbdXacD8z7UhXnGR8KshLfrV3M4jzziBzlSKDC3g77p67NYZZXjszZIhm5SMCQQgyzCnsNMRL7Yyjvn9c1xsAwu4J0qvsBwjzW5FSYc6RfkZmu9wwmPWmMprIWh7DJ9EFTiKHei+IWXEvnKH45giIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MB8c3ihaLKCJsxu85I20L7CMGK06x44FkBrlVzAx2QU=; b=GdKoMtVk6lJPkYB/5TRtkmMfq0anPjm6FUJb6jUW6v9ChvWBZjEMNLCl32ZsgsjhPGJjDeqqJRW92rXWoY329wiaVy9JpEE3bVsTFRRCPjBIn3C4VCmaVpglQZH7A/IBsMcJroPmeeCT5KmzomkiS4Xp60Sb/AmjNfkjWWCXsOVgYdb3izmqV70qKIQL7YNq0muHZC7TVvnRC9nY4gpg1Q5PqM01PevTpnBqwSkzasAxFKN6ec120OZpakCfAyxdQCeMeGWA22tMzxBYO9K10t1UvoZJpax4+V6F2W+UW3aOGq7u2RTdzd43NcX2ot8mF3QeJnBnTJP07nmJlNs/Ww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MB8c3ihaLKCJsxu85I20L7CMGK06x44FkBrlVzAx2QU=; b=RsHJ50fSCgYeIIPyJOQAyBqg8PxAc6b5H7t9weIWl5UWWg3GwD1FRkbiQL3+2xcFRMy6b2roFouUqQdZQqKMqUcwDsnEhepe7prZPWESQRLeeWvge6ta0WFT/x8I8u78y1+Z5RYXkMcJFyyCcjKELMGBwY4EtmrqCg3sUTyde58= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VE1PR04MB6637.eurprd04.prod.outlook.com (2603:10a6:803:126::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17; Mon, 7 Dec 2020 00:00:03 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Mon, 7 Dec 2020 00:00:03 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , Paul Gortmaker , Pablo Neira Ayuso , Jiri Benc , Cong Wang , Jamal Hadi Salim , Stephen Hemminger , Eric Dumazet , George McCollister , Oleksij Rempel , Heiko Carstens , Vasily Gorbik , linux-s390@vger.kernel.org Subject: [RFC PATCH net-next 04/13] s390/appldata_net_sum: hold the netdev lists lock when retrieving device statistics Date: Mon, 7 Dec 2020 01:59:10 +0200 Message-Id: <20201206235919.393158-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201206235919.393158-1-vladimir.oltean@nxp.com> References: <20201206235919.393158-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21 via Frontend Transport; Mon, 7 Dec 2020 00:00:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1db6adcf-3a28-40cf-e584-08d89a430b89 X-MS-TrafficTypeDiagnostic: VE1PR04MB6637: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dAtQfKIaI1lXzKVOEtzSoPNRHIx7MKqDUjdNSbiDlbvzz0UAarjRpF9Xz3PmP+aa1UpA4XDfScXvukHtPBn6cZa9iFuBp87ctGNagHcn/25eQhiOuA4pVk2YFC0tNoy+eGGkSIAQOWXcHM2tIX+u3YQ7lLOmrSGDilb4Dr63QOKDI4+Jh/zihQ5vH6rrxI3/jiAQ4DhU5tX7LpwlBSBJD2gZ5qnO1tED65aQ9V2Y9ep9ie6PAvPF/r1qzSIVh5lBqQhMHkPq5Aq9Uy2LD9+DBOCiWwaDnEzdQ26jJjw+RUeN9BuZmVShBkgOoS4E+UbmAxi6LBxN514PosIVsSiyrxI1XswSc1f5p/ST27rMkDsbHl8DzY8qh/8ibEXpnL9W X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(366004)(136003)(39860400002)(376002)(6506007)(52116002)(5660300002)(66946007)(66556008)(26005)(8676002)(2906002)(8936002)(1076003)(316002)(110136005)(54906003)(478600001)(44832011)(7416002)(6512007)(186003)(6486002)(16526019)(6666004)(36756003)(956004)(4326008)(86362001)(66476007)(69590400008)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: U309BM3ZyyKDHUU0xL+4hyAMPDeahncJowOtzZcQJmvl09rfQy+c+1lnNFpTnGLKI/DWSBWq/t4SDgMszR9HVcWRqSBIEhDmc5NLxnJr3LukniU8JgQZHVW78fpXsqZXxEzM/yfJuwJ5H8BtMS5MHzCQAV5dFYC8glt7EAlaADuWIEvHNVcZratB6eIRtBvEfRKUSCC0c52NXJacRnTbWdFSianZbH+lR15ri+lKWCINvnSNZIB2N8Xlz9JCkFe9I07haJ88ANNkcrTkeS1+UaPdgIFhztuxhIW5/I4F6HbiU1OOfuK3ZNCDegjfB42nyUkVmGWY2gcpHux4YB1qntbzdi0inRV+Jwv7/cnTknf8VEKsJPe10GM59iQtWMKUG4Md7qfaO/g9ELMkHJGTKxslJBjj9j6i4W/z4RaS5IjgN7hmro3t9uqyi+XpP6GjAkcGgL2ssiyrBVUwm42MZt+cwbvzPnPiIupjPcoEO3bYFTqbVtkfwk7aGhEnJRHUL7a+rcTys5f5EaN/YpBYK/UUh6DsOUIQyQbYFjFyPyL5gLdBnejnjyoXJoQGFoqQbFShGut7O76wPNr7NwYJpJMlo27RnfKW7VRHnlEq9BbzG0OEoldsrcjRN5F9/ryf+yB7p9xDEatIhKn1hQ+0kjjxHDh5M+PuzDOzxjw8xDcoR8UVwa3wlAL2Vs1CgsLGY3xO84yhIn5qddMImVMt8XXePjPrJZsnut3/R/aeDiI8sn2mdOEJmGCC0XdYs6y3G3s7jfj1kCaLzSIqlxHZhinKIAQeo56SPzXY3ds4LMwNnweLbIALpAtVJeXdlfyBy+GKh+tWI+4TK9Bpa167vnDRTMfvCAdbJ4w5xCGQ/Rc96PCEe2Mg8CkfMQvDxQbbCkVjcLeDRi9/lA0aaL+AzxD6BsMOFPQq90UMgOp3b5Ylg73fv9bI+6No7xHS5JPqC6d4E4sl8fBuKMbP1Aas63tuNeO8nEdKGP2+hXWhWlI= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1db6adcf-3a28-40cf-e584-08d89a430b89 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2020 00:00:02.2606 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PntJ+bYUie54wiQa/vTNI2J4DjCn4mQOtp6Z1Du4k9eOiABAobET4bLb37nJeJcuUTXaj1Er69tx8CCRfJosQw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6637 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC In the effort of making .ndo_get_stats64 be able to sleep, we need to ensure the callers of dev_get_stats do not use atomic context. In the case of the appldata driver, an RCU read-side critical section is used to ensure the integrity of the list of network interfaces, because the driver iterates through all net devices in the netns to aggregate statistics. We still need some protection against an interface registering or deregistering, and the writer-side lock, the netns's mutex, is fine for that, because it offers sleepable context. The ops->callback function is called from under appldata_ops_mutex protection, so this is proof that the context is sleepable and holding a mutex is therefore fine. Cc: Heiko Carstens Cc: Vasily Gorbik Cc: linux-s390@vger.kernel.org Signed-off-by: Vladimir Oltean --- arch/s390/appldata/appldata_net_sum.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/s390/appldata/appldata_net_sum.c b/arch/s390/appldata/appldata_net_sum.c index 59c282ca002f..27e9cc998d4d 100644 --- a/arch/s390/appldata/appldata_net_sum.c +++ b/arch/s390/appldata/appldata_net_sum.c @@ -78,8 +78,9 @@ static void appldata_get_net_sum_data(void *data) tx_dropped = 0; collisions = 0; - rcu_read_lock(); - for_each_netdev_rcu(&init_net, dev) { + mutex_lock(&init_net.netdev_lists_lock); + + for_each_netdev(&init_net, dev) { const struct rtnl_link_stats64 *stats; struct rtnl_link_stats64 temp; @@ -95,7 +96,8 @@ static void appldata_get_net_sum_data(void *data) collisions += stats->collisions; i++; } - rcu_read_unlock(); + + mutex_unlock(&init_net.netdev_lists_unlock); net_data->nr_interfaces = i; net_data->rx_packets = rx_packets; From patchwork Sun Dec 6 23:59:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11954645 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D742C433FE for ; Mon, 7 Dec 2020 00:01:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1620222D07 for ; Mon, 7 Dec 2020 00:01:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728746AbgLGABT (ORCPT ); Sun, 6 Dec 2020 19:01:19 -0500 Received: from mail-eopbgr80054.outbound.protection.outlook.com ([40.107.8.54]:57805 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728715AbgLGABS (ORCPT ); Sun, 6 Dec 2020 19:01:18 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=btKyS58qJ2XJCirFJ8tDVk6FUDjbeFLjYE51LgZiSO2hrQWEM3gkLlJDjVWxD+RNYqBT6ppiZbUewaWBZfLVZMfmbJ/6Gf8jRGY91glgrJx9pjShqtJG5TYc+VozFXvnHhezPaWIkd4TJjXplc0Qcc4TQcG0UlWczwypSlN8/ePmnUo3zN51Ao4wkMcO1j7v+KiHQik5HirN+E6GslpdlOhLzluq9p1OIKxR8SYeKV9K+0S+xVGxJlAPY75oTdusISEh7H2P+CysYR/N0GljO0tvaFgeUYtpsvPa9ocauxlfXxYKN6P2olMSxAz1Wll10nwUrFds9glj1Hsh7RBq9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ztUyQXrpTPLs63n+922gBTletwutk/pvS5Hm/e4I8+4=; b=l66oXXSz6Hq5AHuxjyRZSEde6In6NURGkedb33sV2Mb2g/htICr7QRCNO4rwxR7KD/+5KRbQPJenOt2/ksKR77rXeH8DhumNB/do4vwnO26BOLXjT3X9Ds5ZPDFXdLohNABiSN0PlEmh0Hmwm5IVDjN2BlHDMYk6Yjy9uaq74eWl74UQsQTSJSRDzoDGICC9ZK/wCsPXSv/BFhOk11WXW/o89DhAR+oMa9T47gZcYA+c90g3yPmSkq9XYpsHq8G5oD9p0Gydjt02LDYeJpC5PUwtW3X1WMeb7+hB25Gxs3A8yVQW8VpD7vSeuAonI8eAxG27zQHbypYYiygly42K5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ztUyQXrpTPLs63n+922gBTletwutk/pvS5Hm/e4I8+4=; b=fJpBvV8+GL+DFya6Ypa769wLjb+KxVtrhMSJRrcpJ5Eac4KaKk8S5+rHciGfW2+J8M0B704EJrbD/KDTniICY6u4sYcwkf+f7or5Qw2lWk4zX73nkNf3dliRaBtxf0OLYMIceOSP2lL7K2Xeb0QP74k3OyF1cMZD4+1r9tgJMBg= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VE1PR04MB6637.eurprd04.prod.outlook.com (2603:10a6:803:126::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17; Mon, 7 Dec 2020 00:00:04 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Mon, 7 Dec 2020 00:00:04 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , Paul Gortmaker , Pablo Neira Ayuso , Jiri Benc , Cong Wang , Jamal Hadi Salim , Stephen Hemminger , Eric Dumazet , George McCollister , Oleksij Rempel , Jay Vosburgh , Veaceslav Falico , Andy Gospodarek Subject: [RFC PATCH net-next 05/13] net: bonding: hold the netdev lists lock when retrieving device statistics Date: Mon, 7 Dec 2020 01:59:11 +0200 Message-Id: <20201206235919.393158-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201206235919.393158-1-vladimir.oltean@nxp.com> References: <20201206235919.393158-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21 via Frontend Transport; Mon, 7 Dec 2020 00:00:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 850cc018-9e31-4564-d31e-08d89a430c14 X-MS-TrafficTypeDiagnostic: VE1PR04MB6637: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qUNa3fvCSRvnflBGqTV9Z/cY40zow2iuGcCtMTNh8Fb/LeZ6e6d77A4z0zFKV18/p+a2MFcBhQr8cqQnztwwqAP7Zbw3ITKH1GlfQ0hd7ioY+s5w6gUFV9bIa/7Nhmy5nbAkNNNn7m7y38KHpeHs7hMEOgciab8eb03bsApR8pf0UYgiV1RyFTlGoXFeduWSPJ8KQNbxoLu9JQiFvqNIV4dqKfiJRBaGebERT/32NEa7SKs1SYZclMB1MxWBRh7Eshr5IVvrsTy3Y/2WfkE75EfUFjlIfuM/1WwY59p2OhgSup2dYJgJsdO4TlHxQAK/tA05GUevRyl71ircU7B8ue2YmrUFhssHyZ5QmNYXUB5/R6VWZZMGWFC2uSVI5BSt X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(366004)(136003)(39860400002)(376002)(6506007)(52116002)(5660300002)(66946007)(66556008)(26005)(8676002)(2906002)(8936002)(1076003)(316002)(110136005)(54906003)(478600001)(44832011)(7416002)(6512007)(186003)(6486002)(16526019)(6666004)(36756003)(956004)(4326008)(86362001)(66476007)(69590400008)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: MSrM70IKUrCpYRy0VefAEiyr0q+fGg+ibLh0S/dH0XEvmzV2SHyu0E9FAbwdRE6db3i7XUt0ui1Y64i8ZDonC7aPD7155xW3NtYj+zkFPNXGPO7n+b8Daj2Oj3sGXTdpFiT3GMPUy1T1a2le7SiQK/XkuEY65122I8+K/B9ziHGnmqz/Qo6/G09XU13C+Jc4KNFGIlaWx4tgGCT5+mLXSwR3pA3O4847QppNrNs7pWqqjKkEm/vQt8V/gI62Lad/n3JFUS/neyZev4bm4KzG3SKTU557xdbiHNm/rCETsic0VMIWbRzbMGWSRCLVTreTYAiSoV4lWrbNoTVjYpshRi4GTsQKSgspSFN5c1xx0ks1BpB7c10U0jma7oaRUhhVUOzMm5nx1tF+gMxVKI8pIIbywBgU6I6FwA2c6DdKmYO4JxT0enyAvUr2k2YOuVR7XqYvm2Go0nltniZfEpSMNSS8WfdVc8vhCVWOBOfmiTIjqor/utvKW1RRwhPCmc1EfqKDcZdR4xM9sSywuCUWg0MFN+j8+IQ5xRIY12zjOWtQd6GDjCNxjA+9EXiIVd+Xyk+GAQlWE8jDyg8SxuhvMPu7K2meayMc+MfN9bZukbgS10QihZow0OGMY/mWFpwwM15RTD4bLg8gzPsYS8ZYSBnWKja2r8WlcXBoxR7EXo5/2UJdwFoNUClVhhY5L6tfRi3mjJSBXxU/fI2B70JUk/eKCFeT89BGrPD3V/st8y0MjDNfPo2AqXXfE9PImogaGpejViNKgFG5qKx2jtNCpq/aG5uEc++WIIB0lmZplmLtBsUdt08p/IsJbktTeSW99Ofm/V+zcF3y11dzBQ1Ww+Dgiu9DcnDJGkKrrLTqSoFoVfnalv4MYSMYnCKax30x78P61/fSXOsva7YcFcIRR2txrVe7ZoJJYHrjvIkY+muWfFZE9d58YrVmAWaFFJZFSQSp2+pLPlWjEtssqqTHLWU/6EDIbynKUZS80KlJgo8= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 850cc018-9e31-4564-d31e-08d89a430c14 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2020 00:00:03.0871 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pyp7Hbeb9+x3syaL/B9nzlut2X9EbZ0V8+MxDakH0RNTQyDZb78/WjYbi1sYTiI9+JJPmCrJJoIL1KNvkcQPXw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6637 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC In the effort of making .ndo_get_stats64 be able to sleep, we need to ensure the callers of dev_get_stats do not use atomic context. The bonding driver uses an RCU read-side critical section to ensure the integrity of the list of network interfaces, because the driver iterates through all net devices in the netns to find the ones which are its configured slaves. We still need some protection against an interface registering or deregistering, and the writer-side lock, the netns mutex, is fine for that, because it offers sleepable context. This mutex now serves double duty. It offers code serialization, something which the stats_lock already did. So now that serves no purpose, let's remove it. Cc: Jay Vosburgh Cc: Veaceslav Falico Cc: Andy Gospodarek Signed-off-by: Vladimir Oltean --- drivers/net/bonding/bond_main.c | 16 +++++----------- include/net/bonding.h | 1 - 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index e0880a3840d7..f788f9fa1858 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -3738,21 +3738,16 @@ static void bond_get_stats(struct net_device *bond_dev, struct rtnl_link_stats64 *stats) { struct bonding *bond = netdev_priv(bond_dev); + struct net *net = dev_net(bond_dev); struct rtnl_link_stats64 temp; struct list_head *iter; struct slave *slave; - int nest_level = 0; + mutex_lock(&net->netdev_lists_lock); - rcu_read_lock(); -#ifdef CONFIG_LOCKDEP - nest_level = bond_get_lowest_level_rcu(bond_dev); -#endif - - spin_lock_nested(&bond->stats_lock, nest_level); memcpy(stats, &bond->bond_stats, sizeof(*stats)); - bond_for_each_slave_rcu(bond, slave, iter) { + bond_for_each_slave(bond, slave, iter) { const struct rtnl_link_stats64 *new = dev_get_stats(slave->dev, &temp); @@ -3763,8 +3758,8 @@ static void bond_get_stats(struct net_device *bond_dev, } memcpy(&bond->bond_stats, stats, sizeof(*stats)); - spin_unlock(&bond->stats_lock); - rcu_read_unlock(); + + mutex_unlock(&net->netdev_lists_lock); } static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd) @@ -5192,7 +5187,6 @@ static int bond_init(struct net_device *bond_dev) if (!bond->wq) return -ENOMEM; - spin_lock_init(&bond->stats_lock); netdev_lockdep_set_classes(bond_dev); list_add_tail(&bond->bond_list, &bn->dev_list); diff --git a/include/net/bonding.h b/include/net/bonding.h index d9d0ff3b0ad3..6fbde9713424 100644 --- a/include/net/bonding.h +++ b/include/net/bonding.h @@ -224,7 +224,6 @@ struct bonding { * ALB mode (6) - to sync the use and modifications of its hash table */ spinlock_t mode_lock; - spinlock_t stats_lock; u8 send_peer_notif; u8 igmp_retrans; #ifdef CONFIG_PROC_FS From patchwork Sun Dec 6 23:59:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11954649 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12E8CC4361B for ; Mon, 7 Dec 2020 00:01:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D0D7222D07 for ; Mon, 7 Dec 2020 00:01:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728781AbgLGABg (ORCPT ); Sun, 6 Dec 2020 19:01:36 -0500 Received: from mail-eopbgr80049.outbound.protection.outlook.com ([40.107.8.49]:17892 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728687AbgLGABf (ORCPT ); Sun, 6 Dec 2020 19:01:35 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OWN6i+aeFMVOwQ1PaWmXbJWuVS/EqIvuNh9R9s6J5KlK8ufV6E0AM6dz2CsZl8lEzc0DPPTf1xlCu2mm4410qIpWnRQREqqr2g7xKrmPUddof2pzHAq0m5DGIPTTKKVJVI0Vh6SQq4WEQufrye0O+LBRZpeb/tZhgEWRbZXXsTWywkX+z1rMb1DaIKfYW4hnpgvBWh8Fer4ICG61d6R/NiK34gFq9rdo3vxOFR7Y3G2MRqmQxYNey/w/459Vy7eFPwM7CQEX/kiuUyL3+PerVJfP/RrXQGnfavK0MInZM3LKKvE/N3mOCC/eoasHpCCseXfTIQt9Z2HDfvns6MswOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RGx2CoCUTnIlmt5iAFFp7CH+wwxPytHnE/PNCdBToSg=; b=aEH9UHjnhiitYUj8pljfo7aFrQY8wJaFtMeubh7m3lAU9pQg4p7jzOa5z9gtEm5+3Z62gM0XYXfgkTRnp+wBfpycuc39CPPB6scBTjPXelQDJOr/5p8K1fhPQ67XpHuTD/NPrYOA/q3qBFRyW3wSWtsOnRCHZkBXogzW8zXM5oNaHQLgdwFbYLmvvt6IN0dvMKvrc19f2u3HxPbZ77MC7PWeL3U4G9sVCj1VYdiUeI+r88clvP0qCJsT9ISwBCuRIz5CJWwQAdBp68Nutr7tFVJSSzUSMHrLp0Bm0HiYkabXUO1ikdtTXvnfNP/UspePCIvS3SjMuQFOR3RVSWJ9sA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RGx2CoCUTnIlmt5iAFFp7CH+wwxPytHnE/PNCdBToSg=; b=RxGz0EHcAJjDrKZfRsunRsydQAmSC59rIK6g7BsKTKOP2vr+iyyTOsl6oNTQ7bucwSfhonSJD+e797ORFUwp4PVxcVorvEBaEoHlwapzLU/YRUYj2si0tyXVd+gj9G09ULrlO3NUDB+pNYdZFz4xO7krtwrekeXH6RpQpneCb48= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VE1PR04MB6637.eurprd04.prod.outlook.com (2603:10a6:803:126::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17; Mon, 7 Dec 2020 00:00:04 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Mon, 7 Dec 2020 00:00:04 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , Paul Gortmaker , Pablo Neira Ayuso , Jiri Benc , Cong Wang , Jamal Hadi Salim , Stephen Hemminger , Eric Dumazet , George McCollister , Oleksij Rempel , Sridhar Samudrala Subject: [RFC PATCH net-next 06/13] net_failover: hold the netdev lists lock when retrieving device statistics Date: Mon, 7 Dec 2020 01:59:12 +0200 Message-Id: <20201206235919.393158-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201206235919.393158-1-vladimir.oltean@nxp.com> References: <20201206235919.393158-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21 via Frontend Transport; Mon, 7 Dec 2020 00:00:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7ae84657-c4c4-4d41-72b8-08d89a430c9f X-MS-TrafficTypeDiagnostic: VE1PR04MB6637: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4zcZ/ZVJsHFXAtwOIt2JiBtUSLmeSPpa3R0zDHDlSqKi/KniC9jcTcMkTFVCDk2EsLnO/SIhVXFZGZ/NjsKq8PsJmzNkDo0W5q1JZrc6+vKXVKWdwYVt/iM7uJFYwnyaBteBvGYnx25nfgIxKS+5Q5OGD3mQriHpG9HM9HtNHjVLzXPIqFr6wc8zzAzMcAEA0k6ekirN7hmpyfGGjjf6V7kZkjuFutea+W7SxzQPcD+2nN7ul3nu5/0Pb8ihcMadpczOZ1lVR00m3ZNygk9zThdQ4buFl8Ke3uvRfdMVYtswu5TgRYmWsI6XwhLtPM7lo1YNP0ZcABTfk/xHv08uX020QbvAXANKEgw2s3FsiOcMhdlmNAVmwGT2eo0sGBsT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(366004)(136003)(39860400002)(376002)(6506007)(52116002)(5660300002)(66946007)(66556008)(26005)(8676002)(2906002)(8936002)(1076003)(316002)(110136005)(54906003)(478600001)(44832011)(7416002)(6512007)(186003)(6486002)(16526019)(6666004)(36756003)(956004)(4326008)(86362001)(66476007)(69590400008)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: CRb8CyLt72hylLvAx6VVtggpLte0lCNWfkFAGSKa+8/bKDlUt4JYCN4qA+Yf2sQWbHJiUygZwD9+W2pp/wlG8u2GAXEcRsGeE6bapKV1kBgpGmAAhcFd2uZwFETudVNgO7VRljoKmfWLvK4bshbOZrAzRdEu+rUtgeIJgjBHytXypKWwQuW6/P3phz5HzTecTt12tuwRTOftyfRpXfonCbqF/NqIG8bTk9RhHfnbMWImEMxF2E579+D+27XFIy9OyMSbvrzmFKD43sAhiP/to9KpNuAik+FZP761mZ8122B/0NqfKx8CpSj1kwHpa4p7mzUJxZm+v0bRlcdWHlcU/kC6S8sJGo25d+b42+O803pKE8UPX3+vZtWMH1Siq3s7wK69EMAh1wTlhUQ4/NW0FsEkq6UmJMOiFjjyWfVMJLWhBMSTjUE0GPVz5MyWVvVdMahw/SuC2aZfnvJrgRbjy6h3un4Mtwo0yhuj/XkS7cGEdiTIwr4ep9vCeisEobxTo+GvO/kku8IsHi2CpOFFl43YSglEWpOsZ100Doe3dTCv7n+uULcA6jgXWFbZ7h07FRgEmCvg+QqFBKVSTqG7h9mu+5iX2G9gemMAsUAlXnpyp56aWUkTiQeP2ifTkAFzFOz1VTek85umIz9ZFP/FEqVxhOUkLb12BPjTvNndBQqV4/2DBqL+QtXg/wqCpZDSelNzevGZx/Dvq1yCpNh+XEImZ6cNYe3kt42YWFHxI5c9UEdMuWPBCTxT8ojI4Vgo+WAJkZ35+2eDWDDu5SMhQTO2SbGpySjGmrezTbX8b/KUcLDC0Oo03hzhWkWIj9pi2CUFukU1oSuK6rwSiCcxhsRLTrJ1zTrxXowtCwdCqTXZspW3VoI0WNOC2bmOQBiteGXpTMZ+uSebz72/CsllNKjFCw3X8w8eHhV1FghIE3XXBumBSXI/zXBuub7OXPyreN3cGUTs6WCJqARjrMXFtMDvJedktLUOfhZVH7zHJNXBbeJrNHRz9VH27UiB54Fy X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7ae84657-c4c4-4d41-72b8-08d89a430c9f X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2020 00:00:04.1885 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: atOLe+QI3JglKynUMxaL0BNtZqihkAc03MkG/da35pF+QtWTNl1otFxXbTgW1sdq2PMS7IpDjQjwrLeHWKKQIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6637 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC In the effort of making .ndo_get_stats64 be able to sleep, we need to ensure the callers of dev_get_stats do not use atomic context. The net_failover driver makes copious abuse of RCU protection for the slave interfaces, which is probably unnecessary given the fact that it already calls dev_hold on slave interfaces. Nonetheless, to avoid regressions, we still need to offer the same level of protection against unregistering the standby and primary devices. We can achieve this by holding the netns mutex, which gives us the sleepable context that dev_get_stats() wants to see. Holding this mutex also removes the need for a separate lock for statistics. Cc: Sridhar Samudrala Signed-off-by: Vladimir Oltean --- drivers/net/net_failover.c | 15 +++++++-------- include/net/net_failover.h | 3 --- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/net/net_failover.c b/drivers/net/net_failover.c index 2a4892402ed8..90db0358bc1d 100644 --- a/drivers/net/net_failover.c +++ b/drivers/net/net_failover.c @@ -184,32 +184,31 @@ static void net_failover_get_stats(struct net_device *dev, { struct net_failover_info *nfo_info = netdev_priv(dev); const struct rtnl_link_stats64 *new; + struct net *net = dev_net(dev); struct rtnl_link_stats64 temp; struct net_device *slave_dev; - spin_lock(&nfo_info->stats_lock); - memcpy(stats, &nfo_info->failover_stats, sizeof(*stats)); + mutex_lock(&net->netdev_lists_lock); - rcu_read_lock(); + memcpy(stats, &nfo_info->failover_stats, sizeof(*stats)); - slave_dev = rcu_dereference(nfo_info->primary_dev); + slave_dev = nfo_info->primary_dev; if (slave_dev) { new = dev_get_stats(slave_dev, &temp); net_failover_fold_stats(stats, new, &nfo_info->primary_stats); memcpy(&nfo_info->primary_stats, new, sizeof(*new)); } - slave_dev = rcu_dereference(nfo_info->standby_dev); + slave_dev = nfo_info->standby_dev; if (slave_dev) { new = dev_get_stats(slave_dev, &temp); net_failover_fold_stats(stats, new, &nfo_info->standby_stats); memcpy(&nfo_info->standby_stats, new, sizeof(*new)); } - rcu_read_unlock(); - memcpy(&nfo_info->failover_stats, stats, sizeof(*stats)); - spin_unlock(&nfo_info->stats_lock); + + mutex_unlock(&net->netdev_lists_lock); } static int net_failover_change_mtu(struct net_device *dev, int new_mtu) diff --git a/include/net/net_failover.h b/include/net/net_failover.h index b12a1c469d1c..1e0089800a28 100644 --- a/include/net/net_failover.h +++ b/include/net/net_failover.h @@ -22,9 +22,6 @@ struct net_failover_info { /* aggregated stats */ struct rtnl_link_stats64 failover_stats; - - /* spinlock while updating stats */ - spinlock_t stats_lock; }; struct failover *net_failover_create(struct net_device *standby_dev); From patchwork Sun Dec 6 23:59:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11954651 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CD0BC4361B for ; Mon, 7 Dec 2020 00:01:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5554422D08 for ; Mon, 7 Dec 2020 00:01:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728774AbgLGABf (ORCPT ); Sun, 6 Dec 2020 19:01:35 -0500 Received: from mail-eopbgr80058.outbound.protection.outlook.com ([40.107.8.58]:53705 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728748AbgLGABe (ORCPT ); Sun, 6 Dec 2020 19:01:34 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GSNlR61aZhsuMg3A0NHaxWPYDK/nYRsskUibONsWQUJ6SKhKvdDF+C3f9KaT/IBAfrvT0JlqRjICx351WrLsl+0aB+9o6YrDaug8e+opTAnx7EGjx8tlpawpUHc01WeDJhS0vRKBgYgUJhCDplIjfbiM4BTKNhKUadVpRHR/OIrK18U3QuPMUpg4nFWGW3NbEGO3IJ4BBZ7aYdbLFlSj7Zh4m6H2ylwjNd7HO/yc+CmdYWk/VnI1/tYtAWQy/phU93ktzGsS6fAGnD009LVAp6PgtwhRDyOeLf8VvGtTDtiYmAP26paey/sr4N2CcAjphCTEDA4S7EK/Q4myZSTFNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Y9lyqS3+YQoBjIZOTagj8aId1ZLbutQqlTf+rCJJTuc=; b=oQW0Tc6F3/TRPYSmPg4ftnIZ7RUFBqoWRu2j9GvEn1pneu/3GdUlAZQZYRhgXQu82ud7MpGxJKO/67FHpTSieDXIXZRkHzTgRIvfcgX9ZMgysSkW0M7q/atQWNRjv+EYpBEBx6ATJVWVNjgohTtkvRDDD0bYqB/F3ROtTpYEBWE0+34Ne+r5nWlpHOq19WDf91dJYLLr4/iUfxaJymziCA42xTGbP3SIfRMqbrh3BeYCtCeyOrZGJSqRZvtiZE1VcAz+sX8qawH0kJDI/yzrDGithXmuxYWFRiWkc+18KWJ9yh4JUNyYpNyab9aD6ylJb1ByJgOjnEZ+vIMxAutXkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Y9lyqS3+YQoBjIZOTagj8aId1ZLbutQqlTf+rCJJTuc=; b=WDVLVQnp4IGWSGMiwIcXeJvlYmnYrJQiy+7p8nB/uxjvwF4KxsEUtYZqhzjs+3boZ2QRXAgYl8TDdbuF/LOP+EgVIuzFVUFNnuCArdinK4AsuGSqvMOtXQcvGcurWWZV9ZY8Kc2+Qel1wqpof5NAp6zoj9fQU6kjjeN4M3iKtJI= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VE1PR04MB6637.eurprd04.prod.outlook.com (2603:10a6:803:126::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17; Mon, 7 Dec 2020 00:00:05 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Mon, 7 Dec 2020 00:00:05 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , Paul Gortmaker , Pablo Neira Ayuso , Jiri Benc , Cong Wang , Jamal Hadi Salim , Stephen Hemminger , Eric Dumazet , George McCollister , Oleksij Rempel , "James E.J. Bottomley" , Helge Deller , linux-parisc@vger.kernel.org Subject: [RFC PATCH net-next 07/13] parisc/led: remove trailing whitespaces Date: Mon, 7 Dec 2020 01:59:13 +0200 Message-Id: <20201206235919.393158-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201206235919.393158-1-vladimir.oltean@nxp.com> References: <20201206235919.393158-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21 via Frontend Transport; Mon, 7 Dec 2020 00:00:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 47936ec3-cf38-4dfb-3807-08d89a430d3c X-MS-TrafficTypeDiagnostic: VE1PR04MB6637: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wKX7bhnQb3FATe2ZL+X+L4jUKRqIw9pR1dicT9NcGqpZc9oE1U+AHYJAPK4/sA3mJxbnX9H4VY0CKaNryIh/Dv2sR8OE1G/6zYCTEEsOE70r9vnZpuGW6648Q9TrpafIPGaht3VqynDQvy7bK5UmxduXS/Ko4Sh7h29dEivS15tSrXCPx4duetELZBgl9aRldEVFi4EM48+COgXWPR2lA6tRkcLfxFASb54a1J5VkYd1KpvUp3VgVhruMxxBquSb386I6ZTJ5MEZMIG4E5lWo1P8dRPPh+71HmsxeZy11/ggLs7id3wtRrWaY/uhCNTp6L+D5yzySkRQU8HFELbC4oKjgmOrPnViI0ZUbjDB14C0a+PJc9OS199/oAcnJn/b X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(366004)(136003)(39860400002)(376002)(6506007)(52116002)(5660300002)(66946007)(66556008)(26005)(8676002)(2906002)(8936002)(1076003)(316002)(30864003)(110136005)(54906003)(478600001)(44832011)(7416002)(6512007)(186003)(6486002)(16526019)(6666004)(36756003)(956004)(4326008)(86362001)(66476007)(69590400008)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: MvRi+X3eIqb7HYHPkOQkVYL6VyFkfQvCAYl/IM8GpXpG7NW68QFdklROgexWdnG+fGj+53ovM29g7uu3TlFQO/AESWHMbfj52rzbDtqnnRuCQ9n3ncsBBXmMZz9yKsHb3VOxkuYmnmlTVWnvPJU3wSG6NbgyfRs7tcPit5Q1xC0SsTsP81InoxNdEX9eH3g2xo8HpTv719zjtATcRUlmGB1iIbGcQSbg4ZVJQeh6YWAKIIMilmAlzuc9wNFaLVm3M+XLf7NkVISaK0enZB2T4yFhOeiD4uJ5Lip7Xa15iAc/hValReuoSZSR++nwWOBumG3lItFVidd8Pv94Aah/LQ4Gc7h8kusMLEliT0sCbo8C4oU92j8ypeofAjWBfBe4SCDIh30qaG8WdlZ3CT8SB5WWPPCjHR5rh1KTDu7PnD59LyXHMad5tDzY3jZMvZuDL3ukpmN/+sqJGE6nBFm68torBIcwZIu+5pp+TUuXZ2OBbR2ydhNXNB+YB1/2LQm0gSBr6SBonewQJJ15E+cYxz6KIYiNyMpsEn+kbLSNTZ/G0TIkRh5ki6tEQ/MXegIHvBpNpeM0Fdn+uF/5IUyOAuIBKgQi97QKaLt2I/bi7V3v8MhiTO/okeC5Lj+JpTTYSyCi6FVCfxeL6uJz1htC5WxvR7frTEpDeUTr2AqHDwdJGGO6K5/TazuLqN6xBIe4bqau4q+s6BlqhrTpJR9To/hgMbNnTHvcNQ1gx9xpl63zDedoSdSft24CQRqiOVUnfOMMCaXKpnMwge5tdwf8frdX+lN6RZ77vURxHA79Kl+6nWg5D5KMP+YIywABB+wY6wuivz+k7IRGvAcE4HUeVtPsSq6u1mQzBxFvNXPEkS/rJqeRty7SRWw0CyJkLCrVnmuuXD8qf9oYlulgpkOHIFAYO/Wv/v/KXUr1wipp/DTt9xaWtPqMrd9m+Tikq8xaBhmnr0i8YgmBkLt2SLfuUcAM+Ng0L98A25axBnVUaI25ZmQ0lADHY5Ui23THdWBX X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47936ec3-cf38-4dfb-3807-08d89a430d3c X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2020 00:00:05.1120 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GrRhobfpaa/spVRqqSsCN4lximKKA1/r9DFfsxLsCFxTLJqHnJGRgASHb4Eo5/YMoCCUvAmV0Amzb1RPtHzzew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6637 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC This file looks bad in text editors. Cc: "James E.J. Bottomley" Cc: Helge Deller Cc: linux-parisc@vger.kernel.org Signed-off-by: Vladimir Oltean --- drivers/parisc/led.c | 128 +++++++++++++++++++++---------------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c index 36c6613f7a36..676a12bb94c9 100644 --- a/drivers/parisc/led.c +++ b/drivers/parisc/led.c @@ -47,10 +47,10 @@ #include #include -/* The control of the LEDs and LCDs on PARISC-machines have to be done +/* The control of the LEDs and LCDs on PARISC-machines have to be done completely in software. The necessary calculations are done in a work queue - task which is scheduled regularly, and since the calculations may consume a - relatively large amount of CPU time, some of the calculations can be + task which is scheduled regularly, and since the calculations may consume a + relatively large amount of CPU time, some of the calculations can be turned off with the following variables (controlled via procfs) */ static int led_type __read_mostly = -1; @@ -80,7 +80,7 @@ struct lcd_block { }; /* Structure returned by PDC_RETURN_CHASSIS_INFO */ -/* NOTE: we use unsigned long:16 two times, since the following member +/* NOTE: we use unsigned long:16 two times, since the following member lcd_cmd_reg_addr needs to be 64bit aligned on 64bit PA2.0-machines */ struct pdc_chassis_lcd_info_ret_block { unsigned long model:16; /* DISPLAY_MODEL_XXXX */ @@ -103,7 +103,7 @@ struct pdc_chassis_lcd_info_ret_block { #define KITTYHAWK_LCD_CMD F_EXTEND(0xf0190000UL) /* 64bit-ready */ #define KITTYHAWK_LCD_DATA (KITTYHAWK_LCD_CMD+1) -/* lcd_info is pre-initialized to the values needed to program KittyHawk LCD's +/* lcd_info is pre-initialized to the values needed to program KittyHawk LCD's * HP seems to have used Sharp/Hitachi HD44780 LCDs most of the time. */ static struct pdc_chassis_lcd_info_ret_block lcd_info __attribute__((aligned(8))) __read_mostly = @@ -119,16 +119,16 @@ lcd_info __attribute__((aligned(8))) __read_mostly = /* direct access to some of the lcd_info variables */ -#define LCD_CMD_REG lcd_info.lcd_cmd_reg_addr -#define LCD_DATA_REG lcd_info.lcd_data_reg_addr +#define LCD_CMD_REG lcd_info.lcd_cmd_reg_addr +#define LCD_DATA_REG lcd_info.lcd_data_reg_addr #define LED_DATA_REG lcd_info.lcd_cmd_reg_addr /* LASI & ASP only */ #define LED_HASLCD 1 #define LED_NOLCD 0 /* The workqueue must be created at init-time */ -static int start_task(void) -{ +static int start_task(void) +{ /* Display the default text now */ if (led_type == LED_HASLCD) lcd_print( lcd_text_default ); @@ -136,7 +136,7 @@ static int start_task(void) if (lcd_no_led_support) return 0; /* Create the work queue and queue the LED task */ - led_wq = create_singlethread_workqueue("led_wq"); + led_wq = create_singlethread_workqueue("led_wq"); queue_delayed_work(led_wq, &led_task, 0); return 0; @@ -214,14 +214,14 @@ static ssize_t led_proc_write(struct file *file, const char __user *buf, case LED_HASLCD: if (*cur && cur[strlen(cur)-1] == '\n') cur[strlen(cur)-1] = 0; - if (*cur == 0) + if (*cur == 0) cur = lcd_text_default; lcd_print(cur); break; default: return 0; } - + return count; parse_error: @@ -267,9 +267,9 @@ static int __init led_create_procfs(void) #endif /* - ** + ** ** led_ASP_driver() - ** + ** */ #define LED_DATA 0x01 /* data to shift (0:on 1:off) */ #define LED_STROBE 0x02 /* strobe to clock data */ @@ -289,9 +289,9 @@ static void led_ASP_driver(unsigned char leds) /* - ** + ** ** led_LASI_driver() - ** + ** */ static void led_LASI_driver(unsigned char leds) { @@ -301,16 +301,16 @@ static void led_LASI_driver(unsigned char leds) /* - ** + ** ** led_LCD_driver() - ** + ** */ static void led_LCD_driver(unsigned char leds) { static int i; static unsigned char mask[4] = { LED_HEARTBEAT, LED_DISK_IO, LED_LAN_RCV, LED_LAN_TX }; - + static struct lcd_block * blockp[4] = { &lcd_info.heartbeat, &lcd_info.disk_io, @@ -320,15 +320,15 @@ static void led_LCD_driver(unsigned char leds) /* Convert min_cmd_delay to milliseconds */ unsigned int msec_cmd_delay = 1 + (lcd_info.min_cmd_delay / 1000); - - for (i=0; i<4; ++i) + + for (i=0; i<4; ++i) { - if ((leds & mask[i]) != (lastleds & mask[i])) + if ((leds & mask[i]) != (lastleds & mask[i])) { gsc_writeb( blockp[i]->command, LCD_CMD_REG ); msleep(msec_cmd_delay); - - gsc_writeb( leds & mask[i] ? blockp[i]->on : + + gsc_writeb( leds & mask[i] ? blockp[i]->on : blockp[i]->off, LCD_DATA_REG ); msleep(msec_cmd_delay); } @@ -337,15 +337,15 @@ static void led_LCD_driver(unsigned char leds) /* - ** + ** ** led_get_net_activity() - ** + ** ** calculate if there was TX- or RX-throughput on the network interfaces ** (analog to dev_get_info() from net/core/dev.c) - ** + ** */ static __inline__ int led_get_net_activity(void) -{ +{ #ifndef CONFIG_NET return 0; #else @@ -355,7 +355,7 @@ static __inline__ int led_get_net_activity(void) int retval; rx_total = tx_total = 0; - + /* we are running as a workqueue task, so we can use an RCU lookup */ rcu_read_lock(); for_each_netdev_rcu(&init_net, dev) { @@ -390,14 +390,14 @@ static __inline__ int led_get_net_activity(void) /* - ** + ** ** led_get_diskio_activity() - ** + ** ** calculate if there was disk-io in the system - ** + ** */ static __inline__ int led_get_diskio_activity(void) -{ +{ static unsigned long last_pgpgin, last_pgpgout; unsigned long events[NR_VM_EVENT_ITEMS]; int changed; @@ -418,7 +418,7 @@ static __inline__ int led_get_diskio_activity(void) /* ** led_work_func() - ** + ** ** manages when and which chassis LCD/LED gets updated TODO: @@ -453,9 +453,9 @@ static void led_work_func (struct work_struct *unused) /* flash heartbeat-LED like a real heart * (2 x short then a long delay) */ - if (count_HZ < HEARTBEAT_LEN || + if (count_HZ < HEARTBEAT_LEN || (count_HZ >= HEARTBEAT_2ND_RANGE_START && - count_HZ < HEARTBEAT_2ND_RANGE_END)) + count_HZ < HEARTBEAT_2ND_RANGE_END)) currentleds |= LED_HEARTBEAT; } @@ -488,10 +488,10 @@ static void led_work_func (struct work_struct *unused) /* ** led_halt() - ** + ** ** called by the reboot notifier chain at shutdown and stops all ** LED/LCD activities. - ** + ** */ static int led_halt(struct notifier_block *, unsigned long, void *); @@ -501,7 +501,7 @@ static struct notifier_block led_notifier = { }; static int notifier_disabled = 0; -static int led_halt(struct notifier_block *nb, unsigned long event, void *buf) +static int led_halt(struct notifier_block *nb, unsigned long event, void *buf) { char *txt; @@ -518,45 +518,45 @@ static int led_halt(struct notifier_block *nb, unsigned long event, void *buf) break; default: return NOTIFY_DONE; } - + /* Cancel the work item and delete the queue */ if (led_wq) { cancel_delayed_work_sync(&led_task); destroy_workqueue(led_wq); led_wq = NULL; } - + if (lcd_info.model == DISPLAY_MODEL_LCD) lcd_print(txt); else if (led_func_ptr) led_func_ptr(0xff); /* turn all LEDs ON */ - + return NOTIFY_OK; } /* ** register_led_driver() - ** + ** ** registers an external LED or LCD for usage by this driver. ** currently only LCD-, LASI- and ASP-style LCD/LED's are supported. - ** + ** */ int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long data_reg) { static int initialized; - + if (initialized || !data_reg) return 1; - + lcd_info.model = model; /* store the values */ LCD_CMD_REG = (cmd_reg == LED_CMD_REG_NONE) ? 0 : cmd_reg; switch (lcd_info.model) { case DISPLAY_MODEL_LCD: LCD_DATA_REG = data_reg; - printk(KERN_INFO "LCD display at %lx,%lx registered\n", + printk(KERN_INFO "LCD display at %lx,%lx registered\n", LCD_CMD_REG , LCD_DATA_REG); led_func_ptr = led_LCD_driver; led_type = LED_HASLCD; @@ -575,7 +575,7 @@ int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long d case DISPLAY_MODEL_OLD_ASP: LED_DATA_REG = data_reg; led_func_ptr = led_ASP_driver; - printk(KERN_INFO "LED (ASP-style) display at %lx registered\n", + printk(KERN_INFO "LED (ASP-style) display at %lx registered\n", LED_DATA_REG); led_type = LED_NOLCD; break; @@ -585,8 +585,8 @@ int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long d __func__, lcd_info.model); return 1; } - - /* mark the LCD/LED driver now as initialized and + + /* mark the LCD/LED driver now as initialized and * register to the reboot notifier chain */ initialized++; register_reboot_notifier(&led_notifier); @@ -601,11 +601,11 @@ int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long d /* ** register_led_regions() - ** + ** ** register_led_regions() registers the LCD/LED regions for /procfs. - ** At bootup - where the initialisation of the LCD/LED normally happens - + ** At bootup - where the initialisation of the LCD/LED normally happens - ** not all internal structures of request_region() are properly set up, - ** so that we delay the led-registration until after busdevices_init() + ** so that we delay the led-registration until after busdevices_init() ** has been executed. ** */ @@ -626,9 +626,9 @@ void __init register_led_regions(void) /* - ** + ** ** lcd_print() - ** + ** ** Displays the given string on the LCD-Display of newer machines. ** lcd_print() disables/enables the timer-based led work queue to ** avoid a race condition while writing the CMD/DATA register pair. @@ -640,7 +640,7 @@ int lcd_print( const char *str ) if (!led_func_ptr || lcd_info.model != DISPLAY_MODEL_LCD) return 0; - + /* temporarily disable the led work task */ if (led_wq) cancel_delayed_work_sync(&led_task); @@ -660,7 +660,7 @@ int lcd_print( const char *str ) gsc_writeb(' ', LCD_DATA_REG); udelay(lcd_info.min_cmd_delay); } - + /* re-queue the work */ if (led_wq) { queue_delayed_work(led_wq, &led_task, 0); @@ -671,8 +671,8 @@ int lcd_print( const char *str ) /* ** led_init() - ** - ** led_init() is called very early in the bootup-process from setup.c + ** + ** led_init() is called very early in the bootup-process from setup.c ** and asks the PDC for an usable chassis LCD or LED. ** If the PDC doesn't return any info, then the LED ** is detected by lasi.c or asp.c and registered with the @@ -715,20 +715,20 @@ int __init led_init(void) (lcd_info.model==DISPLAY_MODEL_LCD) ? "LCD" : (lcd_info.model==DISPLAY_MODEL_LASI) ? "LED" : "unknown", lcd_info.lcd_width, lcd_info.min_cmd_delay, - __FILE__, sizeof(lcd_info), + __FILE__, sizeof(lcd_info), chassis_info.actcnt, chassis_info.maxcnt)); DPRINTK((KERN_INFO "%s: cmd=%p, data=%p, reset1=%x, reset2=%x, act_enable=%d\n", - __FILE__, lcd_info.lcd_cmd_reg_addr, - lcd_info.lcd_data_reg_addr, lcd_info.reset_cmd1, + __FILE__, lcd_info.lcd_cmd_reg_addr, + lcd_info.lcd_data_reg_addr, lcd_info.reset_cmd1, lcd_info.reset_cmd2, lcd_info.act_enable )); - + /* check the results. Some machines have a buggy PDC */ if (chassis_info.actcnt <= 0 || chassis_info.actcnt != chassis_info.maxcnt) goto not_found; switch (lcd_info.model) { case DISPLAY_MODEL_LCD: /* LCD display */ - if (chassis_info.actcnt < + if (chassis_info.actcnt < offsetof(struct pdc_chassis_lcd_info_ret_block, _pad)-1) goto not_found; if (!lcd_info.act_enable) { From patchwork Sun Dec 6 23:59:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11954653 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4E27C4167B for ; Mon, 7 Dec 2020 00:01:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7072122D07 for ; Mon, 7 Dec 2020 00:01:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728792AbgLGABm (ORCPT ); Sun, 6 Dec 2020 19:01:42 -0500 Received: from mail-eopbgr80054.outbound.protection.outlook.com ([40.107.8.54]:57805 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728687AbgLGABl (ORCPT ); Sun, 6 Dec 2020 19:01:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BEQ/4GL3D5CkicJgSmGR+CTyIyT2V/NslYfCKHDWS2edTAltFiz9WKZS8g8jgsVMLvXyjiUJRo8ObDIrCS0NCDBl3rKXxBPs1pTbIec43qpNqPF0mNOQa69Px7grL0jjJV12DdllC8xX3i2UUP9cmTsrYerAjLRHf5pCblJhkskNctid1UgrjTKY/dHh0VueUkXdVh4w/v1oYRFylF9PT7DPc4md6RWTMRiPus67K++WEhCiX6cC+hsoW5/kJFmAb63ctPya98tngeCiIFfBoAdK2qoANLR6+w2A5qWi4aYJkMCV2qwppJ0bM/JjAJDOWM9f9vv8HqP7ZjZGv26j8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YO3y0hndosQW10PzBTQd32CGEWeBUaCxb1xYmAQDgew=; b=bhHlDUojyN60pmYAz0cnqzmgorCT1c1bwA5/Gn04KUuNVFV751QdLVLDUHC0ooKJW66aFsJnYqnqlnNGS97NJq96TOYlw2XnNVjaFQsl+bwap6SBgbhjNf+Rpxbhlp24OPoBjEHecG0OIggWkltCM7xivf01H3P6kunCUSt5UCqk7IG678BrP+L8jRvuk/AnDCsrbSI6ZZf9zP2aDN2JT8/VLDnOvW0lIe0ntUD0Iqgd1FbedAdVVTp/CzdCvlwlLQgUM9i7lRZpYZLXG7a/UdW7bRMeOccjPrpEYJEeyFZbCmwnVv+ylgPFhSOjkQmAUVd7JeWb7FvKN1AwVBqJmg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YO3y0hndosQW10PzBTQd32CGEWeBUaCxb1xYmAQDgew=; b=IrtRMzpd/HTTEIkx3HNUT/dBNB4LVbGruWQDGMt7IJ3qHFIOscWwRW9TIdFDIm2DAwyMpGjycdCcAATMgPwb+EMoGSEjWENRx8g1uC0x+cacxykx7oi4L3XDTJUQpovbnMeUVVk4r7fvg0lsz6Y6vF9JUu78E8xbRA9ACbs6gPc= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VE1PR04MB6637.eurprd04.prod.outlook.com (2603:10a6:803:126::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17; Mon, 7 Dec 2020 00:00:06 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Mon, 7 Dec 2020 00:00:06 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , Paul Gortmaker , Pablo Neira Ayuso , Jiri Benc , Cong Wang , Jamal Hadi Salim , Stephen Hemminger , Eric Dumazet , George McCollister , Oleksij Rempel , "James E.J. Bottomley" , Helge Deller , linux-parisc@vger.kernel.org Subject: [RFC PATCH net-next 08/13] parisc/led: reindent the code that gathers device statistics Date: Mon, 7 Dec 2020 01:59:14 +0200 Message-Id: <20201206235919.393158-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201206235919.393158-1-vladimir.oltean@nxp.com> References: <20201206235919.393158-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21 via Frontend Transport; Mon, 7 Dec 2020 00:00:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 43e97ed3-f231-442a-c99b-08d89a430dd5 X-MS-TrafficTypeDiagnostic: VE1PR04MB6637: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wYxogD61xYwagRtL9lMNjpMhVPuJVXY4ecJfdq0uB6BCq1MU2N6sZFC1DVhJ79ec/ErxRnEYTAXEiGQtbW+Wioe8zOTv+SeF+2af0illsMde5RsvTYAKcBMCIYRV7M5kpFjDOyKsBhskwTbIALgsY//ogXEqUFikjT/GBgihuI13jAEVOds25ds6LhemBCiWxACd9vAe0V6/IxbRpksmp+yFmBYVaScuvTyyszgBBwUjeLg2dWKzlcmjBYugY5OAha+dXOZBENJBdRp2PjdqPMQkV3ZfYInZbLjDscHZC6l0555O4D6919NfXKr02jUAfaTYPABuIxOfqnpvrgXFQtXOQMSmoJtYHhzZxBPczxx5uwXE7GkUAvxRXPaq4NcR X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(366004)(136003)(39860400002)(376002)(6506007)(52116002)(5660300002)(66946007)(66556008)(26005)(8676002)(2906002)(8936002)(1076003)(316002)(110136005)(54906003)(478600001)(44832011)(7416002)(6512007)(186003)(6486002)(16526019)(6666004)(36756003)(956004)(4326008)(86362001)(66476007)(69590400008)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 0OmKOcTf6IeGnCRAo/vgzQHWdsBPLU+40e6xJfUBRvmdjX1C8qajluRcRx2p34vg9UW+TkYdgmghlR2baIT6SiAoPRc4MdXFc9xfn0LHuioJorFqKakgZDsMrgkc1tLNqRKspU3jypjQWq/Lusu4eeWehfxGq5iq8qK8jX7K+2lfQ1XIfSNpOo1LQcvz1jXgUjUKZSRQlu2bcr5SoaTknMg3RmJj7CIZ2vnQl8/3IXewLEmPYkkiLxP/eOr8WUA2fkUPcR+0x1Hwdl9QmflX5k4TXxRrDmEdBHBCtXjzIR4gDA5Yt41/Mm4S3/H8obPf3SPkXmb0DpWdzFfiunz8yJM7Sk8tAvoIA4uPYjySZJFTm8WICPggq4p26DoFKRAGlmiEJht8qXZlgslVePv2yYGBOd5/TGC4aF73OYwIHdVzOHGi4jWTwKCy0+SO81UW371uFGEssOoOlhWXk9GaOh0Jod5/J2ZIVPozpF+OoiX8074sImNS1yaiY/YNKDt4rQQjLaStad/bC02im1crZDWPKo6igRjmdfQocy37w1csaGpP3q0lhZmpOvsUBi5c0Z+arh/1MNoIq8pLDXmhQ2NOw1SRavOQxIvX983xXdcE2KecCVknx6t+LaUI0ihL7IqKewOGfCj1BxybcvhalXL36sbpLvinZReVhJFZZLplB7hRz+olpDxWvLMn9AeDEhh/1FONIRAf0z0BtEbwt8UNvlTMejTXYPIaizHj4VhbkJEfu8uppM36dQ563XFbr7rk5Hpl61I/ccLuD6l4cLyaPUrVVcxVj+pI6Qgvz8nzsWzh+qKcoK+n5JgwkvKvtm5gDHIy8UoODIE60LEqwt2abAWDYv/CZuCllYxVMJzlBdu0cj+JlZWeTzbSgCAdv3M7iNYh/MuyO9Y2TzARTq7pjgD1bNcmXNqp4lwAKteIf2vo8LRwzd/uMwhsVIfxujDSdcZGP6Vy0FnZ1oUqNhkc4DUh0u8RRDsKhZP7X7FbxBtQSo9T8hFnGgknGOPh X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 43e97ed3-f231-442a-c99b-08d89a430dd5 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2020 00:00:06.0444 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: b4zPGyse6yHdrb/7hymJmNg34GCTwr5X4xX3NQ0rZgIvFlJsKzWygzG9Xvr68hNYkgfqA/CSg7A64A4W7Lx8MQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6637 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The standard in the Linux kernel is to use one tab character per indentation level. Cc: "James E.J. Bottomley" Cc: Helge Deller Cc: linux-parisc@vger.kernel.org Signed-off-by: Vladimir Oltean --- drivers/parisc/led.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c index 676a12bb94c9..b7005aaa782b 100644 --- a/drivers/parisc/led.c +++ b/drivers/parisc/led.c @@ -359,16 +359,19 @@ static __inline__ int led_get_net_activity(void) /* we are running as a workqueue task, so we can use an RCU lookup */ rcu_read_lock(); for_each_netdev_rcu(&init_net, dev) { - const struct rtnl_link_stats64 *stats; - struct rtnl_link_stats64 temp; - struct in_device *in_dev = __in_dev_get_rcu(dev); - if (!in_dev || !in_dev->ifa_list) - continue; - if (ipv4_is_loopback(in_dev->ifa_list->ifa_local)) - continue; - stats = dev_get_stats(dev, &temp); - rx_total += stats->rx_packets; - tx_total += stats->tx_packets; + const struct rtnl_link_stats64 *stats; + struct rtnl_link_stats64 temp; + struct in_device *in_dev = __in_dev_get_rcu(dev); + + if (!in_dev || !in_dev->ifa_list) + continue; + + if (ipv4_is_loopback(in_dev->ifa_list->ifa_local)) + continue; + + stats = dev_get_stats(dev, &temp); + rx_total += stats->rx_packets; + tx_total += stats->tx_packets; } rcu_read_unlock(); From patchwork Sun Dec 6 23:59:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11954655 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD95BC4167B for ; Mon, 7 Dec 2020 00:02:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C0C422D08 for ; Mon, 7 Dec 2020 00:02:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728814AbgLGAB4 (ORCPT ); Sun, 6 Dec 2020 19:01:56 -0500 Received: from mail-eopbgr80082.outbound.protection.outlook.com ([40.107.8.82]:2436 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728683AbgLGABz (ORCPT ); Sun, 6 Dec 2020 19:01:55 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nOvIjDhdwhos+KrW6RN5/H7q5RIcrfnc6HbqzF9WPKur+TFvlmqzureFjc8rm29PcfRv+DhhtGkTH6BFtGw/vHixNwhkKPwTTDFFjKsiaa2n9k1RwB+Yvhu+hRmewOdTYzbRabnD7mtDxcZ7xucFL2/LRflVTMdXyfo4b/wIg0BdmDlLkf7yb3vyUZuD1GXTAt28ShV0Rh1eDKIcvAOfw9s4vTDmIMYlHRvwTogVOdym/rvNjDbgAt9O0PF70T7MwaGfv71CFJenebyXFXaDTycuKRYHq6QjXf51jIJ1ReWIY0BkIqOuK1rBSp6jo4uYPaGs7NvWiYyyzZhm9geFng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fe24wXWPqHk0gw/XLrY/J/yPJk51KrqORMkqeYQ007o=; b=RV5qf4Hu9c//I3bOXZIIIf8LFeKzJzBy6Y15sTco+kQR3C9pn4CP92jTp96WWmyO/xCOcfftnqlpQ92Ta7WROulhwy/vvN7CLVxVs6rLB7zS8KN+FGpe6uTTwUlTVXprSpRwS+Uk2SsOSiz4nZOQ3p3PuR5K4IISuA7uFcP89bU1yLmL6cLB2j971x9jE1u3DH1YDw8H14jDDukkcKwI4I+rZEn+UHzDRLCrbmBRh8cQqB5C8so56blINNjab0d64kT0xnYrmO7lru+xt44KPetAOAqQ2V3d/IRidOsYkMLB/DdZIW0K7NFZiQbq4VDQS2kKb80HWxhdON4XiZe/uA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fe24wXWPqHk0gw/XLrY/J/yPJk51KrqORMkqeYQ007o=; b=Ir/iHm7FnOZw84CghTRSeTXbUfaaSQhpZEnNhG9rJ1xzMkNxA8AQpyeNemdG/9N+ErdmxzYQlQzbrLwlFMZpJIRHlupctQ8mKCugOSIsSareTyUm5X1tNT8Q/WmA6DvEXayluqcEf4x2pGTq2r0vprhlvFl/WOeAob4LTk6OwQc= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VE1PR04MB6637.eurprd04.prod.outlook.com (2603:10a6:803:126::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17; Mon, 7 Dec 2020 00:00:07 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Mon, 7 Dec 2020 00:00:07 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , Paul Gortmaker , Pablo Neira Ayuso , Jiri Benc , Cong Wang , Jamal Hadi Salim , Stephen Hemminger , Eric Dumazet , George McCollister , Oleksij Rempel , "James E.J. Bottomley" , Helge Deller , linux-parisc@vger.kernel.org Subject: [RFC PATCH net-next 09/13] parisc/led: hold the netdev lists lock when retrieving device statistics Date: Mon, 7 Dec 2020 01:59:15 +0200 Message-Id: <20201206235919.393158-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201206235919.393158-1-vladimir.oltean@nxp.com> References: <20201206235919.393158-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21 via Frontend Transport; Mon, 7 Dec 2020 00:00:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 53d4cb5a-ce4c-46de-a2a3-08d89a430e4f X-MS-TrafficTypeDiagnostic: VE1PR04MB6637: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rtt/qMdGZCFILcwJsmIiKLqtvBzTWNpg+Nz0zjiFQ7rokKF4MB0AUVFQl5jXEgYGk9C1qXGnlM5X0y6VlEQC+mAsVR6IUm4We1Q9REIjbd3WIYMmEXXdA2AsVPCYliVt07j1UMv015xWXdxuypvnRX3hxb1wH5by4xwLku9QolAsd2EVRj4vGLZTo5iz6iI0XiCfQQRFTz1eJpVsD6lIDdCBkUPGECuPXNcEMSTFG6e9EC2K5o7v8Z6XgEcTJMX9dy/iqjbys272aWEdVs7akA9TdkDxSBDCDW92O8IE/1/KKSktt2fn8Zw+h1J/WPaBxIuebBKrE0R+VdrOqPkgkuSXXsF1/HM6El2WgRG+zqB8X0X/svbK2+7P2hDnV7PI X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(366004)(136003)(39860400002)(376002)(6506007)(52116002)(5660300002)(66946007)(66556008)(26005)(8676002)(2906002)(8936002)(1076003)(316002)(110136005)(54906003)(478600001)(44832011)(7416002)(6512007)(186003)(6486002)(16526019)(6666004)(36756003)(956004)(4326008)(86362001)(66476007)(69590400008)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: FLYYK/RLLRUG5KYpD+BGnSSlwJ2/JpoTPBdkIfStuc2Jx7mfvyAW1dUG4H8WJT/+fEI6SQ5mM/IQnEdaDCEWoQPkGt3kqYdhSdZ1jqtKyXAjgkC+HrEt5tWa1xMGra+OZDonKWakZCprF2eOPNRCP96HT6eGEMMTG7vnX+8SPhkmUTLjgIjdb/PqJjcUBLdvPNaQRs+8L57Y2nMg891rOjUOfaCp3oV9P5mvs2X1FkTORepnCQqf31QmWr7XXPbYMl2xmL6EHsTRb87YTtz4snDiJFHpM3sgslwOmZMHX9U7MBj79cvLKASBr6Cs6GwOKErnoPnJxbEwOz+yLeXUuDo+l3F6NFNThGnMY/MFXvP4RxLdKXe45/mfAx3gZu6061HsqzDy8J+udyNqf/AK4DP4AaFl/9Z1uSfGvYlwt3Y68bRyPCd0QfnfYnI13QRW/n/zFs5ZrAggax6BysZyYG5ng/TaYJmMKU5mTyesRPiqeuB+BJ9hI2OfphpiDfX/cCHyNS8ZwJk713IZAE5HH6jpnDHQAiIlgFlgUolp722h0mNTqC9k6pbkg4PxvkZSG/W/EgK5lCGmOPzh7OCA2V5XRtmg+nbGkRzcmm9auacPZ0kC/6vewiJJri+rwNNzJIA1MECUKT4Qn0hnGUYAqFpgZTlr5FLYae8vycN95m7qKQSDkYQJsl7DpSjB8l2CNqXKoXu1aYCW5BF8q2+JOpgrkoyGTOy0j3ASZWu5pU6aZgJbUmDJccLtBMrav1Sam8a/6dSsTwpL4XHPkhR0ZEqhuXm97G/79MLuxTJ9mNrFZQUDKt2qlzpdW2G+IEIcQzRgYc/kuzu7jyoqubumk0TT0smLM7YbLpBfEFZYX4b4bw7K3wOjjbDeUwUhry4LELYWO8axAOpEAWYLb8sP4WrQXC95XiMomp1Oy0BTeoIKM+ZWe0IGMk8w+g7pjPRN+ZY2Nirzq77SxZhqAfZpQJ3nt9OtwJQati6NHjr8hd+NGWUOyxlh14ENadbokCHb X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53d4cb5a-ce4c-46de-a2a3-08d89a430e4f X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2020 00:00:07.0249 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yCstBQQSP/uznnkkNen5Mavy8Zio/1Wg+Cup/c66jkHpz5AmDS3fhgiMRlrB8ORMyDaRv1bVumsxq+oGC7huww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6637 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC In the effort of making .ndo_get_stats64 be able to sleep, we need to ensure the callers of dev_get_stats do not use atomic context. The LED driver for HP-PARISC workstations uses a workqueue to periodically check for updates in network interface statistics, and flicker when those have changed (i.e. there has been activity on the line). Ignoring the fact that this driver is completely duplicating drivers/leds/trigger/ledtrig-netdev.c, there is an even bigger problem. Now, the dev_get_stats call can sleep, and iterating through the list of network interfaces still needs to ensure the integrity of list of network interfaces. So that leaves us only one locking option given the current design of the network stack, and that is the netns mutex. Cc: "James E.J. Bottomley" Cc: Helge Deller Cc: linux-parisc@vger.kernel.org Signed-off-by: Vladimir Oltean --- drivers/parisc/led.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c index b7005aaa782b..1289dd3ea6e4 100644 --- a/drivers/parisc/led.c +++ b/drivers/parisc/led.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -356,24 +355,28 @@ static __inline__ int led_get_net_activity(void) rx_total = tx_total = 0; - /* we are running as a workqueue task, so we can use an RCU lookup */ - rcu_read_lock(); - for_each_netdev_rcu(&init_net, dev) { + /* we are running as a workqueue task, so we can sleep */ + mutex_lock(&init_net->netdev_lists_lock); + + for_each_netdev(&init_net, dev) { + struct in_device *in_dev = in_dev_get(dev); const struct rtnl_link_stats64 *stats; struct rtnl_link_stats64 temp; - struct in_device *in_dev = __in_dev_get_rcu(dev); - if (!in_dev || !in_dev->ifa_list) + if (!in_dev || !in_dev->ifa_list || + ipv4_is_loopback(in_dev->ifa_list->ifa_local)) { + in_dev_put(in_dev); continue; + } - if (ipv4_is_loopback(in_dev->ifa_list->ifa_local)) - continue; + in_dev_put(in_dev); stats = dev_get_stats(dev, &temp); rx_total += stats->rx_packets; tx_total += stats->tx_packets; } - rcu_read_unlock(); + + mutex_unlock(&init_net->netdev_lists_lock); retval = 0; From patchwork Sun Dec 6 23:59:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11954659 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1938BC433FE for ; Mon, 7 Dec 2020 00:02:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C3FB322D07 for ; Mon, 7 Dec 2020 00:02:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728827AbgLGAB6 (ORCPT ); Sun, 6 Dec 2020 19:01:58 -0500 Received: from mail-eopbgr80058.outbound.protection.outlook.com ([40.107.8.58]:53705 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727375AbgLGAB5 (ORCPT ); Sun, 6 Dec 2020 19:01:57 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mz27L0IMzgopmsozqdfTmoV3bSbJNabwMemtft9Vdhu3Ivy3PIOFULzxAJpMa/dcRBoGaPVniHPIqbzubri3Ud+QHEIVjasjpWR+hIwl98Dm7jLlJEw8g+uHdj2fTkfAUXW5Ehzivn8J9RPTKBg6JHwwobt1o13TwA1q3tG2Ug6/D6V+xdCK7LMhmo62DG0smy2e0DzVjcXt+IzuJeQxQqjat38SlxJUYCmudeMq0G6YsrWyCKFLRu8LYXgGQ09U59UFwdF+konvQX9y1bJzu6O7/3fkAB9WhMGWAeEZqQIFxHUuFsIhs1zosSmtc0hLYmbkYOMuWU9cGR2UpRE60Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OHmGWui+p+DyYtm0DNC+njXgVzJATjXFcBvLMUSA+fw=; b=IkB3URV6AyNMZOAaTbDnaDOFkdmPFKCeZwxWxndyjm1s1uAKp25VhQM9IfzWLmFZShXXYb2F5HeWNbjEYBfhBcxJ2HWco059m5MBU5aoek3ycHtbVY485V+aa0WpL2QSJH499zUVwoWILjfVH6IrV/WyR5ZT6Ely/fMx6IgLWDTj0y/mjnl8UgMueHc0i7daBjMln4CYuOTp1TOgtxVp7AOhw+G/eCp/HLrnX2HCDRm88g9Mjpf4LMaP7y+pwu3LsVwJ9eN1IpKaO3qnB7ZsluLtf9W3nsNC9s7EdIqk1UGNXA4zb4piLJfVamaFoLkI23th5AsNrhZOi44h14Q5DA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OHmGWui+p+DyYtm0DNC+njXgVzJATjXFcBvLMUSA+fw=; b=Gbgeg8lgnEER1Ltc2K0oxW5NRnbaaxYMH4MFVKBG5xz2knBrmOf2oQMp6zCXKdCgYIiLEdataYvNlXlIipWgEXUtVveOLK0U7F8fx7LwfyUZJE8UXdPIwHG/y8uW7N53HNpvNhBcESapiFpL0YbmwE3n601KmpXQ+4LIs32drU4= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VE1PR04MB6637.eurprd04.prod.outlook.com (2603:10a6:803:126::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17; Mon, 7 Dec 2020 00:00:07 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Mon, 7 Dec 2020 00:00:07 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , Paul Gortmaker , Pablo Neira Ayuso , Jiri Benc , Cong Wang , Jamal Hadi Salim , Stephen Hemminger , Eric Dumazet , George McCollister , Oleksij Rempel Subject: [RFC PATCH net-next 10/13] net: procfs: hold the netdev lists lock when retrieving device statistics Date: Mon, 7 Dec 2020 01:59:16 +0200 Message-Id: <20201206235919.393158-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201206235919.393158-1-vladimir.oltean@nxp.com> References: <20201206235919.393158-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21 via Frontend Transport; Mon, 7 Dec 2020 00:00:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 21442223-46c4-4839-693e-08d89a430eda X-MS-TrafficTypeDiagnostic: VE1PR04MB6637: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ohXlfBm2tX/UpbTrGI/U/qHz9S2JSZ7VuNZ3f9MWJPt+2Hsz8ZAeaZvre84WpGAw33DS0dwhadd71dditj28daVZuJRRzoO5P/ata+0KFt7vtMfLXxzRF9iEgmhxB0ByKKsZCPGnvyFjiHGgk66D3cxxLRFpWvmPEQ8xWnWhSxX59SDr3bW8mt+pC7WgmG/NENod+7J5h6sR2BcSt2gq/dSG4aKLC/JYSYZHpW/nW/ntAoRMft7KPWQ2spmpJjM0jiWu0HWLXIs1YjU6MLM0BmnpRZrB17114Rcfv6vXnSucEL6b4JLttioVzXmPlqM4kwcEf1kIJOcSU+qgQIi7uAUbwNFLwIgoKZxi7F/F+2APX42coawZnnGwPhYtcTzV X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(366004)(136003)(39860400002)(376002)(6506007)(52116002)(5660300002)(66946007)(66556008)(26005)(8676002)(2906002)(8936002)(1076003)(316002)(110136005)(54906003)(478600001)(44832011)(7416002)(6512007)(186003)(6486002)(16526019)(6666004)(36756003)(956004)(4326008)(86362001)(66476007)(69590400008)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 28HdsQhNizOSaoDmVlbgh5kQG1UO1WKw4DUkeQv70NR2kgrOL5U+KxlFRad1Ncf+6yFLjnZacb1ISNXyIf1sry9xVdVPOf/EukwbUux2Ck3DZraZFv/nI+FgUCFQBqEicdSXjgA8BgtXd3ffAospgxLMkZVYtXEE0f5bKsj81WRfV0ACzsONE0zjDB9hD+ghZOyK/0qTcNIS8zZvv955LYUgiqkGwcAlyS7N7xXYgplKD1Q1sqK8aaW9kU8tE+O5jl6jjY5wZe308jltTLgpPjzSWE5G3dE4rDFDppwv8To0AStLDdIAyFEAgcwvrQddzt9QcPWsndLixGhOMpPWJ4QRkqkgDKhjPBW403+QxlluLSC2WDhXXPWssC0GvnXzj1mnJm2vDZOCi3nDP4pX6TAgm+K0B3/xVH661e+/hl8SVonibmJ9p2KkMB6CaRc98AW6HEYMHb34bAWHdahI40bMDe3BBrC6slaQOYxsYAJ2XtDkkKFqDkdtlLzZt2hgKwRedPmrBGxIttznUMwT7jL+ZIDb0c2jvQViAfdKdEamFIkNl4EnhTXllaLKtkp0k6bKqjMUlmkhPpEFlMVwWqUC9z/rDiapC2pD1Fzpgx4rkGdxCsYpFE0+MZr1zlGqhuY4srdo8jlvyZY1l+FW/WTu1b6WRDtV2+HtTrASrWt/cKUHPYqz0GYiIl8R8pt3axIWZUP2mnVXY1EJQwlbzNoMtBazg13Aue0aap7ptAcAtBRbfu6+mCakHESOoNhVGeF4stJzi+5L8PlGMFlrliH4/rrdzCvwJN6Sx2SB1IRFIc6hWPHWnnMK7ea8DbkF/n+/Lb/FqA9lASBhqlct1csw3Q2sc5+cnMAUo1pHTQWUmjQCrnimUZ229C/QJvNupoPamDYa/VB7Pj2+aV+Gl3b3IrlIrtnmXy40YSmjw8AE/CmhRBKnlcI65xME+VjFiGKcjaNmQozIL8jRMuiQs8ofNJs0Y66zkLVzzyHfMy/go6Y1okDSqEcdA50t9z/z X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21442223-46c4-4839-693e-08d89a430eda X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2020 00:00:07.7655 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ut/FkbzCcTYYtkDNM2qVn4ezT37tRqst9+Ng5slSkqnfnKdezXeAS5yOnLpYS+Jv9DhklounlNZ6/neFH/Cfvw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6637 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC In the effort of making .ndo_get_stats64 be able to sleep, we need to ensure the callers of dev_get_stats do not use atomic context. The /proc/net/dev file uses an RCU read-side critical section to ensure the integrity of the list of network interfaces, because it iterates through all net devices in the netns to show their statistics. To offer the equivalent protection against an interface registering or deregistering, while also remaining in sleepable context, we can use the netns mutex for the interface lists. Cc: Cong Wang Cc: Eric Dumazet Signed-off-by: Vladimir Oltean --- net/core/net-procfs.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c index c714e6a9dad4..83f8a89dfc5a 100644 --- a/net/core/net-procfs.c +++ b/net/core/net-procfs.c @@ -21,7 +21,7 @@ static inline struct net_device *dev_from_same_bucket(struct seq_file *seq, loff unsigned int count = 0, offset = get_offset(*pos); h = &net->dev_index_head[get_bucket(*pos)]; - hlist_for_each_entry_rcu(dev, h, index_hlist) { + hlist_for_each_entry(dev, h, index_hlist) { if (++count == offset) return dev; } @@ -51,9 +51,11 @@ static inline struct net_device *dev_from_bucket(struct seq_file *seq, loff_t *p * in detail. */ static void *dev_seq_start(struct seq_file *seq, loff_t *pos) - __acquires(RCU) { - rcu_read_lock(); + struct net *net = seq_file_net(seq); + + mutex_lock(&net->netdev_lists_lock); + if (!*pos) return SEQ_START_TOKEN; @@ -70,9 +72,10 @@ static void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) } static void dev_seq_stop(struct seq_file *seq, void *v) - __releases(RCU) { - rcu_read_unlock(); + struct net *net = seq_file_net(seq); + + mutex_unlock(&net->netdev_lists_lock); } static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev) From patchwork Sun Dec 6 23:59:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11954657 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 385BCC19437 for ; Mon, 7 Dec 2020 00:02:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EBBAB22D08 for ; Mon, 7 Dec 2020 00:02:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728832AbgLGAB7 (ORCPT ); Sun, 6 Dec 2020 19:01:59 -0500 Received: from mail-eopbgr80049.outbound.protection.outlook.com ([40.107.8.49]:17892 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728683AbgLGAB6 (ORCPT ); Sun, 6 Dec 2020 19:01:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y0XgaJjkReN50lvXF/Hbg0v6+FNQPE8Tpx/NrGj08GiRPDsMsNCWnBPhLxoT8QjRRfgXGnqgtRrG5Y9hDjwox1DN4wVgSfu3sy64DLzb3jsw6/8MpQTE0WxKb2rb0MVHppUsLNsualltVngrzspeDlwfFjEJMFJDbiNUvZcJgtq6f2OQXYQ0UoyImOt8LTe/555GO9J2fmc3feuZJ4k6tK6ePu6qdraNizTphb6h+UdCjtIaplUTwVYhUPaxUkHY8UO0FQsq3OhwMjEM0FlpFodrrZBSpjcQDBV3kDWE8gdNgHu+VQNsLJeeTJJsNauIwZ6UCO9gKmG1GGbziFcZSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q1aaSplXW7VCc/5O8O2/UDxdFpNfODNYhSZ9QSiG4wY=; b=HHb7bTaGMZHYzmF7hT3PPnl1GKcSAEGvDBTO/oCLcBQl1oIZFnsKiUqX8g/pgOw6THnupQ/XhhMug2I+ONIYEVKYbCI/5/7Dyje9MAOkwgjUIX6pxSB5pO5Wabi2E+B7M4RuUczbvzmEEeGF6ct7WPxREpzXXYC5PiSGGRMkufjmYwpaBys41IDJwQaaxLdOhjIjxQTKjji92elGpIyI/hZB8/QXqaPNjy3kFIPPfUoZFM1kkygApdFzHHIT2Hp0+W10ht5eQJDYXCrO6clM9yKcQcvlPyFFNOTPBSejx41ITHR0EydxEJUnGbhStuaEyIV4+jeXkUkg9+7IQRDMbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q1aaSplXW7VCc/5O8O2/UDxdFpNfODNYhSZ9QSiG4wY=; b=ZmhrAp8Q0T8f87qbquPxcknhB3AFLgfJNQGSfMXMlDiRi7w1mw3NT+vMQb/hcE/6j2Ztg5aXZRqZNcBmvZBxafvR7MLfvZVivk0vsuyY0s6n/1sQha4QDsz6DsqUMvIOivJfGxqV+O2TqoIwd0oUqxVyfYgSs0UmwiPYeTnoIts= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VE1PR04MB6637.eurprd04.prod.outlook.com (2603:10a6:803:126::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17; Mon, 7 Dec 2020 00:00:08 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Mon, 7 Dec 2020 00:00:08 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , Paul Gortmaker , Pablo Neira Ayuso , Jiri Benc , Cong Wang , Jamal Hadi Salim , Stephen Hemminger , Eric Dumazet , George McCollister , Oleksij Rempel , Christian Brauner Subject: [RFC PATCH net-next 11/13] net: sysfs: don't hold dev_base_lock while retrieving device statistics Date: Mon, 7 Dec 2020 01:59:17 +0200 Message-Id: <20201206235919.393158-12-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201206235919.393158-1-vladimir.oltean@nxp.com> References: <20201206235919.393158-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21 via Frontend Transport; Mon, 7 Dec 2020 00:00:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 78b2c608-f89f-4387-3117-08d89a430f53 X-MS-TrafficTypeDiagnostic: VE1PR04MB6637: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T3CC+M575zOEt3IRbw8DalIxCUqL/YSgCNvfh+E3AxHJpiQClHxy9FXZkSkPksGWFcs1GWxTSrSvQ7xTQqdTu9XDXb9Sez6qnwO1Ky40g1hbVyPb4fTh+IHUZnNXl/j9gT0+BbT4lgkkVl2C1fC8nlwImAEAF5LjWd9yZu75JSoagb7MnITsXJaaGiHfZrYP1sjruSriy4wVIzK3Uj2z3U9M806900zaYxLcbjASfM+CCzjjg8uheue5TMqvEczNQiVU5fHGww+pKwrBYC2i1tV/hVG/uAhpwEbWLRlCrkvG+q3r123rEBD0JjmRZMgfso0pYGdt8J73IRbkwdhtgyin1jqEa8ghtkI9vcDT2seIJJ2X19HR2adtcJrrQ7iq X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(366004)(136003)(39860400002)(376002)(6506007)(52116002)(5660300002)(66946007)(66556008)(26005)(8676002)(2906002)(8936002)(1076003)(316002)(110136005)(54906003)(478600001)(44832011)(7416002)(6512007)(186003)(6486002)(16526019)(6666004)(36756003)(956004)(4326008)(86362001)(66476007)(69590400008)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: pX0eL/Ayi+cDZft4fn2Dg7PrMoz8i6OZ/XwnZG8osI8/Zd30QySGYcnR/kShrIiC1H/uAvIqaMa3caEEuK0s+TflByYPPfAilHuCVang13D1jdbuCp6Qinmcx3WDSlItgb+Hd0QM4jf6SiFX+C78gR8uqx53sAjpOwGvCF0bWf0Bxnkp0TTwqDQGmwfNF8mTqVTr94wZp/mhTPIBcwKsPMoUiTU2oBg/4VPFcJQ2RMr6EtUnLUONZEU4e3vT+A2ymRTpK4tLNl28Rb3MfxsRoSAZvJCJMBW5tq2uocQuFt03xIy2spuMNeLWVBjdBQnsjMulVbzzf79Y05FtxZ53FcJYzER7SzGCeZZJC1FKYd6Dx99bn4jMxa/xEpqYBdKGOv+MVB05TESDVAhqu5UJogy2Oql3c1Efhn4hjZk3EQWqdrEAQ7PU8mxx65rWAWILyuCXAW990ASvX7U4DNaEfF+CwFY/mB6JWqYAE9AGaJ5LhJ3m7tRNLTWgHRqXuKNsBtj07h8dEJIw4lMFvQ0/167qdqlYtW76enPqd2eg68EtI66B2ech2Q0uXEhM+/AhpY9ru+4L0pMRwUWncoEtL5LLrkZaUnG2EvPdWzu3NUhEhrKG7q1W3FY1/7xJoEHSOgARclQ3/VX54XB57EzZlMbeUfKA+5ogMn7R/ShhfXLerNlfGh+0S2/TdV+2W/Rxh24Tg3gbgAsZqkHq6E8L9NDGGXMwR01RgIcIJvQ21f6OgNsNhlDUlwGi/BGmmMTDzNKgLZXXtE/IchnZYDIwS7bDWK7iooXcwLiKzQ2NG52v11iFGE2PpymBrBAeXjq+n8cqi4JiIctTHMNXZ/uNLczE+QuQf91RzG/2WLnJx2IvHkPqFQYAvRok/7qS1xkJ1tmYk56iuBGd8l0ublcn3UEstYXBytRBo941TMsEFgaDttvZeZAxQCPNT0lON3vaLXiABvXLx9GjP/3n3qOxXN5lss3NG0coEacuSU8k0D3tpvCqYy4Ns8mCnXV3xB1T X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78b2c608-f89f-4387-3117-08d89a430f53 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2020 00:00:08.5590 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1ySFUYTotQGvb7mt0Uohe62aou17atBWu53D8vlPp4KV/T5MC+MEsHs8OYuwTIfkvPv+qoAzERubVsiDPGaowQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6637 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC In the effort of making .ndo_get_stats64 be able to sleep, we need to ensure the callers of dev_get_stats do not use atomic context. I need to preface this by saying that I have no idea why netstat_show takes the dev_base_lock rwlock. Two things can be observed: (a) it does not appear to be due to dev_isalive requiring it for some reason, because broadcast_show() also calls dev_isalive() and has had no problem existing since the beginning of git. (b) the dev_get_stats function definitely does not need dev_base_lock protection either. In fact, holding the dev_base_lock is the entire problem here, because we want to make dev_get_stats sleepable, and holding a rwlock gives us atomic context. So since no protection seems to be necessary, just run unlocked while retrieving the /sys/class/net/eth0/statistics/* values. Cc: Christian Brauner Cc: Eric Dumazet Signed-off-by: Vladimir Oltean --- net/core/net-sysfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 999b70c59761..0782a476b424 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -585,14 +585,13 @@ static ssize_t netstat_show(const struct device *d, WARN_ON(offset > sizeof(struct rtnl_link_stats64) || offset % sizeof(u64) != 0); - read_lock(&dev_base_lock); if (dev_isalive(dev)) { struct rtnl_link_stats64 temp; const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp); ret = sprintf(buf, fmt_u64, *(u64 *)(((u8 *)stats) + offset)); } - read_unlock(&dev_base_lock); + return ret; } From patchwork Sun Dec 6 23:59:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11954661 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DC01C19425 for ; Mon, 7 Dec 2020 00:02:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F7E222E03 for ; Mon, 7 Dec 2020 00:02:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728839AbgLGACE (ORCPT ); Sun, 6 Dec 2020 19:02:04 -0500 Received: from mail-eopbgr80054.outbound.protection.outlook.com ([40.107.8.54]:57805 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728632AbgLGACE (ORCPT ); Sun, 6 Dec 2020 19:02:04 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dvYFJ04jeOzHl9YpRAHjkJTXazjl+ZS9mmP1ta88mkK7yl7FTKqcf3Tu03eLtAB2pPbqeS/6HmtWPzGJq2XzAGn/e5WlzU/Mf+BPEJXItY1J7WOugUbcb05lgMBPufcHcHGtcDVrFLUP6eWoVHh9tOWDPy73Os2TxFiKiSIoc9R8bat2LAaN0aMjZYYMDp53rAcRM3++3UwWvT/Erfu+8m+0cydoG9YCVR4E42HeW0kCM0GGTIoaapfvj6eWnF3PA0woiEltW2AjEMWxmS7IEY+dxo0A4Xy3r7M66tOnIZGlpTcNayY4GTYORgURoaHhmrrlgdlfsoIzefuoqMmX2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iwx+FYPRMg3O5R99oiba+alxiCgFfXMdLjcnG53F6xY=; b=j2xu1jqiQZM9pEWpBtX68jVzRIeNIpvsAITkcUZGe9UULBCFuNGXRpo22hde/ivsRqjVJ/fUMscFMWlAswij+yDn5wo9m1CIVQ4cZO4iDpZVCmKwLIa9ILTCNJT8PWlQBSXHO8pzUdT4/XUq+iBe2YFpHGuLOdSZVo31fbTUq6w8f+mYb0uJVB+ytyk5cgbjGrTAwViO3+boa4Y50yujKIUOmTrck0l3qSeAX6phxpdG02gs03ojJhZ/pfJwGxB36Mhu8IWbOgihxybJB+//7dSlyAr5laLoBegA1+zqTkw7P8LKhOYJ/lZT4+EHFSd4oZjrxGHuf3Bpg6ob3btyOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iwx+FYPRMg3O5R99oiba+alxiCgFfXMdLjcnG53F6xY=; b=Z6DwRxjGRtgMwboXMupRdcPFGbfzFoK7JMgm/B5cz2aljVJpbNKBhr77DwJYZXmyizVvPPLyfazhgIEjq1zPudegzYiVcMEMjxdJcvGnUTKPFISBXYUeMxkJ0CemkLcxy1UNN5XOhDDNCws8dNJ1NRU0l6w4ujCJiVqB9nXdGy0= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VE1PR04MB6637.eurprd04.prod.outlook.com (2603:10a6:803:126::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17; Mon, 7 Dec 2020 00:00:09 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Mon, 7 Dec 2020 00:00:09 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , Paul Gortmaker , Pablo Neira Ayuso , Jiri Benc , Cong Wang , Jamal Hadi Salim , Stephen Hemminger , Eric Dumazet , George McCollister , Oleksij Rempel Subject: [RFC PATCH net-next 12/13] net: mark ndo_get_stats64 as being able to sleep Date: Mon, 7 Dec 2020 01:59:18 +0200 Message-Id: <20201206235919.393158-13-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201206235919.393158-1-vladimir.oltean@nxp.com> References: <20201206235919.393158-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21 via Frontend Transport; Mon, 7 Dec 2020 00:00:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 2ee4c55d-41f1-4c22-6991-08d89a430fce X-MS-TrafficTypeDiagnostic: VE1PR04MB6637: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yOHW0fa4TkDhKns3i6Zia0ZJJ6MidA7o41QQTbn9yXKvJ31uYmNDRfIL/jWMm/7Ex/nicHSvUEzjKZbIYPZvY1Fe4z5qm9ORdpy+x9EbFmj2vX3Q1J9k+0kiULh0NVo+UO2VekhHmSncQPYlTtSHacQRbbx/bdX/P3aRn7T76XjEPgUrLZY3UAL4B3Zu+KRng2oZLluRF5iAmDvBy5zLHsSnblh7SeVIYIy6TZmQHwiJ9q+Nag6Gx/xAtHxclvHEGrHInOZLY2hINZa1eiCZadV6LzNP6RcZvKQEgT0aHo4jInn6HalS4B0mCa49Q3HwGwl3SExMEa5snYfYRr9fkhST4iJXkMBG4xuSk3cNdj8h/QGi1c3U0gdOBTCV0UvQ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(366004)(136003)(39860400002)(376002)(6506007)(52116002)(5660300002)(66946007)(66556008)(26005)(8676002)(2906002)(8936002)(1076003)(316002)(110136005)(54906003)(478600001)(44832011)(7416002)(6512007)(186003)(6486002)(16526019)(6666004)(36756003)(956004)(4326008)(86362001)(66476007)(69590400008)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 2Lx+rK31YWMlwRgLxSVW0I8oo9epZl0FdZ0c8Xfmf3kW1dZtuDJU94Ui0Bf6wWpv4cJldojLxA/tN0/SFvQeGmmwl179Oo47P0ehHOk+FjdKOmEn2hhEVjQwStCGqLBQeFiM0MTARQ525Oj1xOJmvwFwtpFQXD7Uhf171uEyQM2Pf35gnDCA5O5SxVhua/pKw/dpMHAzJcJIFvxUqkKuOK9Mj22Ad2KkcE24x/ABKKxJCo4Fo4GFTJ08th4X7UXRt6i+c3ogQmLjuOlmRXtNmRF0A4RrkP/mB959yVEyKquAz9LmFIZN+XUc/PODPB9QTG/eYUBtFoCtw2zH/LiOhd/T+CQCUbeOr6HcEDC8+wZdQjG24897mDEIL0L+6oG5A5SuyfbGMgFpGNJNoHnZBeNxXgmK4lkkQxbnTjzaF2cBeibrlgo99WSmKuH4r6nmPVfe0AaTe53H2hkLTGb1o7OwLekIEWCBeeEOLcQbb/1sWONYYtkytqEeYrCSJDCm7qNRq8RbFvRGkIxaliyBetkC1pvaG0wVkX4p65w1Tby6NW0jdc2K8tZ1X47lckeiIhAGAmL9lh44Feo8PRkAxkTF1hv9/t6xIlLUmR5I26P/NhF32+pDCJc8I8PPdCjCr3ny94F6GoaA6Cl2fDlciay3hYwyZcu2ho25EBDjVpSY5D0ZXr98NlIg5x6loAw85RdP/Muk2cNN8Jj2t978iVRZ6VYPmatpDPb7Cht/hp+/Tgs0TUg1sXIyPXja6JTXkzTOLSva0iwLJk2yVZUsWHYMFp/MlNZmNMXSLLDzElmU+PaeRRu+J/59jBn+o1zilMtG25gTRrbdU21QsXLr9VIjbZ7UldhqY1KiJD6iwOaXJRmDywFeYZtaxIGQZF/n39IkXRk6SHmPztsB/bqU+eq5oZtA6PcJR03tho3zLvEifhu0Z1VLSikk7BbhlEVPQ+Jye5Qt5EIwQdWr2szpnE8QC/0N43W8mpkHjoRFSTplbvNJj+dhx5Bjf46QqWfR X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2ee4c55d-41f1-4c22-6991-08d89a430fce X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2020 00:00:09.5474 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6mPyvHZPu8fdBZyjKnzRNhG+ibc8uZ2fFGy7XAo8URTSLvzTBYw0viFfPKEs7ayBfpLlOESIcTo7CuAfUlkL3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6637 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Now that all callers have been converted to not use atomic context when calling dev_get_stats, it is time to update the documentation and put a notice in the function that it expects process context. Signed-off-by: Vladimir Oltean --- Documentation/networking/netdevices.rst | 4 ++-- Documentation/networking/statistics.rst | 9 ++++----- net/core/dev.c | 2 ++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Documentation/networking/netdevices.rst b/Documentation/networking/netdevices.rst index 5a85fcc80c76..9d005cbf84f7 100644 --- a/Documentation/networking/netdevices.rst +++ b/Documentation/networking/netdevices.rst @@ -64,8 +64,8 @@ ndo_do_ioctl: Context: process ndo_get_stats: - Synchronization: dev_base_lock rwlock. - Context: nominally process, but don't sleep inside an rwlock + Synchronization: none. rtnl_lock() might be held, but not guaranteed. + Context: process ndo_start_xmit: Synchronization: __netif_tx_lock spinlock. diff --git a/Documentation/networking/statistics.rst b/Documentation/networking/statistics.rst index 234abedc29b2..ad3e353df0dd 100644 --- a/Documentation/networking/statistics.rst +++ b/Documentation/networking/statistics.rst @@ -155,11 +155,10 @@ Drivers must ensure best possible compliance with Please note for example that detailed error statistics must be added into the general `rx_error` / `tx_error` counters. -The `.ndo_get_stats64` callback can not sleep because of accesses -via `/proc/net/dev`. If driver may sleep when retrieving the statistics -from the device it should do so periodically asynchronously and only return -a recent copy from `.ndo_get_stats64`. Ethtool interrupt coalescing interface -allows setting the frequency of refreshing statistics, if needed. +Drivers may sleep when retrieving the statistics from the device, or they might +read the counters periodically and only return in `.ndo_get_stats64` a recent +copy collected asynchronously. In the latter case, the ethtool interrupt +coalescing interface allows setting the frequency of refreshing statistics. Retrieving ethtool statistics is a multi-syscall process, drivers are advised to keep the number of statistics constant to avoid race conditions with diff --git a/net/core/dev.c b/net/core/dev.c index 18904acb7797..45a845526b64 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10367,6 +10367,8 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev, { const struct net_device_ops *ops = dev->netdev_ops; + might_sleep(); + if (ops->ndo_get_stats64) { memset(storage, 0, sizeof(*storage)); ops->ndo_get_stats64(dev, storage); From patchwork Sun Dec 6 23:59:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11954637 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7266DC19425 for ; Mon, 7 Dec 2020 00:01:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4EEF722D07 for ; Mon, 7 Dec 2020 00:01:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728692AbgLGABB (ORCPT ); Sun, 6 Dec 2020 19:01:01 -0500 Received: from mail-eopbgr150052.outbound.protection.outlook.com ([40.107.15.52]:29828 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727661AbgLGABA (ORCPT ); Sun, 6 Dec 2020 19:01:00 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=faHcYrl5Ppt766mLNPP+GaUG/PihURsm+DoP9OcGkFrb1qbbWiiAHAz2LFdejWCeToFP8Sqv588IBhQFr9ml1uubQ5cHqgiBXlY0YQh3uXVXdj2SeoeXC9Ag/lUdL7emU46Re5OBQJmCd8g4e66UWnagliHE7hj9rWi92gNaufjtXVqRJXOlsGCts5d7lBBqCFhCw4ff4DbcEkQWvrUuwjoI1dGCajfoC0gM4sCbhVhAyY38pOtb/5Sq3lCFgOfWTtuJOziw3Nxr8LLyfUoIJhfY/eIHxUNmnomI4IKaN0JCH6supk5Ty7RBkHTgmHUQztdLvy8aPdO4SiYPERZPfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=syJmnDIcP9vPDwvyxxM1qoW4SiyaCBwoBEiboGQQTds=; b=ekdegJsLa4upvcNK9+q8VFECu/6H0nl2QW/s3I1R3FO6WBGAzqaMNy1Z6bD1Vhg9wy9/kFQN65lkGHzC6+XDhP4N15Q9L32RjAySIJ8Qhgm+0LRK0LVsJdXJ33kxWoQgyMGvS5lls83wBR9fHGX50GKnS3fMxU8nHipUts8p80CQjO/MYxVIG6OUhEhSM4ZyxLZZSCVCpQZs3qhePMT7Kh5biyO5v0dEeez55V/4qOWlQjyfl0yJqCRF8vPuirIL4DOu/Z/5mE5lXtftAlj7/fN3myyLjr7bGl2iMpNcUubqB48owVB05wEewwN2WWJfwy4pclBN4SPdFAZ97bOuJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=syJmnDIcP9vPDwvyxxM1qoW4SiyaCBwoBEiboGQQTds=; b=S2ffH4qxcMjhDS2V4oGL1WvMrANH/9vnAuNawradGJNfmNQaDjA70pCmoIRGD88W0GYyPfJboKFGViVS8dwULTPiJ95QHPk697hhoQazvA6HvKJ+IMI1R0CZ53ZSgQJakkHzUB33o2k88SQajJyzxiomUadLGw957lsgNTzXEpI= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VI1PR04MB5502.eurprd04.prod.outlook.com (2603:10a6:803:c9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17; Mon, 7 Dec 2020 00:00:10 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Mon, 7 Dec 2020 00:00:10 +0000 From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , Paul Gortmaker , Pablo Neira Ayuso , Jiri Benc , Cong Wang , Jamal Hadi Salim , Stephen Hemminger , Eric Dumazet , George McCollister , Oleksij Rempel Subject: [RFC PATCH net-next 13/13] net: remove obsolete comments about ndo_get_stats64 context from eth drivers Date: Mon, 7 Dec 2020 01:59:19 +0200 Message-Id: <20201206235919.393158-14-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201206235919.393158-1-vladimir.oltean@nxp.com> References: <20201206235919.393158-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by VI1PR08CA0156.eurprd08.prod.outlook.com (2603:10a6:800:d5::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21 via Frontend Transport; Mon, 7 Dec 2020 00:00:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c9b0d924-4aa9-4486-635c-08d89a431065 X-MS-TrafficTypeDiagnostic: VI1PR04MB5502: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:525; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +wdKwk7xuQJL7Rv2Ax5N9psUtHLioz7yuGyi1tXQdDGShHGQLPIHJdsKEMVINCmPyW51St/uKLeXE9v6qcPp6TUXmD3tnsihK6eLAAXt/pUOV2qegoI+4NPDX5u+v0wgR6fkrjbe4So7C59t6GtAN8I+CccyyQDcXZFQT9Y4fIpoVAQqleStjlNCFwfbrbiqDtHp5VWf6uWv6V5KI+ZzoC8/kOGDYz9GYUMVnuJsjZeqWxDX2QS8SMrS0hIUfb031yDOCOd4OsdcXnCyWPaNWlq7ZziTzS8qnQ838OCv1M+yvcVg66xlN0sUpFCnnS6VqPxTLYEY8P64moRHS4b33Y8Z1XTnfaSesNSB8RNW68/XT1I1E6y0jqrxJMxZMYq8 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(39860400002)(366004)(396003)(346002)(136003)(26005)(478600001)(8936002)(5660300002)(8676002)(6512007)(6486002)(186003)(36756003)(52116002)(16526019)(4326008)(1076003)(956004)(66476007)(2616005)(110136005)(54906003)(69590400008)(66556008)(2906002)(44832011)(66946007)(86362001)(83380400001)(6506007)(316002)(7416002)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: BeHhn+bpVvlaiux1A0c3JfmcO2eOzWDFChJK1Ms9e3koXR3if+/Ziw4CCjavcmAx3wgK3MtArwf5/l0xrw68gsey5jmuEdbnbvr1UZhqoWQ14oav/TrjjPzeyfZTA8hKMvKUHDGw6hLrnUdO2ic2BI2/kSAP708N3e5q2yNKGlur7A4maeyUC1+VG6syII0IdczKMDyiijxJGEWEyxNhzfmKBN1sqyUk+O8GUf/c3EPKKcHqD60phLGsNWhQNgjtDJDkVwV/ZPwb9mo3Q0h53N1SIPyldnpqXy5oecM92HFrMt7qo/GRSxeoiPsdDZTBdy+KxZcfwY5i0ko6tVEZqRml6nmvR5mKBbUOQr3RoiDNw3pxhRmaA0Sfofm7Dif2BOxk05wVJax206TRrC9Z72xYnHhWBapWLwAzJy2C32WZJ8H2iRs06jsrn03idIl62Kb8F3PWbXiMXktJYeaBgnTRbHXbhYRPoPgWV7hMdL/ed0bV4drJ/ZWygBxfO2x+wiUgPM5Kzve15eXbiFMKVYA0xIX7zN63sDYWsxyZ9AQnxgWS+Ot2xnsk0I4M6Z3qF3fCRXHo83CmtLIVO3ZMJRrYFMvua3ivDrA613JdqmNU+cqhrsTW+XBR6Oqo7y+2afvTHx8BDB0AlxckVigoHAJY6mjxi4k6RXlz8uE+JbOHoSKtWoju/Xv7/KXPSh5JpNPzDjob5gm6Fp24CH/edX7mVIg1gdH9QZ2y0kbYXnR69d2FIWypjWLprhhZHJHBO/r76HosuovMpcaowhWpQQor2S21DzPEs5r6C1b6/0GiO3V6oEHV8sVjKLJY0XffUmGn5+b2+gCWXF8vTh7wNpSn2mYl7emOhrZrcckw9uFSLJZD5ivgLkUdtw5SborWfG1a7YVXOq2fFUq3yqhzPu4gciO66t9zQIsMEEi2GehRp4BKV6gBF3Y1ABXf80UP3EUJNHe1q1L7OKlyUG9F+VvRe7iHS+tod3s2RTkmIQDoSP6BdB3UFCWHxF5ccYZq X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c9b0d924-4aa9-4486-635c-08d89a431065 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2020 00:00:10.3930 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5EgklLesF53VFzqXIShzHCiu3fCljxTWZQGePBUOkowS6X5LGXW6GbNATZsVZslKkkYqHIpicJ7Eh+24iJapJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5502 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Now that we have a good summary in Documentation/networking/netdevices.rst, these comments serve no purpose and are actually distracting/confusing. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/cisco/enic/enic_main.c | 1 - drivers/net/ethernet/nvidia/forcedeth.c | 2 -- drivers/net/ethernet/sfc/efx_common.c | 1 - drivers/net/ethernet/sfc/falcon/efx.c | 1 - 4 files changed, 5 deletions(-) diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index fb269d587b74..7425f94f9091 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -870,7 +870,6 @@ static netdev_tx_t enic_hard_start_xmit(struct sk_buff *skb, return NETDEV_TX_OK; } -/* dev_base_lock rwlock held, nominally process context */ static void enic_get_stats(struct net_device *netdev, struct rtnl_link_stats64 *net_stats) { diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c index 8724d6a9ed02..8fa254dc64e9 100644 --- a/drivers/net/ethernet/nvidia/forcedeth.c +++ b/drivers/net/ethernet/nvidia/forcedeth.c @@ -1761,8 +1761,6 @@ static void nv_get_stats(int cpu, struct fe_priv *np, /* * nv_get_stats64: dev->ndo_get_stats64 function * Get latest stats value from the nic. - * Called with read_lock(&dev_base_lock) held for read - - * only synchronized against unregister_netdevice. */ static void nv_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *storage) diff --git a/drivers/net/ethernet/sfc/efx_common.c b/drivers/net/ethernet/sfc/efx_common.c index de797e1ac5a9..4d8047b35fb2 100644 --- a/drivers/net/ethernet/sfc/efx_common.c +++ b/drivers/net/ethernet/sfc/efx_common.c @@ -596,7 +596,6 @@ void efx_stop_all(struct efx_nic *efx) efx_stop_datapath(efx); } -/* Context: process, dev_base_lock or RTNL held, non-blocking. */ void efx_net_stats(struct net_device *net_dev, struct rtnl_link_stats64 *stats) { struct efx_nic *efx = netdev_priv(net_dev); diff --git a/drivers/net/ethernet/sfc/falcon/efx.c b/drivers/net/ethernet/sfc/falcon/efx.c index f8979991970e..6db2b6583dec 100644 --- a/drivers/net/ethernet/sfc/falcon/efx.c +++ b/drivers/net/ethernet/sfc/falcon/efx.c @@ -2096,7 +2096,6 @@ int ef4_net_stop(struct net_device *net_dev) return 0; } -/* Context: process, dev_base_lock or RTNL held, non-blocking. */ static void ef4_net_stats(struct net_device *net_dev, struct rtnl_link_stats64 *stats) {