linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ext2: Reduce object size when !CONFIG_PRINTK
@ 2013-06-18 17:14 Joe Perches
  2013-06-18 17:14 ` [PATCH 2/2] ext3: " Joe Perches
  2013-06-21 16:50 ` [PATCH 1/2] ext2: " Jan Kara
  0 siblings, 2 replies; 4+ messages in thread
From: Joe Perches @ 2013-06-18 17:14 UTC (permalink / raw)
  To: linux-ext4; +Cc: Theodore Ts'o, Jan Kara, linux-kernel

Reducing the object size ~5kb/15% could be useful for embedded
systems.

Add #ifdef CONFIG_PRINTK #else #endif blocks
to hold formats and arguments, passing " " to
functions when !CONFIG_PRINTK and still verifying
format and arguments with no_printk.

 $ size fs/ext2/built-in.o*
    text   data	    bss	    dec	    hex	filename
   31297     44	      4	  31345	   7a71	fs/ext2/built-in.o.ext2.new
   36288     44	      4	  36336	   8df0	fs/ext2/built-in.o.ext2.old

 $ grep -E "CONFIG_EXT2|CONFIG_PRINTK" .config
 # CONFIG_PRINTK is not set
 CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
 # CONFIG_EXT2_FS_XIP is not set

Signed-off-by: Joe Perches <joe@perches.com>
---
 fs/ext2/ext2.h  | 22 ++++++++++++++++++++--
 fs/ext2/super.c |  6 +++---
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index d9a17d0..888ae31 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -767,12 +767,30 @@ struct dentry *ext2_get_parent(struct dentry *child);
 
 /* super.c */
 extern __printf(3, 4)
-void ext2_error(struct super_block *, const char *, const char *, ...);
+void __ext2_error(struct super_block *, const char *, const char *, ...);
 extern __printf(3, 4)
-void ext2_msg(struct super_block *, const char *, const char *, ...);
+void __ext2_msg(struct super_block *, const char *, const char *, ...);
 extern void ext2_update_dynamic_rev (struct super_block *sb);
 extern void ext2_write_super (struct super_block *);
 
