Skip to contentSkip to conversation

RFC - organize include/linux/kernel.h, add include/linux/logging.h

DISCUSSION Alexey Dobriyan 3 participants 4 messages Nov 30, 2007

lore
Share & tools
lore
#0 lore raw
Quoted 4 lines

kernel.h has become a bit disorganized over a long time. Here's an attempt to clean it up a bit.

Something for everyone to like or dislike...

You duplicate ALIGN macros all over the place.

Quoted 9 lines

Groups externs and functions by module/function Creates a "logging.h" for printk, KERN_<level> Changes some macros to statement expressions
DIV_ROUND_UP, roundup and __ALIGN_MASK
Removes the unused PTR_ALIGN

This one used the ALIGN macro, but I'm not inclined to figure out what it actually does right now, so copy the old macro to this file and renames it.

Which is not acceptable. Ditto for DIV_ROUND_UP.

And you somehow decided that putting statements on one line is more readable than on multiple lines -- typecheck and friends.

Overall impression -- moving code just because you can.

#1 lore raw
Quoted 8 lines · Alexey Dobriyan
Quoted 3 lines

kernel.h has become a bit disorganized over a long time. Here's an attempt to clean it up a bit. Something for everyone to like or dislike...

You duplicate ALIGN macros all over the place.

Quoted 3 lines

This one used the ALIGN macro, but I'm not inclined to figure out what it actually does right now, so copy the old macro to this file and renames it.

Which is not acceptable. Ditto for DIV_ROUND_UP.

There were 3 instances where macros were
used to specify an array size. It seems
cleaner to use SEs and direct use of calculations for those 3 instances. (ymmv)

What would you expect this to do?

        struct {
        	unsigned char ha[ALIGN(32,sizeof(unsigned long))];
        } foo;

A casual reading might suggest 0.

Quoted 2 lines

And you somehow decided that putting statements on one line is more readable than on multiple lines -- typecheck and friends.

That appears to be the generally accepted coding style for macros and statement expressions.

Whatever is agreed to is fine by me.

Quoted 1 line

Overall impression -- moving code just because you can.

Yes. It's definitely a cleanup.

I think creating a separate include for the printk related defines and functions will be useful for possible future improvements to logging.

There are many private logging definitions that could be consolidated in generic way. Things like:

	#define MY_PRINTK(fmt, arg) print(PFX fmt, ##arg)

cheers, Joe

#2 lore raw
Quoted 7 lines · Joe Perches

There are many private logging definitions that could be consolidated in generic way. Things like:

	#define MY_PRINTK(fmt, arg) print(PFX fmt, ##arg)

cheers, Joe

While you are at that, PFX should probably be KBUILD_MODNAME, for simplicity. Then it will be easy to consolidate since they all use KBUILD_MODNAME rather than their own PFX. Just btw :)

#3 lore raw
Quoted 4 lines · Jan Engelhardt

While you are at that, PFX should probably be KBUILD_MODNAME, for simplicity. Then it will be easy to consolidate since they all use KBUILD_MODNAME rather than their own PFX. Just btw :)

I think that nearly all private logging functions
could be eliminated by having a new macro defined
especially for logging.

Something akin to:

#define PRINTK_MODNAME 1
#define PRINTK_FILE 2
#define PRINTK_FUNCTION 4
#define PRINTK_LINE 8

#define PRINTK_PREFIX (your choice)
#include <linux/logging.h>

then all uses of pr_<level> could get modified for free.