login
Login
/
Register
Search
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2007
»
September
»
29
Re: [PATCH 1/3] CodingStyle updates
view
thread
!MAILaRCHIVE_VOTE_RePLACE
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From:
Shawn Bohrer <shawn.bohrer@...>
To: Erez Zadok <ezk@...>
Cc: <torvalds@...>, <akpm@...>, <linux-kernel@...>, Kok, Auke <auke-jan.h.kok@...>, Kyle Moffett <mrmacman_g4@...>, Jan Engelhardt <jengelh@...>, Adrian Bunk <bunk@...>, roel <12o3l@...>
Subject:
Re: [PATCH 1/3] CodingStyle updates
Date: Saturday, September 29, 2007 - 10:43 am
On Fri, Sep 28, 2007 at 05:32:00PM -0400, Erez Zadok wrote:
quoted text
> 1. Updates chapter 13 (printing kernel messages) to expand on the use of > pr_debug()/pr_info(), what to avoid, and how to hook your debug code with > kernel.h. > > 2. New chapter 19, branch prediction optimizations, discusses the whole > un/likely issue. > > Cc: "Kok, Auke" <auke-jan.h.kok@intel.com> > Cc: Kyle Moffett <mrmacman_g4@mac.com> > Cc: Jan Engelhardt <jengelh@computergmbh.de> > Cc: Adrian Bunk <bunk@kernel.org> > Cc: roel <12o3l@tiscali.nl> > > Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu> > --- > Documentation/CodingStyle | 88 +++++++++++++++++++++++++++++++++++++++++++- > 1 files changed, 86 insertions(+), 2 deletions(-) > > diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle > index 7f1730f..00b29e4 100644 > --- a/Documentation/CodingStyle > +++ b/Documentation/CodingStyle > @@ -643,8 +643,26 @@ Printing numbers in parentheses (%d) adds no value and should be avoided. > There are a number of driver model diagnostic macros in <linux/device.h> > which you should use to make sure messages are matched to the right device > and driver, and are tagged with the right level: dev_err(), dev_warn(), > -dev_info(), and so forth. For messages that aren't associated with a > -particular device, <linux/kernel.h> defines pr_debug() and pr_info(). > +dev_info(), and so forth. > + > +A number of people often like to define their own debugging printf's, > +wrapping printk's in #ifdef's that get turned on only when subsystem > +debugging is compiled in (e.g., dprintk, Dprintk, DPRINTK, etc.). Please > +don't reinvent the wheel but use existing mechanisms. For messages that > +aren't associated with a particular device, <linux/kernel.h> defines > +pr_debug() and pr_info(); the latter two translate to printk(KERN_DEBUG) and
The latter two? Since there are only two presented I think there is no reason to say "latter".
quoted text
> +printk(KERN_INFO), respectively. However, to get pr_debug() to actually > +emit the message, you'll need to turn on DEBUG in your code, which can be > +done as follows in your subsystem Makefile: > + > +ifeq ($(CONFIG_WHATEVER_DEBUG),y) > +EXTRA_CFLAGS += -DDEBUG > +endif > + > +In this way, you can create a Kconfig parameter to turn on debugging at > +compile time, which will also turn on DEBUG, to enable pr_debug() to emit > +actual messages; conversely, when CONFIG_WHATEVER_DEBUG is off, DEBUG is > +off, and pr_debug() will display nothing. > > Coming up with good debugging messages can be quite a challenge; and once > you have them, they can be a huge help for remote troubleshooting. Such > @@ -779,6 +797,69 @@ includes markers for indentation and mode configuration. People may use their > own custom mode, or may have some other magic method for making indentation > work correctly. > > + Chapter 19: branch prediction optimizations > + > +The kernel includes macros called likely() and unlikely(), which can be used > +as hints to the compiler to optimize branch prediction. They operate by > +asking gcc to shuffle the code around so that the more favorable outcome > +executes linearly, avoiding a JMP instruction; this can improve cache > +pipeline efficiency. For technical details how these macros work, see the > +References section at the end of this document. > + > +An example use of this as as follows:
^^^^^^
quoted text
> + > + ptr = kmalloc(size, GFP_KERNEL); > + if (unlikely(!ptr)) > + ... > + > +or > + err = some_function(...); > + if (likely(!err)) > + ...
-- Shawn -
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[PATCH] 0/3 coding standards documentation/code updates
, Erez Zadok
, (Fri Sep 28, 5:31 pm)
Re: [PATCH] 0/3 coding standards documentation/code updates
, Linus Torvalds
, (Sat Sep 29, 2:18 pm)
Re: [PATCH] 0/3 coding standards documentation/code updates
,
, (Sat Sep 29, 10:24 pm)
Re: [PATCH] 0/3 coding standards documentation/code updates
, Al Viro
, (Sat Sep 29, 11:27 pm)
Re: [PATCH] 0/3 coding standards documentation/code updates
,
, (Sat Sep 29, 11:39 pm)
Re: [PATCH] 0/3 coding standards documentation/code updates
, Linus Torvalds
, (Sat Sep 29, 11:00 pm)
Re: [PATCH] 0/3 coding standards documentation/code updates
,
, (Sat Sep 29, 11:29 pm)
Re: [PATCH] 0/3 coding standards documentation/code updates
, Theodore Tso
, (Sun Sep 30, 1:57 pm)
Re: [PATCH] 0/3 coding standards documentation/code updates
, Linus Torvalds
, (Sat Sep 29, 11:35 pm)
Re: [PATCH] 0/3 coding standards documentation/code updates
, Erez Zadok
, (Sat Sep 29, 8:23 pm)
Re: [PATCH] 0/3 coding standards documentation/code updates
, Linus Torvalds
, (Sat Sep 29, 8:49 pm)
Re: [PATCH] 0/3 coding standards documentation/code updates
, Erez Zadok
, (Sun Sep 30, 12:01 am)
Re: [PATCH] 0/3 coding standards documentation/code updates
, Mark Lord
, (Sun Sep 30, 1:40 pm)
Re: [PATCH] 0/3 coding standards documentation/code updates
, Randy Dunlap
, (Sun Sep 30, 1:59 pm)
Re: [PATCH] 0/3 coding standards documentation/code updates
, Robert P. J. Day
, (Sat Sep 29, 5:56 pm)
Re: [PATCH] 0/3 coding standards documentation/code updates
, J. Bruce Fields
, (Sat Sep 29, 3:56 pm)
Re: [PATCH] 0/3 coding standards documentation/code updates
, Theodore Tso
, (Sat Sep 29, 10:06 pm)
Re: [PATCH] 0/3 coding standards documentation/code updates
, Erez Zadok
, (Sat Sep 29, 11:28 pm)
Re: [PATCH] 0/3 coding standards documentation/code updates
, Randy Dunlap
, (Sat Sep 29, 4:14 pm)
[PATCH 1/3] CodingStyle updates
, Erez Zadok
, (Fri Sep 28, 5:32 pm)
Re: [PATCH 1/3] CodingStyle updates
, Randy Dunlap
, (Sat Sep 29, 2:01 pm)
Re: [PATCH 1/3] CodingStyle updates
, Sam Ravnborg
, (Sat Sep 29, 2:29 pm)
[OT] kbuild syntax extension for ccflags and asflags (was: [...
, Ingo Oeser
, (Sat Sep 29, 4:21 pm)
Re: [OT] kbuild syntax extension for ccflags and asflags (wa...
, Sam Ravnborg
, (Sat Sep 29, 4:24 pm)
Re: [PATCH 1/3] CodingStyle updates
, Scott Preece
, (Sat Sep 29, 11:59 am)
Re: [PATCH 1/3] CodingStyle updates
, Shawn Bohrer
, (Sat Sep 29, 10:43 am)
Re: [PATCH 1/3] CodingStyle updates
, Randy Dunlap
, (Fri Sep 28, 5:46 pm)
[PATCH 3/3] New script to check coding-style compliance on m...
, Erez Zadok
, (Fri Sep 28, 5:32 pm)
Re: [PATCH 3/3] New script to check coding-style compliance ...
, Sam Ravnborg
, (Sat Sep 29, 6:10 am)
[PATCH 2/3] Update usage string for checkpatch.pl
, Erez Zadok
, (Fri Sep 28, 5:32 pm)
Navigation
Create content
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Tarkan Erimer
Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3
Greg Kroah-Hartman
[PATCH 005/196] Chinese: add translation of SubmittingDrivers
Andrew Morton
Re: -mm merge plans for 2.6.23 -- sys_fallocate
Michael Opdenacker
[PATCH] x86: fix unconditional arch/x86/kernel/pcspeaker.c compiling
git
:
linux-netdev
:
David Miller
Re: [GIT]: Networking
Gerrit Renker
[PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side)
Jarek Poplawski
[PATCH] pkt_sched: Destroy gen estimators under rtnl_lock().
Andrew Morton
Re: [BUG] New Kernel Bugs
openbsd-misc
:
Colocation donated by:
Who's online
There are currently
2 users
and
838 guests
online.
Online users
badoodles
Nelson
Syndicate