2010-02-25 15:54:08

by Dave Young

[permalink] [raw]
Subject: [PATCH 03/07] 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.

Signed-off-by: Dave Young <[email protected]>
---
include/linux/kernel.h | 29 +----------------------------
include/linux/string.h | 30 ++++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 28 deletions(-)

--- linux-2.6.orig/include/linux/kernel.h 2010-02-25 20:45:26.000000000 +0800
+++ linux-2.6/include/linux/kernel.h 2010-02-25 20:46:11.000000000 +0800
@@ -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);
--- linux-2.6.orig/include/linux/string.h 2010-02-25 20:43:06.000000000 +0800
+++ linux-2.6/include/linux/string.h 2010-02-25 20:49:16.000000000 +0800
@@ -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_ */


2010-02-25 18:55:24

by Alexey Dobriyan

[permalink] [raw]
Subject: Re: [PATCH 03/07] kernel.h string cleanup

On Thu, Feb 25, 2010 at 11:53:59PM +0800, Dave Young wrote:
> Cleanup kernel.h string related stuff, move to linux/string.h

Ick.

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

> --- linux-2.6.orig/include/linux/kernel.h
> +++ linux-2.6/include/linux/kernel.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)));

2010-02-26 01:14:36

by Dave Young

[permalink] [raw]
Subject: Re: [PATCH 03/07] kernel.h string cleanup

On Fri, Feb 26, 2010 at 2:55 AM, Alexey Dobriyan <[email protected]> wrote:
> On Thu, Feb 25, 2010 at 11:53:59PM +0800, Dave Young wrote:
>> 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.

>
>> --- linux-2.6.orig/include/linux/kernel.h
>> +++ linux-2.6/include/linux/kernel.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)));
>



--
Regards
dave

2010-02-26 07:15:41

by Alexey Dobriyan

[permalink] [raw]
Subject: Re: [PATCH 03/07] kernel.h string cleanup

On Fri, Feb 26, 2010 at 3:14 AM, Dave Young <[email protected]> wrote:
> Yeah, same question, then where should they go?

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

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

2010-02-26 07:33:24

by Dave Young

[permalink] [raw]
Subject: Re: [PATCH 03/07] kernel.h string cleanup

On Fri, Feb 26, 2010 at 3:15 PM, Alexey Dobriyan <[email protected]> wrote:
> On Fri, Feb 26, 2010 at 3:14 AM, Dave Young <[email protected]> wrote:
>> 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.

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

--
Regards
dave

2010-02-26 07:43:05

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 03/07] kernel.h string cleanup

On Fri, 2010-02-26 at 15:33 +0800, Dave Young wrote:
> 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.

2010-02-26 09:55:19

by Dave Young

[permalink] [raw]
Subject: Re: [PATCH 03/07] kernel.h string cleanup

On Fri, Feb 26, 2010 at 3:42 PM, Joe Perches <[email protected]> wrote:
> On Fri, 2010-02-26 at 15:33 +0800, Dave Young wrote:
>> 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

--
Regards
dave

2010-02-26 09:58:42

by Alexey Dobriyan

[permalink] [raw]
Subject: Re: [PATCH 03/07] kernel.h string cleanup

On Fri, Feb 26, 2010 at 11:55 AM, Dave Young <[email protected]> wrote:
> 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?

> 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

Not scientific at all.

2010-02-26 10:51:12

by Dave Young

[permalink] [raw]
Subject: Re: [PATCH 03/07] kernel.h string cleanup

On Fri, Feb 26, 2010 at 5:58 PM, Alexey Dobriyan <[email protected]> wrote:
> On Fri, Feb 26, 2010 at 11:55 AM, Dave Young <[email protected]> wrote:
>> 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.

>
>> 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
>
> Not scientific at all.
>



--
Regards
dave

2010-02-26 14:27:29

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH 03/07] kernel.h string cleanup

On Fri, 2010-02-26 at 17:55 +0800, Dave Young wrote:

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


2010-02-27 09:55:05

by Dave Young

[permalink] [raw]
Subject: Re: [PATCH 03/07] kernel.h string cleanup

On Fri, Feb 26, 2010 at 10:27 PM, Steven Rostedt <[email protected]> wrote:
> On Fri, 2010-02-26 at 17:55 +0800, Dave Young wrote:
>
>> 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
>>
>> 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?
>
> 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
>
>
>
>



--
Regards
dave

2010-02-27 10:20:59

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [PATCH 03/07] kernel.h string cleanup

On Fri, Feb 26, 2010 at 09:15:39AM +0200, Alexey Dobriyan wrote:
> On Fri, Feb 26, 2010 at 3:14 AM, Dave Young <[email protected]> wrote:
> > Yeah, same question, then where should they go?
>
> Should I hand a patch to you, so you can repost it?
>
> > 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.