From: Jakub Kicinski <kuba@kernel.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
Johannes Berg <johannes.berg@intel.com>
Subject: Re: [PATCH v2 1/2] net: extend drop reasons for multiple subsystems
Date: Fri, 31 Mar 2023 21:36:21 -0700 [thread overview]
Message-ID: <20230331213621.0993e25b@kernel.org> (raw)
In-Reply-To: <20230330212227.928595-1-johannes@sipsolutions.net>
On Thu, 30 Mar 2023 23:22:26 +0200 Johannes Berg wrote:
> diff --git a/include/net/dropreason.h b/include/net/dropreason.h
> index c0a3ea806cd5..d7a134c108ad 100644
> --- a/include/net/dropreason.h
> +++ b/include/net/dropreason.h
> @@ -339,10 +339,28 @@ enum skb_drop_reason {
> */
> SKB_DROP_REASON_IPV6_NDISC_NS_OTHERHOST,
> /**
> - * @SKB_DROP_REASON_MAX: the maximum of drop reason, which shouldn't be
> - * used as a real 'reason'
> - */
> + * @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which
> + * shouldn't be used as a real 'reason' - only for tracing code gen
> + */
> SKB_DROP_REASON_MAX,
> +
> + /** @SKB_DROP_REASON_SUBSYS_MASK: subsystem mask in drop reasons,
> + * see &enum skb_drop_reason_subsys
> + */
> + SKB_DROP_REASON_SUBSYS_MASK = 0xffff0000,
> +};
> +
> +#define SKB_DROP_REASON_SUBSYS_SHIFT 16
> +
> +/**
> + * enum skb_drop_reason_subsys - subsystem tag for (extended) drop reasons
> + */
> +enum skb_drop_reason_subsys {
> + /** @SKB_DROP_REASON_SUBSYS_CORE: core drop reasons defined above */
> + SKB_DROP_REASON_SUBSYS_CORE,
> +
> + /** @SKB_DROP_REASON_SUBSYS_NUM: number of subsystems defined */
> + SKB_DROP_REASON_SUBSYS_NUM
> };
>
> #define SKB_DR_INIT(name, reason) \
> @@ -358,6 +376,17 @@ enum skb_drop_reason {
> SKB_DR_SET(name, reason); \
> } while (0)
>
> -extern const char * const drop_reasons[];
> +struct drop_reason_list {
> + const char * const *reasons;
> + size_t n_reasons;
> +};
> +
> +/* Note: due to dynamic registrations, access must be under RCU */
> +extern const struct drop_reason_list __rcu *
> +drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM];
> +
> +void drop_reasons_register_subsys(enum skb_drop_reason_subsys subsys,
> + const struct drop_reason_list *list);
> +void drop_reasons_unregister_subsys(enum skb_drop_reason_subsys subsys);
dropreason.h is included by skbuff.h because history, but I don't think
any of the new stuff must be visible in skbuff.h.
Could you make a new header, and put as much of this stuff there as
possible? Our future selves will thank us for shorter rebuild times..
> #undef FN
> #define FN(reason) [SKB_DROP_REASON_##reason] = #reason,
> -const char * const drop_reasons[] = {
> +static const char * const drop_reasons[] = {
> [SKB_CONSUMED] = "CONSUMED",
> DEFINE_DROP_REASON(FN, FN)
> };
> -EXPORT_SYMBOL(drop_reasons);
> +
> +static const struct drop_reason_list drop_reasons_core = {
> + .reasons = drop_reasons,
> + .n_reasons = ARRAY_SIZE(drop_reasons),
> +};
> +
> +const struct drop_reason_list __rcu *
> +drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM] = {
> + [SKB_DROP_REASON_SUBSYS_CORE] = &drop_reasons_core,
> +};
> +EXPORT_SYMBOL(drop_reasons_by_subsys);
> +
> +/**
> + * drop_reasons_register_subsys - register another drop reason subsystem
> + * @subsys: the subsystem to register, must not be the core
> + * @list: the list of drop reasons within the subsystem, must point to
> + * a statically initialized list
> + */
> +void drop_reasons_register_subsys(enum skb_drop_reason_subsys subsys,
> + const struct drop_reason_list *list)
> +{
> + if (WARN(subsys <= SKB_DROP_REASON_SUBSYS_CORE ||
> + subsys >= ARRAY_SIZE(drop_reasons_by_subsys),
> + "invalid subsystem %d\n", subsys))
> + return;
> +
> + /* must point to statically allocated memory, so INIT is OK */
> + RCU_INIT_POINTER(drop_reasons_by_subsys[subsys], list);
> +}
> +EXPORT_SYMBOL_GPL(drop_reasons_register_subsys);
> +
> +/**
> + * drop_reasons_unregister_subsys - unregister a drop reason subsystem
> + * @subsys: the subsystem to remove, must not be the core
> + *
> + * Note: This will synchronize_rcu() to ensure no users when it returns.
> + */
> +void drop_reasons_unregister_subsys(enum skb_drop_reason_subsys subsys)
> +{
> + if (WARN(subsys <= SKB_DROP_REASON_SUBSYS_CORE ||
> + subsys >= ARRAY_SIZE(drop_reasons_by_subsys),
> + "invalid subsystem %d\n", subsys))
> + return;
> +
> + RCU_INIT_POINTER(drop_reasons_by_subsys[subsys], NULL);
> +
> + synchronize_rcu();
> +}
> +EXPORT_SYMBOL_GPL(drop_reasons_unregister_subsys);
Weak preference to also take the code out of skbuff.c but that's not as
important.
You To'd both wireless and netdev, who are you expecting to apply this?
:S
next prev parent reply other threads:[~2023-04-01 4:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 21:22 [PATCH v2 1/2] net: extend drop reasons for multiple subsystems Johannes Berg
2023-03-30 21:22 ` [PATCH v2 2/2] mac80211: use the new drop reasons infrastructure Johannes Berg
2023-04-01 4:36 ` Jakub Kicinski [this message]
2023-04-14 9:25 ` [PATCH v2 1/2] net: extend drop reasons for multiple subsystems Johannes Berg
2023-04-14 14:42 ` Jakub Kicinski
2023-04-14 3:21 ` kernel test robot
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=20230331213621.0993e25b@kernel.org \
--to=kuba@kernel.org \
--cc=johannes.berg@intel.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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).