+#ifdef CONFIG_PRINTK
+#define ext2_error(sb, func, fmt, ...)					\
+	__ext2_error(sb, func, fmt, ##__VA_ARGS__)
+#define ext2_msg(sb, prefix, fmt, ...)					\
+	__ext2_msg(sb, prefix, fmt, ##__VA_ARGS__)
+#else
+#define ext2_error(sb, func, fmt, ...)					\
+do {									\
+	no_printk(fmt, ##__VA_ARGS__);					\
+	__ext2_error(sb, func, " ");					\
+} while (0)
+#define ext2_msg(sb, prefix, fmt, ...)					\
+do {									\
+	no_printk(fmt, ##__VA_ARGS__);					\
+	__ext2_msg(sb, prefix, " ");					\
+} while (0)
+#endif
+
 /*
  * Inodes and files operations
  */
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 2885349..61ffb3f 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -45,8 +45,8 @@ static int ext2_sync_fs(struct super_block *sb, int wait);
 static int ext2_freeze(struct super_block *sb);
 static int ext2_unfreeze(struct super_block *sb);
 
-void ext2_error(struct super_block *sb, const char *function,
-		const char *fmt, ...)
+void __ext2_error(struct super_block *sb, const char *function,
+		  const char *fmt, ...)
 {
 	struct va_format vaf;
 	va_list args;
@@ -80,7 +80,7 @@ void ext2_error(struct super_block *sb, const char *function,
 	}
 }
 
-void ext2_msg(struct super_block *sb, const char *prefix,
+void __ext2_msg(struct super_block *sb, const char *prefix,
 		const char *fmt, ...)
 {
 	struct va_format vaf;
-- 
1.8.1.2.459.gbcd45b4.dirty

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] ext3: Reduce object size when !CONFIG_PRINTK
  2013-06-18 17:14 [PATCH 1/2] ext2: Reduce object size when !CONFIG_PRINTK Joe Perches
@ 2013-06-18 17:14 ` Joe Perches
  2013-06-21 16:50 ` [PATCH 1/2] ext2: " Jan Kara
  1 sibling, 0 replies; 4+ messages in thread
From: Joe Perches @ 2013-06-18 17:14 UTC (permalink / raw)
  To: linux-ext4
  Cc: Theodore Ts'o, Jan Kara, Andrew Morton, Andreas Dilger,
	linux-kernel

Reducing the object size ~11kb/12% could be useful for embedded
systems.

Add #ifdef CONFIG_PRINTK #else #endif blocks
to hold formats and arguments, passing " " to
functions when !CONFIG_PRINTK and still verifying
format and arguments with no_printk.

 $ size fs/ext3/built-in.o*
    text   data	    bss	    dec	    hex	filename
   79857     51	      8	  79916	  1382c	fs/ext3/built-in.o.new
   90958     51	      8	  91017	  16389	fs/ext3/built-in.o.old

 $ grep -E "CONFIG_EXT3|CONFIG_PRINTK" .config
 # CONFIG_PRINTK is not set
 CONFIG_EXT3_FS=y
 CONFIG_EXT3_DEFAULTS_TO_ORDERED=y
 CONFIG_EXT3_FS_XATTR=y
 # CONFIG_EXT3_FS_POSIX_ACL is not set
 # CONFIG_EXT3_FS_SECURITY is not set

Signed-off-by: Joe Perches <joe@perches.com>
---
 fs/ext3/ext3.h  | 44 ++++++++++++++++++++++++++++++++++++++++----
 fs/ext3/super.c | 14 +++++++-------
 2 files changed, 47 insertions(+), 11 deletions(-)

diff --git a/fs/ext3/ext3.h b/fs/ext3/ext3.h
index e85ff15..8aa33f8 100644
--- a/fs/ext3/ext3.h
+++ b/fs/ext3/ext3.h
@@ -1081,14 +1081,14 @@ extern int ext3_group_extend(struct super_block *sb,
 
 /* super.c */
 extern __printf(3, 4)
-void ext3_error(struct super_block *, const char *, const char *, ...);
+void __ext3_error(struct super_block *, const char *, const char *, ...);
 extern void __ext3_std_error (struct super_block *, const char *, int);
 extern __printf(3, 4)
-void ext3_abort(struct super_block *, const char *, const char *, ...);
+void __ext3_abort(struct super_block *, const char *, const char *, ...);
 extern __printf(3, 4)
-void ext3_warning(struct super_block *, const char *, const char *, ...);
+void __ext3_warning(struct super_block *, const char *, const char *, ...);
 extern __printf(3, 4)
-void ext3_msg(struct super_block *, const char *, const char *, ...);
+void __ext3_msg(struct super_block *, const char *, const char *, ...);
 extern void ext3_update_dynamic_rev (struct super_block *sb);
 
 #define ext3_std_error(sb, errno)				\
@@ -1097,6 +1097,42 @@ do {								\
 		__ext3_std_error((sb), __func__, (errno));	\
 } while (0)
 
+#ifdef CONFIG_PRINTK
+
+#define ext3_error(sb, func, fmt, ...)					\
+	__ext3_error(sb, func, fmt, ##__VA_ARGS__)
+#define ext3_abort(sb, func, fmt, ...)					\
+	__ext3_abort(sb, func, fmt, ##__VA_ARGS__)
+#define ext3_warning(sb, func, fmt, ...)				\
+	__ext3_warning(sb, func, fmt, ##__VA_ARGS__)
+#define ext3_msg(sb, prefix, fmt, ...)					\
+	__ext3_msg(sb, prefix, fmt, ##__VA_ARGS__)
+
+#else
+
+#define ext3_error(sb, func, fmt, ...)					\
+do {									\
+	no_printk(fmt, ##__VA_ARGS__);					\
+	__ext3_error(sb, func, " ");					\
+} while (0)
+#define ext3_abort(sb, func, fmt, ...)					\
+do {									\
+	no_printk(fmt, ##__VA_ARGS__);					\
+	__ext3_abort(sb, func, " ");					\
+} while (0)
+#define ext3_warning(sb, func, fmt, ...)				\
+do {									\
+	no_printk(fmt, ##__VA_ARGS__);					\
+	__ext3_warning(sb, func, " ");					\
+} while (0)
+#define ext3_msg(sb, prefix, fmt, ...)					\
+do {									\
+	no_printk(fmt, ##__VA_ARGS__);					\
+	__ext3_msg(sb, prefix, " ");					\
+} while (0)
+
+#endif
+
 /*
  * Inodes and files operations
  */
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 6356665..b7c3afc 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -123,7 +123,7 @@ void ext3_journal_abort_handle(const char *caller, const char *err_fn,
 	journal_abort_handle(handle);
 }
 
-void ext3_msg(struct super_block *sb, const char *prefix,
+void __ext3_msg(struct super_block *sb, const char *prefix,
 		const char *fmt, ...)
 {
 	struct va_format vaf;
@@ -182,8 +182,8 @@ static void ext3_handle_error(struct super_block *sb)
 			sb->s_id);
 }
 
-void ext3_error(struct super_block *sb, const char *function,
-		const char *fmt, ...)
+void __ext3_error(struct super_block *sb, const char *function,
+		  const char *fmt, ...)
 {
 	struct va_format vaf;
 	va_list args;
@@ -266,8 +266,8 @@ void __ext3_std_error (struct super_block * sb, const char * function,
  * case we take the easy way out and panic immediately.
  */
 
-void ext3_abort(struct super_block *sb, const char *function,
-		 const char *fmt, ...)
+void __ext3_abort(struct super_block *sb, const char *function,
+		  const char *fmt, ...)
 {
 	struct va_format vaf;
 	va_list args;
@@ -297,8 +297,8 @@ void ext3_abort(struct super_block *sb, const char *function,
 		journal_abort(EXT3_SB(sb)->s_journal, -EIO);
 }
 
-void ext3_warning(struct super_block *sb, const char *function,
-		  const char *fmt, ...)
+void __ext3_warning(struct super_block *sb, const char *function,
+		    const char *fmt, ...)
 {
 	struct va_format vaf;
 	va_list args;
-- 
1.8.1.2.459.gbcd45b4.dirty

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] ext2: Reduce object size when !CONFIG_PRINTK
  2013-06-18 17:14 [PATCH 1/2] ext2: Reduce object size when !CONFIG_PRINTK Joe Perches
  2013-06-18 17:14 ` [PATCH 2/2] ext3: " Joe Perches
@ 2013-06-21 16:50 ` Jan Kara
  2013-06-21 17:06   ` Joe Perches
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Kara @ 2013-06-21 16:50 UTC (permalink / raw)
  To: Joe Perches; +Cc: linux-ext4, Theodore Ts'o, Jan Kara, linux-kernel

On Tue 18-06-13 10:14:39, Joe Perches wrote:
> Reducing the object size ~5kb/15% could be useful for embedded
> systems.
> 
> Add #ifdef CONFIG_PRINTK #else #endif blocks
> to hold formats and arguments, passing " " to
> functions when !CONFIG_PRINTK and still verifying
> format and arguments with no_printk.
> 
>  $ size fs/ext2/built-in.o*
>     text   data	    bss	    dec	    hex	filename
>    31297     44	      4	  31345	   7a71	fs/ext2/built-in.o.ext2.new
>    36288     44	      4	  36336	   8df0	fs/ext2/built-in.o.ext2.old
> 
>  $ grep -E "CONFIG_EXT2|CONFIG_PRINTK" .config
>  # CONFIG_PRINTK is not set
>  CONFIG_EXT2_FS=y
>  # CONFIG_EXT2_FS_XATTR is not set
>  # CONFIG_EXT2_FS_XIP is not set
  I'm somewhat reluctant to merge this unless I know someone really
cares. It looks a bit ugly to ifdef every function doing some printing just
to reduce object size when CONFIG_PRINTK is disabled... And in future LTO
might help us ;)

								Honza

> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  fs/ext2/ext2.h  | 22 ++++++++++++++++++++--
>  fs/ext2/super.c |  6 +++---
>  2 files changed, 23 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
> index d9a17d0..888ae31 100644
> --- a/fs/ext2/ext2.h
> +++ b/fs/ext2/ext2.h
> @@ -767,12 +767,30 @@ struct dentry *ext2_get_parent(struct dentry *child);
>  
>  /* super.c */
>  extern __printf(3, 4)
> -void ext2_error(struct super_block *, const char *, const char *, ...);
> +void __ext2_error(struct super_block *, const char *, const char *, ...);
>  extern __printf(3, 4)
> -void ext2_msg(struct super_block *, const char *, const char *, ...);
> +void __ext2_msg(struct super_block *, const char *, const char *, ...);
>  extern void ext2_update_dynamic_rev (struct super_block *sb);
>  extern void ext2_write_super (struct super_block *);
>  
> +#ifdef CONFIG_PRINTK
> +#define ext2_error(sb, func, fmt, ...)					\
> +	__ext2_error(sb, func, fmt, ##__VA_ARGS__)
> +#define ext2_msg(sb, prefix, fmt, ...)					\
> +	__ext2_msg(sb, prefix, fmt, ##__VA_ARGS__)
> +#else
> +#define ext2_error(sb, func, fmt, ...)					\
> +do {									\
> +	no_printk(fmt, ##__VA_ARGS__);					\
> +	__ext2_error(sb, func, " ");					\
> +} while (0)
> +#define ext2_msg(sb, prefix, fmt, ...)					\
> +do {									\
> +	no_printk(fmt, ##__VA_ARGS__);					\
> +	__ext2_msg(sb, prefix, " ");					\
> +} while (0)
> +#endif
> +
>  /*
>   * Inodes and files operations
>   */
> diff --git a/fs/ext2/super.c b/fs/ext2/super.c
> index 2885349..61ffb3f 100644
> --- a/fs/ext2/super.c
> +++ b/fs/ext2/super.c
> @@ -45,8 +45,8 @@ static int ext2_sync_fs(struct super_block *sb, int wait);
>  static int ext2_freeze(struct super_block *sb);
>  static int ext2_unfreeze(struct super_block *sb);
>  
> -void ext2_error(struct super_block *sb, const char *function,
> -		const char *fmt, ...)
> +void __ext2_error(struct super_block *sb, const char *function,
> +		  const char *fmt, ...)
>  {
>  	struct va_format vaf;
>  	va_list args;
> @@ -80,7 +80,7 @@ void ext2_error(struct super_block *sb, const char *function,
>  	}
>  }
>  
> -void ext2_msg(struct super_block *sb, const char *prefix,
> +void __ext2_msg(struct super_block *sb, const char *prefix,
>  		const char *fmt, ...)
>  {
>  	struct va_format vaf;
> -- 
> 1.8.1.2.459.gbcd45b4.dirty
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] ext2: Reduce object size when !CONFIG_PRINTK
  2013-06-21 16:50 ` [PATCH 1/2] ext2: " Jan Kara
@ 2013-06-21 17:06   ` Joe Perches
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2013-06-21 17:06 UTC (permalink / raw)
  To: Jan Kara
  Cc: linux-ext4, Theodore Ts'o, linux-kernel, linux-embedded,
	openwrt-hackers

On Fri, 2013-06-21 at 18:50 +0200, Jan Kara wrote:
> On Tue 18-06-13 10:14:39, Joe Perches wrote:
> > Reducing the object size ~5kb/15% could be useful for embedded
> > systems.
> > 
> > Add #ifdef CONFIG_PRINTK #else #endif blocks
> > to hold formats and arguments, passing " " to
> > functions when !CONFIG_PRINTK and still verifying
> > format and arguments with no_printk.
> > 
> >  $ size fs/ext2/built-in.o*
> >     text   data	    bss	    dec	    hex	filename
> >    31297     44	      4	  31345	   7a71	fs/ext2/built-in.o.ext2.new
> >    36288     44	      4	  36336	   8df0	fs/ext2/built-in.o.ext2.old
> > 
> >  $ grep -E "CONFIG_EXT2|CONFIG_PRINTK" .config
> >  # CONFIG_PRINTK is not set
> >  CONFIG_EXT2_FS=y
> >  # CONFIG_EXT2_FS_XATTR is not set
> >  # CONFIG_EXT2_FS_XIP is not set
>   I'm somewhat reluctant to merge this unless I know someone really
> cares. It looks a bit ugly to ifdef every function doing some printing just
> to reduce object size when CONFIG_PRINTK is disabled... And in future LTO
> might help us ;)

(adding cc's to linux-embedded and openwrt
 maybe someone there cares)

Link time optimization might help some, but these calls
are still made and the strings could not be eliminated
without this.

Original patch: http://patchwork.kernel.org/patch/2744401/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-06-21 17:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-18 17:14 [PATCH 1/2] ext2: Reduce object size when !CONFIG_PRINTK Joe Perches
2013-06-18 17:14 ` [PATCH 2/2] ext3: " Joe Perches
2013-06-21 16:50 ` [PATCH 1/2] ext2: " Jan Kara
2013-06-21 17:06   ` Joe Perches

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).