diff mbox

[OPW,kernel] x86: mm: Remove runtime extable sort logic.

Message ID 20141020191820.GA23922@winterfell
State New, archived
Headers show

Commit Message

Iulia Manda Oct. 20, 2014, 7:18 p.m. UTC
This patch removes runtime extable sorting logic when
!CONFIG_BUILDTIME_EXTABLE_SORT and !CONFIG_MODULES.

The CONFIG_MODULES dependency is needed because if the kernel supports
loadable modules, it still needs to sort their exatbles at runtime.

Bloat-o-meter output:

add/remove: 0/2 grow/shrink: 0/2 up/down: 0/-179 (-179)
function                                     old     new   delta
cmp_ex                                         9       -      -9
sort_main_extable                             54      39     -15
load_module                                 7701    7685     -16
sort_extable                                 139       -    -139

Signed-off-by: Iulia Manda <iulia.manda21@gmail.com>
---
 arch/x86/mm/extable.c  |    2 ++
 include/linux/module.h |    7 +++++++
 2 files changed, 9 insertions(+)

Comments

Josh Triplett Oct. 20, 2014, 8:22 p.m. UTC | #1
Nice!

On Mon, Oct 20, 2014 at 10:18:20PM +0300, Iulia Manda wrote:
> This patch removes runtime extable sorting logic when
> !CONFIG_BUILDTIME_EXTABLE_SORT and !CONFIG_MODULES.

Wrong way around: the runtime logic is needed when
CONFIG_BUILDTIME_EXTABLE_SORT and !CONFIG_MODULES.  (The #if needs to
change accordingly.)

> The CONFIG_MODULES dependency is needed because if the kernel supports
> loadable modules, it still needs to sort their exatbles at runtime.

Typo: s/exatbles/extables/

> Bloat-o-meter output:
> 
> add/remove: 0/2 grow/shrink: 0/2 up/down: 0/-179 (-179)
> function                                     old     new   delta
> cmp_ex                                         9       -      -9
> sort_main_extable                             54      39     -15

You can compile out sort_main_extable as well.

Also, a bit more complex, but you could compile out
main_extable_sort_needed and change sortextable to stop looking for it
and changing it.  However, if you run into problems doing so, feel free
to skip that and we can add it as a separate tinification project.

