From mboxrd@z Thu Jan 1 00:00:00 1970 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=-2.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 89F8CC433DB for ; Tue, 12 Jan 2021 14:37:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3DB1020771 for ; Tue, 12 Jan 2021 14:37:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727394AbhALOhz (ORCPT ); Tue, 12 Jan 2021 09:37:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726329AbhALOhz (ORCPT ); Tue, 12 Jan 2021 09:37:55 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A8ADC061575 for ; Tue, 12 Jan 2021 06:37:14 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id d17so3810470ejy.9 for ; Tue, 12 Jan 2021 06:37:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=61FjCtpXzvlphj4T6JdOdJ406Vj4ifXYb7l05Ik0pvM=; b=qrB+LYVg89WvpS63mfpIF8OwL5kQQEu4sm08RplVN9jqNgkVhKhZrVFT7uWOJoVT3n j5uHj2rdQVF/xwz2JWUKQGPtiZaEfRaqwBPoF7npOJ2SUffRQTMNZgNQtoG/DgOOw6Nu 1YXi5u0r7tk2DLxJnI4pxeMF7++L5aqeOzTQEhKDyRDgYys6Yu7UjxZD0bFDNSwDCaU9 4LT/9Pnj7HNGuvmkmr31z5XX1+YKEHmUMNciwiuY8Bb9nyQnQoUiNpyu3ZPolghiRyh7 WL5r1ptXit0xM3h5LhSZP0wDRF11Gtgec+w654PuzO/aT89NsldjvXmG/8JDS4zrHnut TDsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=61FjCtpXzvlphj4T6JdOdJ406Vj4ifXYb7l05Ik0pvM=; b=F1MqMftq9yv7wnzualpPVooxtYwNePNEBTuUdwX9X+wydAgMIRyYag79YblcR03a8u lG/IzkM1gJQuebu0RYS7jSi4/5iPUCO3FvTVrnqWweWznRDDwLEMcK18MDbiGE/NdTGd 9Zh46v11Qtee7Q8LChdgbIt2F1/VIPRnkyqE5U1whReRq6tUxSjCdKVy2hZ8NKjnnkeK uw13xkwZtdNh78OiGzWioLCnEyyTUwuIU6DFhSGDo07wJ+tz22ZmBv6rHrcDLGO2VHod sKJAFuHRe7I5MTluVmN4nL/Ly80wUMtx3YsQ3lyd7UsYgiXiqiTU8e2dtf+E5nCmdxH7 RKjA== X-Gm-Message-State: AOAM531P+AsNE3eykqkHOZXlrDx/NHjjJVbuCJAuVan58waWkNcmAjJV sUPBnlPihNgROZ1z5KI/0PLkIEzxvxE= X-Google-Smtp-Source: ABdhPJzoX8A3PVWauIJZfwtS0zro6Fh09EgrxVeXEPSSh0tfgXp5+QUbOLba6fJuolmBn8Ux2tpWDQ== X-Received: by 2002:a17:906:1ed6:: with SMTP id m22mr3584956ejj.231.1610462233264; Tue, 12 Jan 2021 06:37:13 -0800 (PST) Received: from skbuf (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id q2sm1490255edv.93.2021.01.12.06.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 06:37:11 -0800 (PST) Date: Tue, 12 Jan 2021 16:37:10 +0200 From: Vladimir Oltean To: Saeed Mahameed Cc: "David S . Miller" , Jakub Kicinski , 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 Subject: Re: [PATCH v6 net-next 14/15] net: bonding: ensure .ndo_get_stats64 can sleep Message-ID: <20210112143710.nxpxnlcojhvqipw7@skbuf> References: <20210109172624.2028156-1-olteanv@gmail.com> <20210109172624.2028156-15-olteanv@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Mon, Jan 11, 2021 at 03:38:49PM -0800, Saeed Mahameed wrote: > GFP_ATOMIC is a little bit aggressive especially when user daemons are > periodically reading stats. This can be avoided. > > You can pre-allocate with GFP_KERNEL an array with an "approximate" > size. > then fill the array up with whatever slaves the the bond has at that > moment, num_of_slaves can be less, equal or more than the array you > just allocated but we shouldn't care .. > > something like: > rcu_read_lock() > nslaves = bond_get_num_slaves(); > rcu_read_unlock() > sarray = kcalloc(nslaves, sizeof(struct bonding_slave_dev), > GFP_KERNEL); > rcu_read_lock(); > bond_fill_slaves_array(bond, sarray); // also do: dev_hold() > rcu_read_unlock(); > > > bond_get_slaves_array_stats(sarray); > > bond_put_slaves_array(sarray); I don't know what to say about acquiring RCU read lock twice and traversing the list of interfaces three or four times. On the other hand, what's the worst that can happen if the GFP_ATOMIC memory allocation fails. It's not like there is any data loss. User space will retry when there is less memory pressure.