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]
Message-ID: <op.v9sctsrj3l0zgt@mpn-glaptop>
Date:	Thu, 16 Feb 2012 11:09:18 -0800
From:	"Michal Nazarewicz" <mina86@...a86.com>
To:	linux-mm@...ck.org,
	Radosław Smogura <mail@...gura.eu>
Cc:	"Yongqiang Yang" <xiaoqiangnk@...il.com>,
	linux-ext4@...r.kernel.org
Subject: Re: [PATCH 01/18] Added hacking menu for override optimization by
 GCC.

On Thu, 16 Feb 2012 06:31:28 -0800, Radosław Smogura <mail@...gura.eu> wrote:
> Supporting files, like Kconfig, Makefile are auto-generated due to large amount
> of available options.

So why not run the script as part of make rather then store generated files in
repository?

> diff --git a/scripts/debug/make_config_optim.sh b/scripts/debug/make_config_optim.sh
> new file mode 100644
> index 0000000..26865923
> --- /dev/null
> +++ b/scripts/debug/make_config_optim.sh
> @@ -0,0 +1,88 @@
> +#!/bin/sh

The below won't run on POSIX-compatible sh.  Address my comments
below to fix that.

> +
> +## Utility script for generating optimization override options
> +## for kernel compilation.
> +##
> +## Distributed under GPL v2 license
> +## (c) Radosław Smogura, 2011
> +
> +# Prefix added for variable
> +CFG_PREFIX="HACK_OPTIM"
> +
> +KCFG="Kconfig.debug.optim"
> +MKFI="Makefile.optim.inc"

How about names that mean something?

KCONFIG=...
MAKEFILE=...

> +
> +OPTIMIZATIONS_PARAMS="-fno-inline-functions-called-once \
> + -fno-combine-stack-adjustments \
> + -fno-tree-dce \
> + -fno-tree-dominator-opts \
> + -fno-dse "

Slashes at end of lines are not necessary here.

> +
> +echo "# This file was auto generated. It's utility configuration" > $KCFG
> +echo "# Distributed under GPL v2 License" >> $KCFG
> +echo >> $KCFG
> +echo "menuconfig ${CFG_PREFIX}" >> $KCFG
> +echo -e "\tbool \"Allows to override GCC optimization\"" >> $KCFG
> +echo -e "\tdepends on DEBUG_KERNEL && EXPERIMENTAL" >> $KCFG
> +echo -e "\thelp" >> $KCFG
> +echo -e "\t  If you say Y here you will be able to override" >> $KCFG
> +echo -e "\t  how GCC optimize kernel code. This will create" >> $KCFG
> +echo -e "\t  more debug friendly, but with not guarentee"    >> $KCFG
> +echo -e "\t  about same runi, like production, kernel."      >> $KCFG
> +echo >> $KCFG
> +echo -e "\t  If you say Y here probably You will want say"   >> $KCFG
> +echo -e "\t  for all suboptions" >> $KCFG
> +echo >> $KCFG
> +echo "if ${CFG_PREFIX}" >> $KCFG
> +echo >> $KCFG

Use:

cat > $KCFG <<EOF
...
EOF

through the file (of course, in next runs you'll need to use “>> $KCFG”).
More readable and also “-e” argument to echo is bash-specific.

Alternatively to using “> $KCFG” all the time, you can also do:

	exec 3> Kconfig.debug.optim
	exec 4> Makefile.optim.inc

at the beginning of the script and later use >&3 and >&4, which will save
you some open/close calls and make the strangely named $KCFG and $MKFI
variables no longer needed.

> +
> +echo "# This file was auto generated. It's utility configuration" > $MKFI
> +echo "# Distributed under GPL v2 License" >> $MKFI
> +echo >> $MKFI
> +
> +# Insert standard override optimization level
> +# This is exception, and this value will not be included
> +# in auto generated makefile. Support for this value
> +# is hard coded in main Makefile.
> +echo -e "config ${CFG_PREFIX}_FORCE_O1_LEVEL" >> $KCFG
> +echo -e "\tbool \"Forces -O1 optimization level\"" >> $KCFG
> +echo -e "\t---help---" >> $KCFG
> +echo -e "\t  This will change how GCC optimize code. Code" >> $KCFG
> +echo -e "\t  may be slower and larger but will be more debug" >> $KCFG
> +echo -e "\t  \"friendly\"." >> $KCFG
> +echo >> $KCFG
> +echo -e "\t  In some cases there is low chance that kernel" >> $KCFG
> +echo -e "\t  will run different then normal, reporting or not" >> $KCFG
> +echo -e "\t  some bugs or errors. Refere to GCC manual for" >> $KCFG
> +echo -e "\t  more details." >> $KCFG
> +echo >> $KCFG
> +echo -e "\t  You SHOULD say N here." >> $KCFG
> +echo >> $KCFG
> +
> +for o in $OPTIMIZATIONS_PARAMS ; do
> +	cfg_o="${CFG_PREFIX}_${o//-/_}";

cfg_o=$CFG_PREFIX_$(echo "$o" | tr '[:lower:]-' '[:upper:]_')

> +	echo "Processing param ${o} config variable will be $cfg_o";
> +
> +	# Generate kconfig entry
> +	echo -e "config ${cfg_o}" >> $KCFG
> +	echo -e "\tbool \"Adds $o parameter to gcc invoke line.\"" >> $KCFG
> +	echo -e "\t---help---" >> $KCFG
> +	echo -e "\t  This will change how GCC optimize code. Code" >> $KCFG
> +	echo -e "\t  may be slower and larger but will be more debug" >> $KCFG
> +	echo -e "\t  \"friendly\"." >> $KCFG
> +	echo >> $KCFG
> +	echo -e "\t  In some cases there is low chance that kernel" >> $KCFG
> +	echo -e "\t  will run different then normal, reporting or not" >> $KCFG
> +	echo -e "\t  some bugs or errors. Refere to GCC manual for" >> $KCFG
> +	echo -e "\t  more details." >> $KCFG
> +	echo >> $KCFG
> +	echo -e "\t  You SHOULD say N here." >> $KCFG
> +	echo >> $KCFG
> +
> +	#Generate Make for include
> +	echo "ifdef CONFIG_${cfg_o}" >> $MKFI
> +	echo -e "\tKBUILD_CFLAGS += $o" >> $MKFI
> +	echo "endif" >> $MKFI
> +	echo  >> $MKFI
> +done;
> +echo "endif #${CFG_PREFIX}" >> $KCFG

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +----<email/xmpp: mpn@...gle.com>--------------ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