lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 25 Aug 2015 13:39:25 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Joe Perches <joe@...ches.com>
Cc:	David Howells <dhowells@...hat.com>,
	James Morris <jmorris@...ei.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] cred: Remove unnecessary kdebug atomic reads

On Tue, 25 Aug 2015 09:53:51 -0700 Joe Perches <joe@...ches.com> wrote:

> commit e0e817392b9a ("CRED: Add some configurable debugging [try #6]")
> added the kdebug mechanism to this file back in 2009.
> 
> The kdebug macro calls no_printk which always evaluates arguments.
> 
> Most of the kdebug uses have an unnecessary call of
> 	atomic_read(&cred->usage)
> 
> Make the kdebug macro do nothing by defining it with
> 	do { if (0) no_printk(...); } while (0)
> when not enabled.
> 
> $ size kernel/cred.o* (defconfig x86-64)
>    text	   data	    bss	    dec	    hex	filename
>    2748	    336	      8	   3092	    c14	kernel/cred.o.new
>    2788	    336	      8	   3132	    c3c	kernel/cred.o.old
> 
> Miscellanea:
> o Neaten the #define kdebug macros while there
> 
> ...
>
> --- a/kernel/cred.c
> +++ b/kernel/cred.c
> @@ -20,11 +20,16 @@
>  #include <linux/cn_proc.h>
>  
>  #if 0
> -#define kdebug(FMT, ...) \
> -	printk("[%-5.5s%5u] "FMT"\n", current->comm, current->pid ,##__VA_ARGS__)
> +#define kdebug(FMT, ...)						\
> +	printk("[%-5.5s%5u] " FMT "\n",					\
> +	       current->comm, current->pid, ##__VA_ARGS__)
>  #else
> -#define kdebug(FMT, ...) \
> -	no_printk("[%-5.5s%5u] "FMT"\n", current->comm, current->pid ,##__VA_ARGS__)
> +#define kdebug(FMT, ...)						\
> +do {									\
> +	if (0)								\
> +		no_printk("[%-5.5s%5u] " FMT "\n",			\
> +			  current->comm, current->pid, ##__VA_ARGS__);	\
> +} while (0)
>  #endif
>  
>  static struct kmem_cache *cred_jar;

Did you consider doing this within no_printk()?  That would break code
which is relying on side-effects in the evaluation of a printk arg but
that's pretty weird and I bet there isn't (and won't be) such code.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