diff mbox series

[v1,5/8] software node: Imply kobj_to_swnode() to be no-op

Message ID 20210327222012.54103-5-andriy.shevchenko@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [v1,1/8] software node: Free resources explicitly when swnode_register() fails | expand

Commit Message

Andy Shevchenko March 27, 2021, 10:20 p.m. UTC
Since we don't use structure field layout randomization
the manual shuffling can affect some macros, in particular
kobj_to_swnode(), which becomes a no-op when kobj member
is the first one in the struct swnode.

Bloat-o-meter statistics:

  add/remove: 0/0 grow/shrink: 2/10 up/down: 9/-100 (-91)
  Total: Before=7217, After=7126, chg -1.26%

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/swnode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Greg KH March 28, 2021, 8:43 a.m. UTC | #1
On Sun, Mar 28, 2021 at 12:20:09AM +0200, Andy Shevchenko wrote:
> Since we don't use structure field layout randomization
> the manual shuffling can affect some macros, in particular
> kobj_to_swnode(), which becomes a no-op when kobj member
> is the first one in the struct swnode.
> 
> Bloat-o-meter statistics:
> 
>   add/remove: 0/0 grow/shrink: 2/10 up/down: 9/-100 (-91)
>   Total: Before=7217, After=7126, chg -1.26%
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/base/swnode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
> index 22f81688af2c..ae53c48f84b1 100644
> --- a/drivers/base/swnode.c
> +++ b/drivers/base/swnode.c
> @@ -13,10 +13,10 @@
>  #include <linux/sysfs.h>
>  
>  struct swnode {
> -	int id;
>  	struct kobject kobj;
>  	struct fwnode_handle fwnode;
>  	const struct software_node *node;
> +	int id;

So you remove one math operation on a pointer and get a 1% size decrease
of the whole kernel?  Or just one file?

thanks,

greg k-h
Andy Shevchenko March 28, 2021, 12:50 p.m. UTC | #2
On Sun, Mar 28, 2021 at 11:47 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Sun, Mar 28, 2021 at 12:20:09AM +0200, Andy Shevchenko wrote:
> > Since we don't use structure field layout randomization
> > the manual shuffling can affect some macros, in particular
> > kobj_to_swnode(), which becomes a no-op when kobj member
> > is the first one in the struct swnode.
> >
> > Bloat-o-meter statistics:
> >
> >   add/remove: 0/0 grow/shrink: 2/10 up/down: 9/-100 (-91)
> >   Total: Before=7217, After=7126, chg -1.26%
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> >  drivers/base/swnode.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
> > index 22f81688af2c..ae53c48f84b1 100644
> > --- a/drivers/base/swnode.c
> > +++ b/drivers/base/swnode.c
> > @@ -13,10 +13,10 @@
> >  #include <linux/sysfs.h>
> >
> >  struct swnode {
> > -     int id;
> >       struct kobject kobj;
> >       struct fwnode_handle fwnode;
> >       const struct software_node *node;
> > +     int id;
>
> So you remove one math operation on a pointer and get a 1% size decrease
> of the whole kernel?  Or just one file?

One file, swnode.o. I'll clarify this in the commit message.
diff mbox series

Patch

diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index 22f81688af2c..ae53c48f84b1 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -13,10 +13,10 @@ 
 #include <linux/sysfs.h>
 
 struct swnode {
-	int id;
 	struct kobject kobj;
 	struct fwnode_handle fwnode;
 	const struct software_node *node;
+	int id;
 
 	/* properties in sysfs */
 	struct kobj_attribute *property_attrs;