* Re: [PATCH] netlink: NL_SET_ERR_MSG - remove local static array
@ 2021-08-10 20:21 kernel test robot
0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-08-10 20:21 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 16585 bytes --]
CC: clang-built-linux(a)googlegroups.com
CC: kbuild-all(a)lists.01.org
In-Reply-To: <1f99c69f4e640accaf7459065e6625e73ec0f8d4.camel@perches.com>
References: <1f99c69f4e640accaf7459065e6625e73ec0f8d4.camel@perches.com>
TO: Joe Perches <joe@perches.com>
TO: netdev <netdev@vger.kernel.org>
CC: Johannes Berg <johannes.berg@intel.com>
CC: Jonathan Toppins <jtoppins@redhat.com>
CC: LKML <linux-kernel@vger.kernel.org>
Hi Joe,
I love your patch! Perhaps something to improve:
[auto build test WARNING on net/master]
[also build test WARNING on ipvs/master net-next/master linus/master v5.14-rc5 next-20210810]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Joe-Perches/netlink-NL_SET_ERR_MSG-remove-local-static-array/20210810-010640
base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git d09c548dbf3b31cb07bba562e0f452edfa01efe3
:::::: branch date: 27 hours ago
:::::: commit date: 27 hours ago
config: x86_64-randconfig-c001-20210810 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 614c7d03877fd99c2de47429b15be3f00306a3bd)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/ba790669ccffc4fb335a699190b2d141f0681910
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Joe-Perches/netlink-NL_SET_ERR_MSG-remove-local-static-array/20210810-010640
git checkout ba790669ccffc4fb335a699190b2d141f0681910
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
^
include/linux/rcupdate.h:528:31: note: expanded from macro 'rcu_dereference_check'
__rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
^
net/ipv6/route.c:3067:2: note: Assuming the condition is false
for_each_fib6_node_rt_rcu(fn) {
^
include/net/ip6_fib.h:233:12: note: expanded from macro 'for_each_fib6_node_rt_rcu'
for (rt = rcu_dereference((fn)->leaf); rt; \
^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:596:28: note: expanded from macro 'rcu_dereference'
#define rcu_dereference(p) rcu_dereference_check(p, 0)
^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:528:2: note: expanded from macro 'rcu_dereference_check'
__rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:390:19: note: expanded from macro '__rcu_dereference_check'
RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_check() usage"); \
~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rcupdate.h:318:8: note: expanded from macro 'RCU_LOCKDEP_WARN'
if ((c) && debug_lockdep_rcu_enabled() && !__warned) { \
^
net/ipv6/route.c:3067:2: note: Left side of '&&' is false
for_each_fib6_node_rt_rcu(fn) {
^
include/net/ip6_fib.h:233:12: note: expanded from macro 'for_each_fib6_node_rt_rcu'
for (rt = rcu_dereference((fn)->leaf); rt; \
^
include/linux/rcupdate.h:596:28: note: expanded from macro 'rcu_dereference'
#define rcu_dereference(p) rcu_dereference_check(p, 0)
^
include/linux/rcupdate.h:528:2: note: expanded from macro 'rcu_dereference_check'
__rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
^
include/linux/rcupdate.h:390:2: note: expanded from macro '__rcu_dereference_check'
RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_check() usage"); \
^
include/linux/rcupdate.h:318:11: note: expanded from macro 'RCU_LOCKDEP_WARN'
if ((c) && debug_lockdep_rcu_enabled() && !__warned) { \
^
net/ipv6/route.c:3067:2: note: Loop condition is false. Exiting loop
for_each_fib6_node_rt_rcu(fn) {
^
include/net/ip6_fib.h:233:12: note: expanded from macro 'for_each_fib6_node_rt_rcu'
for (rt = rcu_dereference((fn)->leaf); rt; \
^
include/linux/rcupdate.h:596:28: note: expanded from macro 'rcu_dereference'
#define rcu_dereference(p) rcu_dereference_check(p, 0)
^
include/linux/rcupdate.h:528:2: note: expanded from macro 'rcu_dereference_check'
__rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
^
include/linux/rcupdate.h:390:2: note: expanded from macro '__rcu_dereference_check'
RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_check() usage"); \
^
include/linux/rcupdate.h:316:2: note: expanded from macro 'RCU_LOCKDEP_WARN'
do { \
^
net/ipv6/route.c:3067:2: note: Loop condition is true. Entering loop body
for_each_fib6_node_rt_rcu(fn) {
^
include/net/ip6_fib.h:233:2: note: expanded from macro 'for_each_fib6_node_rt_rcu'
for (rt = rcu_dereference((fn)->leaf); rt; \
^
net/ipv6/route.c:3069:3: note: Taking false branch
if (fib6_check_expired(rt))
^
net/ipv6/route.c:3071:7: note: Assuming the condition is true
if (rt->fib6_flags & RTF_REJECT)
^~~~~~~~~~~~~~~~~~~~~~~~~~~
net/ipv6/route.c:3071:3: note: Taking true branch
if (rt->fib6_flags & RTF_REJECT)
^
net/ipv6/route.c:3072:4: note: Execution continues on line 3089
break;
^
net/ipv6/route.c:3089:7: note: 'rt' is non-null
if (!rt)
^~
net/ipv6/route.c:3089:2: note: Taking false branch
if (!rt)
^
net/ipv6/route.c:3091:7: note: Taking true branch
else if (rt->fib6_flags & RTF_REJECT) {
^
net/ipv6/route.c:3093:3: note: Control jumps to line 3105
goto out;
^
net/ipv6/route.c:3105:6: note: Assuming 'ret' is null
if (ret) {
^~~
net/ipv6/route.c:3105:2: note: Taking false branch
if (ret) {
^
net/ipv6/route.c:3110:9: note: Calling 'ip6_create_rt_rcu'
ret = ip6_create_rt_rcu(&res);
^~~~~~~~~~~~~~~~~~~~~~~
net/ipv6/route.c:1174:27: note: Dereference of null pointer
struct net_device *dev = res->nh->fib_nh_dev;
^~~~~~~~~~~~~~~~~~~
>> net/ipv6/route.c:3431:9: warning: Dereference of null pointer (loaded from variable '_dev') [clang-analyzer-core.NullDereference]
*_dev = dev = res.nh->fib_nh_dev;
~~~~ ^
net/ipv6/route.c:3391:27: note: Assuming '_dev' is null
struct net_device *dev = _dev ? *_dev : NULL;
^~~~
net/ipv6/route.c:3391:27: note: '?' condition is false
net/ipv6/route.c:3396:6: note: Assuming field 'fc_table' is 0
if (cfg->fc_table) {
^~~~~~~~~~~~~
net/ipv6/route.c:3396:2: note: Taking false branch
if (cfg->fc_table) {
^
net/ipv6/route.c:3408:6: note: 'err' is < 0
if (err < 0) {
^~~
net/ipv6/route.c:3408:2: note: Taking true branch
if (err < 0) {
^
net/ipv6/route.c:3415:7: note: Assuming 'err' is 0
if (err || res.fib6_flags & RTF_REJECT ||
^~~
net/ipv6/route.c:3415:7: note: Left side of '||' is false
net/ipv6/route.c:3415:14: note: Assuming the condition is false
if (err || res.fib6_flags & RTF_REJECT ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~
net/ipv6/route.c:3415:7: note: Left side of '||' is false
if (err || res.fib6_flags & RTF_REJECT ||
^
net/ipv6/route.c:3416:7: note: Assuming field 'nhc_gw_family' is 0
res.nh->fib_nh_gw_family)
^~~~~~~~~~~~~~~~~~~~~~~~
net/ipv6/route.c:3415:3: note: Taking false branch
if (err || res.fib6_flags & RTF_REJECT ||
^
net/ipv6/route.c:3419:7: note: 'err' is 0
if (err)
^~~
net/ipv6/route.c:3419:3: note: Taking false branch
if (err)
^
net/ipv6/route.c:3423:6: note: Assuming field 'fc_ifindex' is equal to 0
cfg->fc_ifindex != 0, NULL, flags);
^~~~~~~~~~~~~~~~~~~~
net/ipv6/route.c:3427:6: note: 'dev' is null
if (dev) {
^~~
net/ipv6/route.c:3427:2: note: Taking false branch
if (dev) {
^
net/ipv6/route.c:3431:9: note: Dereference of null pointer (loaded from variable '_dev')
*_dev = dev = res.nh->fib_nh_dev;
~~~~ ^
net/ipv6/route.c:3638:24: warning: Access to field 'ifindex' results in a dereference of a null pointer (loaded from variable 'dev') [clang-analyzer-core.NullDereference]
fib6_nh->fib_nh_oif = dev->ifindex;
^
net/ipv6/route.c:5470:8: note: Calling 'rtm_to_fib6_config'
err = rtm_to_fib6_config(skb, nlh, &cfg, extack);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
net/ipv6/route.c:5009:6: note: Assuming 'err' is >= 0
if (err < 0)
^~~~~~~
net/ipv6/route.c:5009:2: note: Taking false branch
if (err < 0)
^
net/ipv6/route.c:5028:6: note: Assuming field 'rtm_type' is not equal to RTN_UNREACHABLE
if (rtm->rtm_type == RTN_UNREACHABLE ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
net/ipv6/route.c:5028:6: note: Left side of '||' is false
net/ipv6/route.c:5029:6: note: Assuming field 'rtm_type' is not equal to RTN_BLACKHOLE
rtm->rtm_type == RTN_BLACKHOLE ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
net/ipv6/route.c:5028:6: note: Left side of '||' is false
if (rtm->rtm_type == RTN_UNREACHABLE ||
^
net/ipv6/route.c:5030:6: note: Assuming field 'rtm_type' is not equal to RTN_PROHIBIT
rtm->rtm_type == RTN_PROHIBIT ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
net/ipv6/route.c:5028:6: note: Left side of '||' is false
if (rtm->rtm_type == RTN_UNREACHABLE ||
^
net/ipv6/route.c:5031:6: note: Assuming field 'rtm_type' is not equal to RTN_THROW
rtm->rtm_type == RTN_THROW)
^~~~~~~~~~~~~~~~~~~~~~~~~~
net/ipv6/route.c:5028:2: note: Taking false branch
if (rtm->rtm_type == RTN_UNREACHABLE ||
^
net/ipv6/route.c:5034:6: note: Assuming field 'rtm_type' is not equal to RTN_LOCAL
if (rtm->rtm_type == RTN_LOCAL)
^~~~~~~~~~~~~~~~~~~~~~~~~~
net/ipv6/route.c:5034:2: note: Taking false branch
if (rtm->rtm_type == RTN_LOCAL)
^
net/ipv6/route.c:5037:6: note: Assuming the condition is false
if (rtm->rtm_flags & RTM_F_CLONED)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
net/ipv6/route.c:5037:2: note: Taking false branch
if (rtm->rtm_flags & RTM_F_CLONED)
^
net/ipv6/route.c:5042:6: note: Assuming the condition is false
if (tb[RTA_NH_ID]) {
vim +/_dev +3431 net/ipv6/route.c
fc1e64e1092f62 David Ahern 2018-01-25 3384
1edce99fa8d611 David Ahern 2018-01-25 3385 static int ip6_route_check_nh(struct net *net,
1edce99fa8d611 David Ahern 2018-01-25 3386 struct fib6_config *cfg,
1edce99fa8d611 David Ahern 2018-01-25 3387 struct net_device **_dev,
1edce99fa8d611 David Ahern 2018-01-25 3388 struct inet6_dev **idev)
1edce99fa8d611 David Ahern 2018-01-25 3389 {
1edce99fa8d611 David Ahern 2018-01-25 3390 const struct in6_addr *gw_addr = &cfg->fc_gateway;
1edce99fa8d611 David Ahern 2018-01-25 3391 struct net_device *dev = _dev ? *_dev : NULL;
b2c709cce6826b David Ahern 2019-06-24 3392 int flags = RT6_LOOKUP_F_IFACE;
b2c709cce6826b David Ahern 2019-06-24 3393 struct fib6_result res = {};
1edce99fa8d611 David Ahern 2018-01-25 3394 int err = -EHOSTUNREACH;
1edce99fa8d611 David Ahern 2018-01-25 3395
1edce99fa8d611 David Ahern 2018-01-25 3396 if (cfg->fc_table) {
b2c709cce6826b David Ahern 2019-06-24 3397 err = ip6_nh_lookup_table(net, cfg, gw_addr,
b2c709cce6826b David Ahern 2019-06-24 3398 cfg->fc_table, flags, &res);
b2c709cce6826b David Ahern 2019-06-24 3399 /* gw_addr can not require a gateway or resolve to a reject
b2c709cce6826b David Ahern 2019-06-24 3400 * route. If a device is given, it must match the result.
b2c709cce6826b David Ahern 2019-06-24 3401 */
b2c709cce6826b David Ahern 2019-06-24 3402 if (err || res.fib6_flags & RTF_REJECT ||
b2c709cce6826b David Ahern 2019-06-24 3403 res.nh->fib_nh_gw_family ||
b2c709cce6826b David Ahern 2019-06-24 3404 (dev && dev != res.nh->fib_nh_dev))
b2c709cce6826b David Ahern 2019-06-24 3405 err = -EHOSTUNREACH;
1edce99fa8d611 David Ahern 2018-01-25 3406 }
1edce99fa8d611 David Ahern 2018-01-25 3407
b2c709cce6826b David Ahern 2019-06-24 3408 if (err < 0) {
b2c709cce6826b David Ahern 2019-06-24 3409 struct flowi6 fl6 = {
b2c709cce6826b David Ahern 2019-06-24 3410 .flowi6_oif = cfg->fc_ifindex,
b2c709cce6826b David Ahern 2019-06-24 3411 .daddr = *gw_addr,
b2c709cce6826b David Ahern 2019-06-24 3412 };
1edce99fa8d611 David Ahern 2018-01-25 3413
b2c709cce6826b David Ahern 2019-06-24 3414 err = fib6_lookup(net, cfg->fc_ifindex, &fl6, &res, flags);
b2c709cce6826b David Ahern 2019-06-24 3415 if (err || res.fib6_flags & RTF_REJECT ||
b2c709cce6826b David Ahern 2019-06-24 3416 res.nh->fib_nh_gw_family)
b2c709cce6826b David Ahern 2019-06-24 3417 err = -EHOSTUNREACH;
1edce99fa8d611 David Ahern 2018-01-25 3418
b2c709cce6826b David Ahern 2019-06-24 3419 if (err)
b2c709cce6826b David Ahern 2019-06-24 3420 return err;
b2c709cce6826b David Ahern 2019-06-24 3421
b2c709cce6826b David Ahern 2019-06-24 3422 fib6_select_path(net, &res, &fl6, cfg->fc_ifindex,
b2c709cce6826b David Ahern 2019-06-24 3423 cfg->fc_ifindex != 0, NULL, flags);
1edce99fa8d611 David Ahern 2018-01-25 3424 }
b2c709cce6826b David Ahern 2019-06-24 3425
b2c709cce6826b David Ahern 2019-06-24 3426 err = 0;
b2c709cce6826b David Ahern 2019-06-24 3427 if (dev) {
b2c709cce6826b David Ahern 2019-06-24 3428 if (dev != res.nh->fib_nh_dev)
b2c709cce6826b David Ahern 2019-06-24 3429 err = -EHOSTUNREACH;
1edce99fa8d611 David Ahern 2018-01-25 3430 } else {
b2c709cce6826b David Ahern 2019-06-24 @3431 *_dev = dev = res.nh->fib_nh_dev;
1edce99fa8d611 David Ahern 2018-01-25 3432 dev_hold(dev);
b2c709cce6826b David Ahern 2019-06-24 3433 *idev = in6_dev_get(dev);
1edce99fa8d611 David Ahern 2018-01-25 3434 }
1edce99fa8d611 David Ahern 2018-01-25 3435
1edce99fa8d611 David Ahern 2018-01-25 3436 return err;
1edce99fa8d611 David Ahern 2018-01-25 3437 }
1edce99fa8d611 David Ahern 2018-01-25 3438
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 36336 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] netlink: NL_SET_ERR_MSG - remove local static array
2021-08-10 20:30 ` Jakub Kicinski
@ 2021-08-11 4:07 ` Joe Perches
0 siblings, 0 replies; 5+ messages in thread
From: Joe Perches @ 2021-08-11 4:07 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: netdev, Johannes Berg, Jonathan Toppins, LKML
On Tue, 2021-08-10 at 13:30 -0700, Jakub Kicinski wrote:
> On Mon, 09 Aug 2021 10:04:00 -0700 Joe Perches wrote:
> > The want was to have some separate object section for netlink messages
> > so all netlink messages could be specifically listed by some tool but
> > the effect is duplicating static const char arrays in the object code.
> >
> > It seems unused presently so change the macro to avoid the local static
> > declarations until such time as these actually are wanted and used.
> >
> > This reduces object size ~8KB in an x86-64 defconfig without modules.
[]
> > diff --git a/include/linux/netlink.h b/include/linux/netlink.h
[]
> > @@ -89,13 +89,12 @@ struct netlink_ext_ack {
> > * to the lack of an output buffer.)
> > */
> > #define NL_SET_ERR_MSG(extack, msg) do { \
> > - static const char __msg[] = msg; \
> > struct netlink_ext_ack *__extack = (extack); \
> > \
> > - do_trace_netlink_extack(__msg); \
> > + do_trace_netlink_extack(msg); \
> > \
> > if (__extack) \
> > - __extack->_msg = __msg; \
> > + __extack->_msg = msg; \
> > } while (0)
>
> But you've made us evaluate msg multiple times now.
> Given extack is carefully evaluated only once this stands out.
msg is always a const char array so no evaluation is done.
It's just a pointer.
In fact, this could either become a static inline or a
simple function call to reduce object size even further.
For instance:
$ size vmlinux.o.nl_func.*
text data bss dec hex filename
19974564 3457991 741312 24173867 170dd2b vmlinux.o.nl_func.new
19992097 3457967 741312 24191376 1712190 vmlinux.o.nl_func.old
---
include/linux/netlink.h | 29 ++++++++++-------------------
net/netlink/af_netlink.c | 13 +++++++++++++
2 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 61b1c7fcc401e..fe80c2704cc23 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -82,21 +82,16 @@ struct netlink_ext_ack {
u8 cookie_len;
};
+void netlink_set_err_msg(struct netlink_ext_ack *extack, const char *msg);
/* Always use this macro, this allows later putting the
* message into a separate section or such for things
* like translation or listing all possible messages.
* Currently string formatting is not supported (due
* to the lack of an output buffer.)
*/
-#define NL_SET_ERR_MSG(extack, msg) do { \
- static const char __msg[] = msg; \
- struct netlink_ext_ack *__extack = (extack); \
- \
- do_trace_netlink_extack(__msg); \
- \
- if (__extack) \
- __extack->_msg = __msg; \
-} while (0)
+
+#define NL_SET_ERR_MSG(extack, msg) \
+ netlink_set_err_msg(extack, msg)
#define NL_SET_ERR_MSG_MOD(extack, msg) \
NL_SET_ERR_MSG((extack), KBUILD_MODNAME ": " msg)
@@ -110,16 +105,12 @@ struct netlink_ext_ack {
#define NL_SET_BAD_ATTR(extack, attr) NL_SET_BAD_ATTR_POLICY(extack, attr, NULL)
-#define NL_SET_ERR_MSG_ATTR_POL(extack, attr, pol, msg) do { \
- static const char __msg[] = msg; \
- struct netlink_ext_ack *__extack = (extack); \
- \
- do_trace_netlink_extack(__msg); \
- \
- if (__extack) { \
- __extack->_msg = __msg; \
- __extack->bad_attr = (attr); \
- __extack->policy = (pol); \
+#define NL_SET_ERR_MSG_ATTR_POL(extack, attr, pol, msg) \
+do { \
+ netlink_set_err_msg(extack, msg); \
+ if (extack) { \
+ extack->bad_attr = (attr); \
+ extack->policy = (pol); \
} \
} while (0)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 24b7cf447bc55..b6d035f0d343b 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2561,6 +2561,19 @@ int nlmsg_notify(struct sock *sk, struct sk_buff *skb, u32 portid,
}
EXPORT_SYMBOL(nlmsg_notify);
+/**
+ * nl_set_err_msg -
+ */
+
+void netlink_set_err_msg(struct netlink_ext_ack *extack, const char *msg)
+{
+ do_trace_netlink_extack(msg);
+
+ if (extack)
+ extack->_msg = msg;
+}
+EXPORT_SYMBOL(netlink_set_err_msg);
+
#ifdef CONFIG_PROC_FS
struct nl_seq_iter {
struct seq_net_private p;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] netlink: NL_SET_ERR_MSG - remove local static array
2021-08-09 17:04 Joe Perches
2021-08-09 22:30 ` Jonathan Toppins
@ 2021-08-10 20:30 ` Jakub Kicinski
2021-08-11 4:07 ` Joe Perches
1 sibling, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2021-08-10 20:30 UTC (permalink / raw)
To: Joe Perches; +Cc: netdev, Johannes Berg, Jonathan Toppins, LKML
On Mon, 09 Aug 2021 10:04:00 -0700 Joe Perches wrote:
> The want was to have some separate object section for netlink messages
> so all netlink messages could be specifically listed by some tool but
> the effect is duplicating static const char arrays in the object code.
>
> It seems unused presently so change the macro to avoid the local static
> declarations until such time as these actually are wanted and used.
>
> This reduces object size ~8KB in an x86-64 defconfig without modules.
>
> $ size vmlinux.o*
> text data bss dec hex filename
> 20110471 3460344 741760 24312575 172faff vmlinux.o.new
> 20119444 3460344 741760 24321548 1731e0c vmlinux.o.old
>
> Signed-off-by: Joe Perches <joe@perches.com>
I guess we can bring it back when it's needed.
> diff --git a/include/linux/netlink.h b/include/linux/netlink.h
> index 61b1c7fcc401e..4bb32ae134aa8 100644
> --- a/include/linux/netlink.h
> +++ b/include/linux/netlink.h
> @@ -89,13 +89,12 @@ struct netlink_ext_ack {
> * to the lack of an output buffer.)
> */
> #define NL_SET_ERR_MSG(extack, msg) do { \
> - static const char __msg[] = msg; \
> struct netlink_ext_ack *__extack = (extack); \
> \
> - do_trace_netlink_extack(__msg); \
> + do_trace_netlink_extack(msg); \
> \
> if (__extack) \
> - __extack->_msg = __msg; \
> + __extack->_msg = msg; \
> } while (0)
But you've made us evaluate msg multiple times now.
Given extack is carefully evaluated only once this stands out.
> #define NL_SET_ERR_MSG_MOD(extack, msg) \
> @@ -111,13 +110,12 @@ struct netlink_ext_ack {
> #define NL_SET_BAD_ATTR(extack, attr) NL_SET_BAD_ATTR_POLICY(extack, attr, NULL)
>
> #define NL_SET_ERR_MSG_ATTR_POL(extack, attr, pol, msg) do { \
> - static const char __msg[] = msg; \
> struct netlink_ext_ack *__extack = (extack); \
> \
> - do_trace_netlink_extack(__msg); \
> + do_trace_netlink_extack(msg); \
> \
> if (__extack) { \
> - __extack->_msg = __msg; \
> + __extack->_msg = msg; \
> __extack->bad_attr = (attr); \
> __extack->policy = (pol); \
Same here.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] netlink: NL_SET_ERR_MSG - remove local static array
2021-08-09 17:04 Joe Perches
@ 2021-08-09 22:30 ` Jonathan Toppins
2021-08-10 20:30 ` Jakub Kicinski
1 sibling, 0 replies; 5+ messages in thread
From: Jonathan Toppins @ 2021-08-09 22:30 UTC (permalink / raw)
To: Joe Perches, netdev; +Cc: Johannes Berg, LKML
On 8/9/21 1:04 PM, Joe Perches wrote:
> The want was to have some separate object section for netlink messages
> so all netlink messages could be specifically listed by some tool but
> the effect is duplicating static const char arrays in the object code.
>
> It seems unused presently so change the macro to avoid the local static
> declarations until such time as these actually are wanted and used.
>
> This reduces object size ~8KB in an x86-64 defconfig without modules.
>
> $ size vmlinux.o*
> text data bss dec hex filename
> 20110471 3460344 741760 24312575 172faff vmlinux.o.new
> 20119444 3460344 741760 24321548 1731e0c vmlinux.o.old
>
> Signed-off-by: Joe Perches <joe@perches.com>
Seems reasonable.
Acked-by: Jonathan Toppins <jtoppins@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] netlink: NL_SET_ERR_MSG - remove local static array
@ 2021-08-09 17:04 Joe Perches
2021-08-09 22:30 ` Jonathan Toppins
2021-08-10 20:30 ` Jakub Kicinski
0 siblings, 2 replies; 5+ messages in thread
From: Joe Perches @ 2021-08-09 17:04 UTC (permalink / raw)
To: netdev; +Cc: Johannes Berg, Jonathan Toppins, LKML
The want was to have some separate object section for netlink messages
so all netlink messages could be specifically listed by some tool but
the effect is duplicating static const char arrays in the object code.
It seems unused presently so change the macro to avoid the local static
declarations until such time as these actually are wanted and used.
This reduces object size ~8KB in an x86-64 defconfig without modules.
$ size vmlinux.o*
text data bss dec hex filename
20110471 3460344 741760 24312575 172faff vmlinux.o.new
20119444 3460344 741760 24321548 1731e0c vmlinux.o.old
Signed-off-by: Joe Perches <joe@perches.com>
---
include/linux/netlink.h | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 61b1c7fcc401e..4bb32ae134aa8 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -89,13 +89,12 @@ struct netlink_ext_ack {
* to the lack of an output buffer.)
*/
#define NL_SET_ERR_MSG(extack, msg) do { \
- static const char __msg[] = msg; \
struct netlink_ext_ack *__extack = (extack); \
\
- do_trace_netlink_extack(__msg); \
+ do_trace_netlink_extack(msg); \
\
if (__extack) \
- __extack->_msg = __msg; \
+ __extack->_msg = msg; \
} while (0)
#define NL_SET_ERR_MSG_MOD(extack, msg) \
@@ -111,13 +110,12 @@ struct netlink_ext_ack {
#define NL_SET_BAD_ATTR(extack, attr) NL_SET_BAD_ATTR_POLICY(extack, attr, NULL)
#define NL_SET_ERR_MSG_ATTR_POL(extack, attr, pol, msg) do { \
- static const char __msg[] = msg; \
struct netlink_ext_ack *__extack = (extack); \
\
- do_trace_netlink_extack(__msg); \
+ do_trace_netlink_extack(msg); \
\
if (__extack) { \
- __extack->_msg = __msg; \
+ __extack->_msg = msg; \
__extack->bad_attr = (attr); \
__extack->policy = (pol); \
} \
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-08-11 4:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-10 20:21 [PATCH] netlink: NL_SET_ERR_MSG - remove local static array kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2021-08-09 17:04 Joe Perches
2021-08-09 22:30 ` Jonathan Toppins
2021-08-10 20:30 ` Jakub Kicinski
2021-08-11 4:07 ` Joe Perches
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.