> load_module                                 7701    7685     -16
> sort_extable                                 139       -    -139
> 
> Signed-off-by: Iulia Manda <iulia.manda21@gmail.com>
> ---
>  arch/x86/mm/extable.c  |    2 ++
>  include/linux/module.h |    7 +++++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
> index 903ec1e..701e353 100644
> --- a/arch/x86/mm/extable.c
> +++ b/arch/x86/mm/extable.c
> @@ -99,6 +99,7 @@ search_extable(const struct exception_table_entry *first,
>          return NULL;
>  }
>  
> +#if defined(CONFIG_BUILDTIME_EXTABLE_SORT) || defined(CONFIG_MODULES)
>  /*
>   * The exception table needs to be sorted so that the binary
>   * search that we use to find entries in it works properly.
> @@ -147,6 +148,7 @@ void sort_extable(struct exception_table_entry *start,
>  		i += 4;
>  	}
>  }
> +#endif
>  
>  #ifdef CONFIG_MODULES
>  /*
> diff --git a/include/linux/module.h b/include/linux/module.h
> index 71f282a..876cbb0 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -77,8 +77,15 @@ const struct exception_table_entry *
>  search_extable(const struct exception_table_entry *first,
>  	       const struct exception_table_entry *last,
>  	       unsigned long value);
> +#if defined(CONFIG_BUILDTIME_EXTABLE_SORT) || defined(CONFIG_MODULES)
>  void sort_extable(struct exception_table_entry *start,
>  		  struct exception_table_entry *finish);
> +#else
> +static inline void sort_extable(struct exception_table_entry *start,
> +		  struct exception_table_entry *finish)
> +{
> +}
> +#endif
>  void sort_main_extable(void);
>  void trim_init_extable(struct module *m);
>  
> -- 
> 1.7.10.4
Iulia Manda Oct. 20, 2014, 10:07 p.m. UTC | #2
Thanks for the tips. Working on it. :)

On 20 October 2014 23:22, Josh Triplett <josh@joshtriplett.org> wrote:

> Nice!
>
> On Mon, Oct 20, 2014 at 10:18:20PM +0300, Iulia Manda wrote:
> > This patch removes runtime extable sorting logic when
> > !CONFIG_BUILDTIME_EXTABLE_SORT and !CONFIG_MODULES.
>
> Wrong way around: the runtime logic is needed when
> CONFIG_BUILDTIME_EXTABLE_SORT and !CONFIG_MODULES.  (The #if needs to
> change accordingly.)
>
> > The CONFIG_MODULES dependency is needed because if the kernel supports
> > loadable modules, it still needs to sort their exatbles at runtime.
>
> Typo: s/exatbles/extables/
>
> > Bloat-o-meter output:
> >
> > add/remove: 0/2 grow/shrink: 0/2 up/down: 0/-179 (-179)
> > function                                     old     new   delta
> > cmp_ex                                         9       -      -9
> > sort_main_extable                             54      39     -15
>
> You can compile out sort_main_extable as well.
>
> Also, a bit more complex, but you could compile out
> main_extable_sort_needed and change sortextable to stop looking for it
> and changing it.  However, if you run into problems doing so, feel free
> to skip that and we can add it as a separate tinification project.
>
> > load_module                                 7701    7685     -16
> > sort_extable                                 139       -    -139
> >
> > Signed-off-by: Iulia Manda <iulia.manda21@gmail.com>
> > ---
> >  arch/x86/mm/extable.c  |    2 ++
> >  include/linux/module.h |    7 +++++++
> >  2 files changed, 9 insertions(+)
> >
> > diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
> > index 903ec1e..701e353 100644
> > --- a/arch/x86/mm/extable.c
> > +++ b/arch/x86/mm/extable.c
> > @@ -99,6 +99,7 @@ search_extable(const struct exception_table_entry
> *first,
> >          return NULL;
> >  }
> >
> > +#if defined(CONFIG_BUILDTIME_EXTABLE_SORT) || defined(CONFIG_MODULES)
> >  /*
> >   * The exception table needs to be sorted so that the binary
> >   * search that we use to find entries in it works properly.
> > @@ -147,6 +148,7 @@ void sort_extable(struct exception_table_entry
> *start,
> >               i += 4;
> >       }
> >  }
> > +#endif
> >
> >  #ifdef CONFIG_MODULES
> >  /*
> > diff --git a/include/linux/module.h b/include/linux/module.h
> > index 71f282a..876cbb0 100644
> > --- a/include/linux/module.h
> > +++ b/include/linux/module.h
> > @@ -77,8 +77,15 @@ const struct exception_table_entry *
> >  search_extable(const struct exception_table_entry *first,
> >              const struct exception_table_entry *last,
> >              unsigned long value);
> > +#if defined(CONFIG_BUILDTIME_EXTABLE_SORT) || defined(CONFIG_MODULES)
> >  void sort_extable(struct exception_table_entry *start,
> >                 struct exception_table_entry *finish);
> > +#else
> > +static inline void sort_extable(struct exception_table_entry *start,
> > +               struct exception_table_entry *finish)
> > +{
> > +}
> > +#endif
> >  void sort_main_extable(void);
> >  void trim_init_extable(struct module *m);
> >
> > --
> > 1.7.10.4
>
diff mbox

Patch

diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
index 903ec1e..701e353 100644
--- a/arch/x86/mm/extable.c
+++ b/arch/x86/mm/extable.c
@@ -99,6 +99,7 @@  search_extable(const struct exception_table_entry *first,
         return NULL;
 }
 
+#if defined(CONFIG_BUILDTIME_EXTABLE_SORT) || defined(CONFIG_MODULES)
 /*
  * The exception table needs to be sorted so that the binary
  * search that we use to find entries in it works properly.
@@ -147,6 +148,7 @@  void sort_extable(struct exception_table_entry *start,
 		i += 4;
 	}
 }
+#endif
 
 #ifdef CONFIG_MODULES
 /*
diff --git a/include/linux/module.h b/include/linux/module.h
index 71f282a..876cbb0 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -77,8 +77,15 @@  const struct exception_table_entry *
 search_extable(const struct exception_table_entry *first,
 	       const struct exception_table_entry *last,
 	       unsigned long value);
+#if defined(CONFIG_BUILDTIME_EXTABLE_SORT) || defined(CONFIG_MODULES)
 void sort_extable(struct exception_table_entry *start,
 		  struct exception_table_entry *finish);
+#else
+static inline void sort_extable(struct exception_table_entry *start,
+		  struct exception_table_entry *finish)
+{
+}
+#endif
 void sort_main_extable(void);
 void trim_init_extable(struct module *m);