From patchwork Fri Jan 8 16:31:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12006975 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 E9B7BC433DB for ; Fri, 8 Jan 2021 16:33:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C614A23A1D for ; Fri, 8 Jan 2021 16:33:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728353AbhAHQdJ (ORCPT ); Fri, 8 Jan 2021 11:33:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727132AbhAHQdH (ORCPT ); Fri, 8 Jan 2021 11:33:07 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E25B8C06129D for ; Fri, 8 Jan 2021 08:32:26 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id cw27so11796553edb.5 for ; Fri, 08 Jan 2021 08:32:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nWee4KpFbXrnfWRrreVtff9vSyduFCVI9av5RdVizU0=; b=IfdvAJrxigF9mbShzC1YYZn5DDYBclFRLJqqiHZQkobni2ND4k5ueplKm6QiaVk1T9 p9pWPQcLLdO+O6QWg/Ut8jiaZFc9V7iPJM8POHNk1Xx3DwO1vLXp2GNSAMiBVTOYzz/q cIiOENC/FVM14EGmfw4exhBlhRfoBKXe9jCKnhLhzi74OvOrdlRLQ1jtCNeSJSKW636Y ifH+DDyU4SAznssMquntJKks6LRWDhBnVCtK+JPggIZcC/P6t81MRF+hSPQ+UtVqHicL 0LP/hJmQKxLKJZFQT9pPqZsFowYFt8XvGhCrooyp+FzYPFRpiQSQhRAyQd2khdRuYz59 l91w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nWee4KpFbXrnfWRrreVtff9vSyduFCVI9av5RdVizU0=; b=sak7IIxbxhi7JVUmWS7nIVupNQ7i0mUqic/MJMYFdw1S5R3Yer7wi2LXhWEJGpoin5 FyWNH598JAuZGy0SoarNuhY8Wc686HvNCRb4pXPpITA+kmUlWNlYv31BkGUO8IEbPyIJ HzmXaOI0ZocDvqHUflkS7uNUmAwq3VIkdxrYZ7cyy57XtSRuYIOPNXJJrB2hIMlZC/JF A1Qgw0jh/73Ild/58Va1yLqQa1z0Lg3EheSQUaVy+FeLGrZusdJFyd1tML1010obO03F 75uXHimHFwZGtLURbiAsWTR9tXIKKHcLsaHXDvIT3eoyeMsu2b691qXJIyT/nLajE0lz IpAQ== X-Gm-Message-State: AOAM533Lmhgwul2HH/1hdnVhnCfuslXxJPYzkALsYNK0NWY5Y2Otdswi szKm6pojkFnpg25tmgM0qEI= X-Google-Smtp-Source: ABdhPJz+UuMSQ8Z7bY+bBWEoeenWVh6yPfNJsnSdovJpl/gCo4sObCuZTXKbOPSp0ho4NS0UKA5Faw== X-Received: by 2002:aa7:dc4b:: with SMTP id g11mr6028980edu.379.1610123545700; Fri, 08 Jan 2021 08:32:25 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id x6sm3957737edl.67.2021.01.08.08.32.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 08:32:25 -0800 (PST) From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , Cong Wang , Stephen Hemminger , Eric Dumazet , George McCollister , Oleksij Rempel , Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , Arnd Bergmann , Taehee Yoo , Jiri Pirko , Florian Westphal , Nikolay Aleksandrov , Pravin B Shelar , Sridhar Samudrala , Saeed Mahameed Subject: [PATCH v5 net-next 05/16] s390/appldata_net_sum: hold the netdev lists lock when retrieving device statistics Date: Fri, 8 Jan 2021 18:31:48 +0200 Message-Id: <20210108163159.358043-6-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210108163159.358043-1-olteanv@gmail.com> References: <20210108163159.358043-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vladimir Oltean 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 --- Changes in v5: None. Changes in v4: None. Changes in v3: None. Changes in v2: None. 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..4db886980cba 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) { + netif_lists_lock(&init_net); + + 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(); + + netif_lists_unlock(&init_net); net_data->nr_interfaces = i; net_data->rx_packets = rx_packets;