tools: ynl-gen: include auto-generated uAPI header only once
Subsystems (9)
PATCH 1/1 tools: ynl-gen: include auto-generated uAPI header only once
The auto-generated uAPI file is currently included in both the .h and .c netlink stub files.
However, the .c file already includes its .h counterpart, thus leading to a double inclusion of the uAPI header.
Prevent the double inclusion by including the uAPI header in the .h stub file only.
--- drivers/dpll/dpll_nl.c | 2 -- drivers/net/team/team_nl.c | 2 -- fs/nfsd/netlink.c | 2 -- net/core/netdev-genl-gen.c | 1 - net/devlink/netlink_gen.c | 2 -- net/handshake/genl.c | 2 -- net/ipv4/fou_nl.c | 2 -- net/mptcp/mptcp_pm_gen.c | 2 -- tools/net/ynl/ynl-gen-c.py | 4 +++- 9 files changed, 3 insertions(+), 16 deletions(-)
drivers/dpll/dpll_nl.c +0 -2
@@ -8,8 +8,6 @@#include "dpll_nl.h" -#include <uapi/linux/dpll.h> -/* Common nested types */ const struct nla_policy dpll_pin_parent_device_nl_policy[DPLL_A_PIN_PHASE_OFFSET +1 ] = { [DPLL_A_PIN_PARENT_ID ] = { .type =NLA_U32 , },
drivers/net/team/team_nl.c +0 -2
@@ -8,8 +8,6 @@#include "team_nl.h" -#include <uapi/linux/if_team.h> -/* Common nested types */ const struct nla_policy team_attr_option_nl_policy[TEAM_ATTR_OPTION_ARRAY_INDEX +1 ] = { [TEAM_ATTR_OPTION_NAME ] = { .type =NLA_STRING , .len =TEAM_STRING_MAX_LEN , },
fs/nfsd/netlink.c +0 -2
@@ -8,8 +8,6 @@#include "netlink.h" -#include <uapi/linux/nfsd_netlink.h> -/* Common nested types */ const struct nla_policy nfsd_sock_nl_policy[NFSD_A_SOCK_TRANSPORT_NAME +1 ] = { [NFSD_A_SOCK_ADDR ] = { .type =NLA_BINARY , },
net/core/netdev-genl-gen.c +0 -1
@@ -8,7 +8,6 @@#include "netdev-genl-gen.h" -#include <uapi/linux/netdev.h> #include <linux/list.h> /* Integer value ranges */
net/devlink/netlink_gen.c +0 -2
@@ -8,8 +8,6 @@#include "netlink_gen.h" -#include <uapi/linux/devlink.h> -/* Common nested types */ const struct nla_policy devlink_dl_port_function_nl_policy[DEVLINK_PORT_FN_ATTR_CAPS +1 ] = { [DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR ] = { .type =NLA_BINARY , },
net/handshake/genl.c +0 -2
@@ -8,8 +8,6 @@#include "genl.h" -#include <uapi/linux/handshake.h> -/* HANDSHAKE_CMD_ACCEPT - do */ static const struct nla_policy handshake_accept_nl_policy[HANDSHAKE_A_ACCEPT_HANDLER_CLASS +1 ] = { [HANDSHAKE_A_ACCEPT_HANDLER_CLASS ] =NLA_POLICY_MAX (NLA_U32 ,2 ),
net/ipv4/fou_nl.c +0 -2
@@ -8,8 +8,6 @@#include "fou_nl.h" -#include <uapi/linux/fou.h> -/* Global operation policy for fou */ const struct nla_policy fou_nl_policy[FOU_ATTR_IFINDEX +1 ] = { [FOU_ATTR_PORT ] = { .type =NLA_U16 , },
net/mptcp/mptcp_pm_gen.c +0 -2
@@ -8,8 +8,6 @@#include "mptcp_pm_gen.h" -#include <uapi/linux/mptcp_pm.h> -/* Common nested types */ const struct nla_policy mptcp_pm_address_nl_policy[MPTCP_PM_ADDR_ATTR_IF_IDX +1 ] = { [MPTCP_PM_ADDR_ATTR_FAMILY ] = { .type =NLA_U16 , },
tools/net/ynl/ynl-gen-c.py +3 -1
@@ -2683,7 +2683,9 @@ def main(): if args.out_file: cw.p(f'#include "{hdr_file}"') cw.nl() - headers = ['uapi/' + parsed.uapi_header] + headers = [] + else: + headers = ['uapi/' + parsed.uapi_header] headers += parsed.kernel_family.get('headers', []) else: cw.p('#include <stdlib.h>')
Signature · 1 line
2.45.2
Jiri Pirko
maintainerQuoted 26 lines · Wed, Oct 09, 2024 at 02:12:35PM CEST, [email protected] wrote:
The auto-generated uAPI file is currently included in both the .h and .c netlink stub files.
However, the .c file already includes its .h counterpart, thus leading to a double inclusion of the uAPI header.Prevent the double inclusion by including the uAPI header in the .h stub file only.
Signed-off-by Antonio Quartulli <[email protected]>---
drivers/dpll/dpll_nl.c | 2 -- drivers/net/team/team_nl.c | 2 -- fs/nfsd/netlink.c | 2 -- net/core/netdev-genl-gen.c | 1 - net/devlink/netlink_gen.c | 2 -- net/handshake/genl.c | 2 -- net/ipv4/fou_nl.c | 2 -- net/mptcp/mptcp_pm_gen.c | 2 -- tools/net/ynl/ynl-gen-c.py | 4 +++- 9 files changed, 3 insertions(+), 16 deletions(-)drivers/dpll/dpll_nl.c +0
-0
drivers/dpll/dpll_nl.c line 11
Quoted 4 lines
drivers/dpll/dpll_nl.c +0
-1@@ -8,8 +8,6 @@#include "dpll_nl.h" -#include <uapi/linux/dpll.h>
What seems to be the problem? The uapi headers are protected for double inclusion, no?
#ifndef _UAPI_LINUX_DPLL_H
#define _UAPI_LINUX_DPLL_H
Quoted 28 lines · Jiri Pirko
Quoted 27 lines · Wed, Oct 09, 2024 at 02:12:35PM CEST, [email protected] wrote:
The auto-generated uAPI file is currently included in both the .h and .c netlink stub files.
However, the .c file already includes its .h counterpart, thus leading to a double inclusion of the uAPI header.Prevent the double inclusion by including the uAPI header in the .h stub file only.
Signed-off-by Antonio Quartulli <[email protected]>---
drivers/dpll/dpll_nl.c | 2 -- drivers/net/team/team_nl.c | 2 -- fs/nfsd/netlink.c | 2 -- net/core/netdev-genl-gen.c | 1 - net/devlink/netlink_gen.c | 2 -- net/handshake/genl.c | 2 -- net/ipv4/fou_nl.c | 2 -- net/mptcp/mptcp_pm_gen.c | 2 -- tools/net/ynl/ynl-gen-c.py | 4 +++- 9 files changed, 3 insertions(+), 16 deletions(-)drivers/dpll/dpll_nl.c +0
-0@@ -8,8 +8,6 @@
Quoted 8 lines
drivers/dpll/dpll_nl.c line 11
Quoted 3 lines
drivers/dpll/dpll_nl.c +0
-1#include "dpll_nl.h" -#include <uapi/linux/dpll.h> What seems to be the problem? The uapi headers are protected for double inclusion, no?
#ifndef_UAPI_LINUX_DPLL_H
#define_UAPI_LINUX_DPLL_H
There is no problem to fix, this is just a compile-time micro-optimization by reducing the number of includes to follow.
I was recently told there is ongoing effort to reduce the amount of useless includes in order to speed up the compilation process.
I thought this was an easy fix in this direction :)
Regards,
Signature · 1 line
Antonio Quartulli
Jiri Pirko
maintainerQuoted 38 lines · Wed, Oct 09, 2024 at 03:00:42PM CEST, [email protected] wrote:
Quoted 28 lines · Jiri Pirko
Quoted 27 lines · Wed, Oct 09, 2024 at 02:12:35PM CEST, [email protected] wrote:
The auto-generated uAPI file is currently included in both the .h and .c netlink stub files.
However, the .c file already includes its .h counterpart, thus leading to a double inclusion of the uAPI header.Prevent the double inclusion by including the uAPI header in the .h stub file only.
Signed-off-by Antonio Quartulli <[email protected]>---
drivers/dpll/dpll_nl.c | 2 -- drivers/net/team/team_nl.c | 2 -- fs/nfsd/netlink.c | 2 -- net/core/netdev-genl-gen.c | 1 - net/devlink/netlink_gen.c | 2 -- net/handshake/genl.c | 2 -- net/ipv4/fou_nl.c | 2 -- net/mptcp/mptcp_pm_gen.c | 2 -- tools/net/ynl/ynl-gen-c.py | 4 +++- 9 files changed, 3 insertions(+), 16 deletions(-)drivers/dpll/dpll_nl.c +0
-0@@ -8,8 +8,6 @@Quoted 8 lines
drivers/dpll/dpll_nl.c line 11
Quoted 3 lines
drivers/dpll/dpll_nl.c +0
-1#include "dpll_nl.h" -#include <uapi/linux/dpll.h> What seems to be the problem? The uapi headers are protected for double inclusion, no?
#ifndef_UAPI_LINUX_DPLL_H
#define_UAPI_LINUX_DPLL_H
Quoted 5 lines
There is no problem to fix, this is just a compile-time micro-optimization by reducing the number of includes to follow.
I was recently told there is ongoing effort to reduce the amount of useless includes in order to speed up the compilation process.
Do you have some numbers?
So far I had impression that the common practise is to include header directly when needed and not to depend on indirect include.
Quoted 7 lines
I thought this was an easy fix in this direction :)
Regards,
Signature · 1 line
Antonio Quartulli
Quoted 42 lines · Jiri Pirko
Quoted 41 lines · Wed, Oct 09, 2024 at 03:00:42PM CEST, [email protected] wrote:
Quoted 28 lines · Jiri Pirko
Quoted 27 lines · Wed, Oct 09, 2024 at 02:12:35PM CEST, [email protected] wrote:
The auto-generated uAPI file is currently included in both the .h and .c netlink stub files.
However, the .c file already includes its .h counterpart, thus leading to a double inclusion of the uAPI header.Prevent the double inclusion by including the uAPI header in the .h stub file only.
Signed-off-by Antonio Quartulli <[email protected]>---
drivers/dpll/dpll_nl.c | 2 -- drivers/net/team/team_nl.c | 2 -- fs/nfsd/netlink.c | 2 -- net/core/netdev-genl-gen.c | 1 - net/devlink/netlink_gen.c | 2 -- net/handshake/genl.c | 2 -- net/ipv4/fou_nl.c | 2 -- net/mptcp/mptcp_pm_gen.c | 2 -- tools/net/ynl/ynl-gen-c.py | 4 +++- 9 files changed, 3 insertions(+), 16 deletions(-)drivers/dpll/dpll_nl.c +0
-0@@ -8,8 +8,6 @@Quoted 8 lines
drivers/dpll/dpll_nl.c line 11
Quoted 3 lines
drivers/dpll/dpll_nl.c +0
-1#include "dpll_nl.h" -#include <uapi/linux/dpll.h> What seems to be the problem? The uapi headers are protected for double inclusion, no?
#ifndef_UAPI_LINUX_DPLL_H
#define_UAPI_LINUX_DPLL_HThere is no problem to fix, this is just a compile-time micro-optimization by reducing the number of includes to follow.
Quoted 7 lines
Quoted 2 lines
I was recently told there is ongoing effort to reduce the amount of useless includes in order to speed up the compilation process.
Do you have some numbers?
So far I had impression that the common practise is to include header directly when needed and not to depend on indirect include.
That's the same rule I had been following in the past, but Andrew advised to do differently here:
He also says:
"There is a massive patch series crossing the entire kernel which significantly reduces the kernel build time by optimising includes."
I trusted his word and I just assumed this was the wanted direction nowadays.
@Andrew: maybe you have a pointer to the series?
Thanks.
Regards,
Signature · 1 line
Antonio Quartulli
Jakub Kicinski
maintainerQuoted 7 lines · On Wed, 9 Oct 2024 14:12:35 +0200 Antonio Quartulli wrote:
The auto-generated uAPI file is currently included in both the .h and .c netlink stub files.
However, the .c file already includes its .h counterpart, thus leading to a double inclusion of the uAPI header.Prevent the double inclusion by including the uAPI header in the .h stub file only.
FWIW I don't have a strong opinion either way.
Since both files are auto-generated there is no risk of getting it wrong. Then again the win is fairly minor if any.
But if we want to do this why only remove the uapi header? Netlink headers are also included twice.