linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC] Refactor kenter/kleave/kdebug macros
@ 2015-05-16 17:01 Leon Romanovsky
  2015-05-16 17:09 ` Joe Perches
  2015-05-18 10:31 ` David Howells
  0 siblings, 2 replies; 10+ messages in thread
From: Leon Romanovsky @ 2015-05-16 17:01 UTC (permalink / raw)
  To: dhowells, Linux-MM, linux-kernel, linux-cachefs, linux-afs

Dear David,

During my work on NOMMU system (mm/nommu.c), I saw definition and
usage of kenter/kleave/kdebug macros. These macros are compiled as
empty because of "#if 0" construction.
  45 #if 0
  46 #define kenter(FMT, ...) \
  47         printk(KERN_DEBUG "==> %s("FMT")\n", __func__, ##__VA_ARGS__)
  48 #define kleave(FMT, ...) \
  49         printk(KERN_DEBUG "<== %s()"FMT"\n", __func__, ##__VA_ARGS__)
  50 #define kdebug(FMT, ...) \
  51         printk(KERN_DEBUG "xxx" FMT"yyy\n", ##__VA_ARGS__)
  52 #else
  53 #define kenter(FMT, ...) \
  54         no_printk(KERN_DEBUG "==> %s("FMT")\n", __func__, ##__VA_ARGS__)
  55 #define kleave(FMT, ...) \
  56         no_printk(KERN_DEBUG "<== %s()"FMT"\n", __func__, ##__VA_ARGS__)
  57 #define kdebug(FMT, ...) \
  58         no_printk(KERN_DEBUG FMT"\n", ##__VA_ARGS__)
  59 #endif

This code was changed in 2009 [1] and similar definitions can be found
in 9 other files [2]. The protection of these definitions is slightly
different. There are places with "#if 0" protection and others with
"#if defined(__KDEBUG)" protection. __KDEBUG is supposed to be
inserted by GCC.

My question is how we should handle such duplicated debug print code?
As possible solutions, I see five options:
1. Leave it as is.
2. Move it to general include file (for example linux/printk.h) and
commonize the output to be consistent between different kdebug users.
3. Add CONFIG_*_DEBUG definition for every kdebug user.
4. Move everything to "#if 0" construction.
5. Move everything to "#if defined(__KDEBUG)" construction.

What do you think?

[1]     commit 8feae13110d60cc6287afabc2887366b0eb226c2
        Author: David Howells <dhowells@redhat.com>
        Date:   Thu Jan 8 12:04:47 2009 +0000

[2] List of all files there kdebug was defined:
* arch/mn10300/kernel/mn10300-serial.c
* arch/mn10300/mm/misalignment.c
* fs/cachefiles/internal.h
* fs/afs/internal.h
* fs/fscache/internal.h
* fs/binfmt_elf_fdpic.c
* kernel/cred.c
* mm/nommu.c
* net/rxrpc/ar-internal.h
* security/keys/internal.h

Thank you.

-- 
Leon Romanovsky | Independent Linux Consultant
        www.leon.nu | leon@leon.nu

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2015-05-18 18:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-16 17:01 [RFC] Refactor kenter/kleave/kdebug macros Leon Romanovsky
2015-05-16 17:09 ` Joe Perches
2015-05-16 18:56   ` Leon Romanovsky
2015-05-18 10:31 ` David Howells
2015-05-18 13:23   ` Leon Romanovsky
2015-05-18 13:27     ` Leon Romanovsky
2015-05-18 13:29   ` David Howells
2015-05-18 13:52     ` Leon Romanovsky
2015-05-18 15:20     ` David Howells
2015-05-18 18:35       ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox