Skip to contentSkip to conversation

kernel.h string cleanup

PATCH NAK Dave Young 5 participants 12 messages Feb 25, 2010 – Feb 27, 2010 Generic string library

lore
Share & tools
lore

Dave Young

author
#0 lore raw

PATCH 3/7 kernel.h string cleanup

Cleanup kernel.h string related stuff, move to linux/string.h

Due to lots of files need them, include string.h in kernel.h just for convinience. It can be thought as the first step of further cleanup.

---
 include/linux/kernel.h |   29 +----------------------------
 include/linux/string.h |   30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 28 deletions(-)
include/linux/kernel.h +1 -28
@@ -15,6 +15,7 @@
 #include <linux/typecheck.h>
 #include <linux/printk.h>
 #include <linux/panic.h>
+#include <linux/string.h>
 #include <asm/byteorder.h>
 #include <asm/bug.h>
 
@@ -136,34 +137,6 @@ NORET_TYPE void do_exit(long error_code)
 	ATTRIB_NORET;
 NORET_TYPE void complete_and_exit(struct completion *, long)
 	ATTRIB_NORET;
-extern unsigned long simple_strtoul(const char *,char **,unsigned int);
-extern long simple_strtol(const char *,char **,unsigned int);
-extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
-extern long long simple_strtoll(const char *,char **,unsigned int);
-extern int strict_strtoul(const char *, unsigned int, unsigned long *);
-extern int strict_strtol(const char *, unsigned int, long *);
-extern int strict_strtoull(const char *, unsigned int, unsigned long long *);
-extern int strict_strtoll(const char *, unsigned int, long long *);
-extern int sprintf(char * buf, const char * fmt, ...)
-	__attribute__ ((format (printf, 2, 3)));
-extern int vsprintf(char *buf, const char *, va_list)
-	__attribute__ ((format (printf, 2, 0)));
-extern int snprintf(char * buf, size_t size, const char * fmt, ...)
-	__attribute__ ((format (printf, 3, 4)));
-extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
-	__attribute__ ((format (printf, 3, 0)));
-extern int scnprintf(char * buf, size_t size, const char * fmt, ...)
-	__attribute__ ((format (printf, 3, 4)));
-extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
-	__attribute__ ((format (printf, 3, 0)));
-extern char *kasprintf(gfp_t gfp, const char *fmt, ...)
-	__attribute__ ((format (printf, 2, 3)));
-extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args);
-
-extern int sscanf(const char *, const char *, ...)
-	__attribute__ ((format (scanf, 2, 3)));
-extern int vsscanf(const char *, const char *, va_list)
-	__attribute__ ((format (scanf, 2, 0)));
 
 extern int get_option(char **str, int *pint);
 extern char *get_options(const char *str, int nints, int *ints);
include/linux/string.h +30 -0
@@ -142,5 +142,35 @@ static inline bool strstarts(const char 
 {
 	return strncmp(str, prefix, strlen(prefix)) == 0;
 }
+
+extern unsigned long simple_strtoul(const char *, char **, unsigned int);
+extern long simple_strtol(const char *, char **, unsigned int);
+extern unsigned long long simple_strtoull(const char *, char **, unsigned int);
+extern long long simple_strtoll(const char *, char **, unsigned int);
+extern int strict_strtoul(const char *, unsigned int, unsigned long *);
+extern int strict_strtol(const char *, unsigned int, long *);
+extern int strict_strtoull(const char *, unsigned int, unsigned long long *);
+extern int strict_strtoll(const char *, unsigned int, long long *);
+extern int sprintf(char *buf, const char *fmt, ...)
+	__attribute__ ((format (printf, 2, 3)));
+extern int vsprintf(char *buf, const char *, va_list)
+	__attribute__ ((format (printf, 2, 0)));
+extern int snprintf(char *buf, size_t size, const char *fmt, ...)
+	__attribute__ ((format (printf, 3, 4)));
+extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
+	__attribute__ ((format (printf, 3, 0)));
+extern int scnprintf(char *buf, size_t size, const char *fmt, ...)
+	__attribute__ ((format (printf, 3, 4)));
+extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
+	__attribute__ ((format (printf, 3, 0)));
+extern char *kasprintf(gfp_t gfp, const char *fmt, ...)
+	__attribute__ ((format (printf, 2, 3)));
+extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args);
+
+extern int sscanf(const char *, const char *, ...)
+	__attribute__ ((format (scanf, 2, 3)));
+extern int vsscanf(const char *, const char *, va_list)
+	__attribute__ ((format (scanf, 2, 0)));
 #endif
+
 #endif /* _LINUX_STRING_H_ */
#1 lore raw
Quoted 1 line · Dave Young

Cleanup kernel.h string related stuff, move to linux/string.h

Ick.

That's not where they're in userspace headers.

Quoted 34 lines
include/linux/kernel.h +0 -28
@@ -136,34 +137,6 @@ NORET_TYPE void do_exit(long error_code)
 	ATTRIB_NORET;
 NORET_TYPE void complete_and_exit(struct completion *, long)
 	ATTRIB_NORET;
-extern unsigned long simple_strtoul(const char *,char **,unsigned int);
-extern long simple_strtol(const char *,char **,unsigned int);
-extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
-extern long long simple_strtoll(const char *,char **,unsigned int);
-extern int strict_strtoul(const char *, unsigned int, unsigned long *);
-extern int strict_strtol(const char *, unsigned int, long *);
-extern int strict_strtoull(const char *, unsigned int, unsigned long long *);
-extern int strict_strtoll(const char *, unsigned int, long long *);
-extern int sprintf(char * buf, const char * fmt, ...)
-	__attribute__ ((format (printf, 2, 3)));
-extern int vsprintf(char *buf, const char *, va_list)
-	__attribute__ ((format (printf, 2, 0)));
-extern int snprintf(char * buf, size_t size, const char * fmt, ...)
-	__attribute__ ((format (printf, 3, 4)));
-extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
-	__attribute__ ((format (printf, 3, 0)));
-extern int scnprintf(char * buf, size_t size, const char * fmt, ...)
-	__attribute__ ((format (printf, 3, 4)));
-extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
-	__attribute__ ((format (printf, 3, 0)));
-extern char *kasprintf(gfp_t gfp, const char *fmt, ...)
-	__attribute__ ((format (printf, 2, 3)));
-extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args);
-
-extern int sscanf(const char *, const char *, ...)
-	__attribute__ ((format (scanf, 2, 3)));
-extern int vsscanf(const char *, const char *, va_list)
-	__attribute__ ((format (scanf, 2, 0)));
author
#2 lore raw
Quoted 6 lines · Alexey Dobriyan
Quoted 1 line · Dave Young

Cleanup kernel.h string related stuff, move to linux/string.h

Ick.

That's not where they're in userspace headers.

Yeah, same question, then where should they go? I think string.h is fine.

Thanks.

Quoted 36 lines
Quoted 35 lines
include/linux/kernel.h +0 -28
@@ -136,34 +137,6 @@ NORET_TYPE void do_exit(long error_code)
       ATTRIB_NORET;
  NORET_TYPE void complete_and_exit(struct completion *, long)
       ATTRIB_NORET;
-extern unsigned long simple_strtoul(const char *,char **,unsigned int);
-extern long simple_strtol(const char *,char **,unsigned int);
-extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
-extern long long simple_strtoll(const char *,char **,unsigned int);
-extern int strict_strtoul(const char *, unsigned int, unsigned long *);
-extern int strict_strtol(const char *, unsigned int, long *);
-extern int strict_strtoull(const char *, unsigned int, unsigned long long *);
-extern int strict_strtoll(const char *, unsigned int, long long *);
-extern int sprintf(char * buf, const char * fmt, ...)
-     __attribute__ ((format (printf, 2, 3)));
-extern int vsprintf(char *buf, const char *, va_list)
-     __attribute__ ((format (printf, 2, 0)));
-extern int snprintf(char * buf, size_t size, const char * fmt, ...)
-     __attribute__ ((format (printf, 3, 4)));
-extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
-     __attribute__ ((format (printf, 3, 0)));
-extern int scnprintf(char * buf, size_t size, const char * fmt, ...)
-     __attribute__ ((format (printf, 3, 4)));
-extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
-     __attribute__ ((format (printf, 3, 0)));
-extern char *kasprintf(gfp_t gfp, const char *fmt, ...)
-     __attribute__ ((format (printf, 2, 3)));
-extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args);
-
-extern int sscanf(const char *, const char *, ...)
-     __attribute__ ((format (scanf, 2, 3)));
-extern int vsscanf(const char *, const char *, va_list)
-     __attribute__ ((format (scanf, 2, 0)));
Signature · 2 lines
Regards
dave
#3 lore raw
Quoted 1 line · Dave Young

Yeah, same question, then where should they go?

Should I hand a patch to you, so you can repost it?

Quoted 1 line

I think string.h is fine.

It obviously isn't fine.

Why all of sudden kernel.h split when kernel.h is for simple misc stuff for which there is no other place.

author
#4 lore raw
Quoted 4 lines · Alexey Dobriyan
Quoted 1 line · Dave Young

Yeah, same question, then where should they go?

Should I hand a patch to you, so you can repost it?

Please, if you think spliting is not necessary, you can just say that, or feel free to send a patch.

Quoted 8 lines
Quoted 2 lines

I think string.h is fine.

It obviously isn't fine.

Why all of sudden kernel.h split when kernel.h is for simple misc stuff for which there is no other place.

It will be better to move some of them to proper place instead of kernel.h

Signature · 2 lines
Regards
dave
#5 lore raw
Quoted 1 line · Dave Young

