From: Hangbin Liu <liuhangbin@gmail.com>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Ido Schimmel <idosch@nvidia.com>,
David Ahern <dsahern@kernel.org>,
Benjamin Poirier <bpoirier@nvidia.com>,
Thomas Haller <thaller@redhat.com>,
Stephen Hemminger <stephen@networkplumber.org>,
Eric Dumazet <edumazet@google.com>,
Hangbin Liu <liuhangbin@gmail.com>,
Ido Schimmel <idosch@idosch.org>
Subject: [PATCHv2 net-next 1/2] fib: convert fib_nh_is_v6 and nh_updated to use a single bit
Date: Wed, 9 Aug 2023 22:02:33 +0800 [thread overview]
Message-ID: <20230809140234.3879929-2-liuhangbin@gmail.com> (raw)
In-Reply-To: <20230809140234.3879929-1-liuhangbin@gmail.com>
The FIB info structure currently looks like this:
struct fib_info {
struct hlist_node fib_hash; /* 0 16 */
[...]
u32 fib_priority; /* 80 4 */
/* XXX 4 bytes hole, try to pack */
struct dst_metrics * fib_metrics; /* 88 8 */
int fib_nhs; /* 96 4 */
bool fib_nh_is_v6; /* 100 1 */
bool nh_updated; /* 101 1 */
/* XXX 2 bytes hole, try to pack */
struct nexthop * nh; /* 104 8 */
struct callback_head rcu __attribute__((__aligned__(8))); /* 112 16 */
/* --- cacheline 2 boundary (128 bytes) --- */
struct fib_nh fib_nh[]; /* 128 0 */
/* size: 128, cachelines: 2, members: 21 */
/* sum members: 122, holes: 2, sum holes: 6 */
/* forced alignments: 1 */
} __attribute__((__aligned__(8)));
Let's convert fib_nh_is_v6 and nh_updated to use a single bit, so that
we can add other functional bits in later patch.
Suggested-by: Ido Schimmel <idosch@idosch.org>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
include/net/ip_fib.h | 4 ++--
net/ipv4/fib_semantics.c | 2 +-
net/ipv4/nexthop.c | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index a378eff827c7..a91f8a28689a 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -152,8 +152,8 @@ struct fib_info {
#define fib_rtt fib_metrics->metrics[RTAX_RTT-1]
#define fib_advmss fib_metrics->metrics[RTAX_ADVMSS-1]
int fib_nhs;
- bool fib_nh_is_v6;
- bool nh_updated;
+ u8 fib_nh_is_v6:1,
+ nh_updated:1;
struct nexthop *nh;
struct rcu_head rcu;
struct fib_nh fib_nh[];
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 65ba18a91865..ce1c10e408cf 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1572,7 +1572,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg,
fib_info_update_nhc_saddr(net, &nexthop_nh->nh_common,
fi->fib_scope);
if (nexthop_nh->fib_nh_gw_family == AF_INET6)
- fi->fib_nh_is_v6 = true;
+ fi->fib_nh_is_v6 = 1;
} endfor_nexthops(fi)
fib_rebalance(fi);
diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 93f14d39fef6..5243bb80bade 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -2213,12 +2213,12 @@ static void __nexthop_replace_notify(struct net *net, struct nexthop *nh,
* and then walk the fib tables once
*/
list_for_each_entry(fi, &nh->fi_list, nh_list)
- fi->nh_updated = true;
+ fi->nh_updated = 1;
fib_info_notify_update(net, info);
list_for_each_entry(fi, &nh->fi_list, nh_list)
- fi->nh_updated = false;
+ fi->nh_updated = 0;
}
list_for_each_entry(f6i, &nh->f6i_list, nh_list)
--
2.38.1
next prev parent reply other threads:[~2023-08-09 14:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-09 14:02 [PATCHv2 net-next 0/2] send notify when delete source address routes Hangbin Liu
2023-08-09 14:02 ` Hangbin Liu [this message]
2023-08-09 14:02 ` [PATCHv2 net-next 2/2] ipv4/fib: " Hangbin Liu
2023-08-10 15:08 ` Ido Schimmel
2023-08-15 12:55 ` Hangbin Liu
2023-08-28 6:14 ` Hangbin Liu
2023-09-11 9:35 ` Thomas Haller
2023-09-12 2:30 ` Hangbin Liu
2023-09-13 9:59 ` Nicolas Dichtel
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=20230809140234.3879929-2-liuhangbin@gmail.com \
--to=liuhangbin@gmail.com \
--cc=bpoirier@nvidia.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=idosch@idosch.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stephen@networkplumber.org \
--cc=thaller@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.