From: Jiri Pirko <jiri@resnulli.us>
To: Eric Dumazet <edumazet@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, eric.dumazet@gmail.com
Subject: Re: [PATCH net-next 12/13] rtnetlink: make rtnl_fill_link_ifmap() RCU ready
Date: Wed, 21 Feb 2024 17:02:59 +0100 [thread overview]
Message-ID: <ZdYes3iPqzf0FCTf@nanopsycho> (raw)
In-Reply-To: <20240221105915.829140-13-edumazet@google.com>
Wed, Feb 21, 2024 at 11:59:14AM CET, edumazet@google.com wrote:
>Use READ_ONCE() to read the following device fields:
>
> dev->mem_start
> dev->mem_end
> dev->base_addr
> dev->irq
> dev->dma
> dev->if_port
>
>Provide IFLA_MAP attribute only if at least one of these fields
>is not zero. This saves some space in the output skb for most devices.
>
>Signed-off-by: Eric Dumazet <edumazet@google.com>
>---
> net/core/rtnetlink.c | 26 ++++++++++++++------------
> 1 file changed, 14 insertions(+), 12 deletions(-)
>
>diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
>index 1b26dfa5668d22fb2e30ceefbf143e98df13ae29..b91ec216c593aaebf97ea69aa0d2d265ab61c098 100644
>--- a/net/core/rtnetlink.c
>+++ b/net/core/rtnetlink.c
>@@ -1455,19 +1455,21 @@ static noinline_for_stack int rtnl_fill_vf(struct sk_buff *skb,
> return 0;
> }
>
>-static int rtnl_fill_link_ifmap(struct sk_buff *skb, struct net_device *dev)
>+static int rtnl_fill_link_ifmap(struct sk_buff *skb,
>+ const struct net_device *dev)
> {
> struct rtnl_link_ifmap map;
>
> memset(&map, 0, sizeof(map));
>- map.mem_start = dev->mem_start;
>- map.mem_end = dev->mem_end;
>- map.base_addr = dev->base_addr;
>- map.irq = dev->irq;
>- map.dma = dev->dma;
>- map.port = dev->if_port;
>-
>- if (nla_put_64bit(skb, IFLA_MAP, sizeof(map), &map, IFLA_PAD))
>+ map.mem_start = READ_ONCE(dev->mem_start);
>+ map.mem_end = READ_ONCE(dev->mem_end);
>+ map.base_addr = READ_ONCE(dev->base_addr);
>+ map.irq = READ_ONCE(dev->irq);
>+ map.dma = READ_ONCE(dev->dma);
>+ map.port = READ_ONCE(dev->if_port);
>+ /* Only report non zero information. */
>+ if (memchr_inv(&map, 0, sizeof(map)) &&
This check(optimization) is unrelated to the rest of the patch, correct?
If yes, could it be a separate patch?
>+ nla_put_64bit(skb, IFLA_MAP, sizeof(map), &map, IFLA_PAD))
> return -EMSGSIZE;
>
> return 0;
>@@ -1875,9 +1877,6 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
> goto nla_put_failure;
> }
>
>- if (rtnl_fill_link_ifmap(skb, dev))
>- goto nla_put_failure;
>-
> if (dev->addr_len) {
> if (nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr) ||
> nla_put(skb, IFLA_BROADCAST, dev->addr_len, dev->broadcast))
>@@ -1927,6 +1926,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
> rcu_read_lock();
> if (rtnl_fill_link_af(skb, dev, ext_filter_mask))
> goto nla_put_failure_rcu;
>+ if (rtnl_fill_link_ifmap(skb, dev))
>+ goto nla_put_failure_rcu;
>+
> rcu_read_unlock();
>
> if (rtnl_fill_prop_list(skb, dev))
>--
>2.44.0.rc0.258.g7320e95886-goog
>
>
next prev parent reply other threads:[~2024-02-21 16:03 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-21 10:59 [PATCH net-next 00/13] rtnetlink: reduce RTNL pressure for dumps Eric Dumazet
2024-02-21 10:59 ` [PATCH net-next 01/13] rtnetlink: prepare nla_put_iflink() to run under RCU Eric Dumazet
2024-02-21 10:59 ` [PATCH net-next 02/13] ipv6: prepare inet6_fill_ifla6_attrs() for RCU Eric Dumazet
2024-02-21 10:59 ` [PATCH net-next 03/13] ipv6: prepare inet6_fill_ifinfo() for RCU protection Eric Dumazet
2024-02-21 10:59 ` [PATCH net-next 04/13] ipv6: use xarray iterator to implement inet6_dump_ifinfo() Eric Dumazet
2024-02-21 18:39 ` Ido Schimmel
2024-02-21 18:57 ` Eric Dumazet
2024-02-21 10:59 ` [PATCH net-next 05/13] netlink: fix netlink_diag_dump() return value Eric Dumazet
2024-02-21 10:59 ` [PATCH net-next 06/13] netlink: hold nlk->cb_mutex longer in __netlink_dump_start() Eric Dumazet
2024-02-21 10:59 ` [PATCH net-next 07/13] rtnetlink: change nlk->cb_mutex role Eric Dumazet
2024-02-21 10:59 ` [PATCH net-next 08/13] rtnetlink: add RTNL_FLAG_DUMP_UNLOCKED flag Eric Dumazet
2024-02-21 10:59 ` [PATCH net-next 09/13] ipv6: switch inet6_dump_ifinfo() to RCU protection Eric Dumazet
2024-02-21 10:59 ` [PATCH net-next 10/13] inet: allow ip_valid_fib_dump_req() to be called with RTNL or RCU Eric Dumazet
2024-02-21 10:59 ` [PATCH net-next 11/13] inet: switch inet_dump_fib() to RCU protection Eric Dumazet
2024-02-21 10:59 ` [PATCH net-next 12/13] rtnetlink: make rtnl_fill_link_ifmap() RCU ready Eric Dumazet
2024-02-21 16:02 ` Jiri Pirko [this message]
2024-02-21 17:15 ` Eric Dumazet
2024-02-21 18:22 ` Jiri Pirko
2024-02-21 18:56 ` Jakub Kicinski
2024-02-21 10:59 ` [PATCH net-next 13/13] rtnetlink: provide RCU protection to rtnl_fill_prop_list() Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZdYes3iPqzf0FCTf@nanopsycho \
--to=jiri@resnulli.us \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).