It will be better to move some of them to proper place instead of kernel.h

Perhaps you could describe some of the reasons why it's better to move them.

Maybe you could post the results of a timed compile comparison with kernel.h broken into multiple pieces while you're at it.

author
#6 lore raw
Quoted 10 lines · Joe Perches
Quoted 1 line · Dave Young

It will be better to move some of them to proper place instead of kernel.h

Perhaps you could describe some of the reasons why it's better to move them.

Maybe you could post the results of a timed compile comparison with kernel.h broken into multiple pieces while you're at it.

Thanks joe.

Spliting is necessary from my point of view.
It will be more clean to put externs/declarations to their own header files. At the same time compiling time benifits as well.

printk/panic/string/trace header are splited then included by kernel.h so just hexdump/int_sqrt are actually seperated.

fresh boot and same .config, make without -j, test result as following:

with the patches applied:

time:
real 15m16.504s
user 12m51.866s
sys 1m39.700s

vmlinux .text size: 003bfcd2

without the patches applied*
time:
real 15m20.518s
user 12m54.120s
sys 1m40.190s

vmlinux .text size: 003bfcea

Signature · 2 lines
Regards
dave
#7 lore raw
Quoted 7 lines · Dave Young

It will be more clean to put externs/declarations to their own header files. At the same time compiling time benifits as well.

printk/panic/string/trace header are splited then included by kernel.h so just hexdump/int_sqrt are actually seperated.

fresh boot

You mean cold-cache compile so results are basically random?

Quoted 9 lines

and same .config, make without -j, test result as following:

with the patches applied:

time:
real 15m16.504s
user 12m51.866s
sys 1m39.700s

Quoted 7 lines

vmlinux .text size: 003bfcd2

without the patches applied*
time:
real 15m20.518s
user 12m54.120s
sys 1m40.190s

Not scientific at all.

author
#8 lore raw
Quoted 10 lines · Alexey Dobriyan
Quoted 7 lines · Dave Young

It will be more clean to put externs/declarations to their own header files. At the same time compiling time benifits as well.

printk/panic/string/trace header are splited then included by kernel.h so just hexdump/int_sqrt are actually seperated.

fresh boot

You mean cold-cache compile so results are basically random?

Yes, roughly test.
I have to say I will have no time to do more testing.

Quoted 20 lines
Quoted 10 lines

and same .config, make without -j, test result as following:

with the patches applied:

time:
real 15m16.504s
user 12m51.866s
sys 1m39.700s

Quoted 7 lines

vmlinux .text size: 003bfcd2

without the patches applied*
time:
real 15m20.518s
user 12m54.120s
sys 1m40.190s

Not scientific at all.

Signature · 2 lines
Regards
dave
#9 lore raw
In reply to Dave Young
Quoted 11 lines · Dave Young

Spliting is necessary from my point of view.

with the patches applied:

time:
real 15m16.504s
user 12m51.866s
sys 1m39.700s

vmlinux .text size: 003bfcd2

Quoted 7 lines

without the patches applied*
time:
real 15m20.518s
user 12m54.120s
sys 1m40.190s

vmlinux .text size: 003bfcea

Why the change in text size? If moving stuff around in headers affects the final result, I'm thinking that you did something wrong.

The merge for x86 did a lot of file manipulation, but Thomas and Ingo would always test that the binary result was the same. If the binary result is different, then something went wrong with the file manipulations.

-- Steve

author
#10 lore raw
Quoted 19 lines · Steven Rostedt
Quoted 17 lines · Dave Young

Spliting is necessary from my point of view.

with the patches applied:

time:
real 15m16.504s
user 12m51.866s
sys 1m39.700s

vmlinux .text size: 003bfcd2

without the patches applied*
time:
real 15m20.518s
user 12m54.120s
sys 1m40.190s

Quoted 4 lines
Quoted 1 line

vmlinux .text size: 003bfcea

Why the change in text size? If moving stuff around in headers affects the final result, I'm thinking that you did something wrong.

trace/printk/panic/string stuff just being moved to another head file, then included
in kernel.h, so there shouldn't be difference with before.

So I guess it's the hexdump/int_sqrt head file which are removed from kernel.h?

Quoted 11 lines

The merge for x86 did a lot of file manipulation, but Thomas and Ingo would always test that the binary result was the same. If the binary result is different, then something went wrong with the file manipulations.

-- Steve

Signature · 2 lines
Regards
dave
#11 lore raw
In reply to Alexey Dobriyan
Quoted 11 lines · Alexey Dobriyan
Quoted 1 line · Dave Young

Yeah, same question, then where should they go?

Should I hand a patch to you, so you can repost it?

Quoted 1 line

I think string.h is fine.

It obviously isn't fine.

Why all of sudden kernel.h split when kernel.h is for simple misc stuff for which there is no other place.

kernel.h can be split up, just to ventilate it a bit. It's really a big header so this could be an occasion to organize it a bit.