linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: Ingo Molnar <mingo@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
	Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: Re: [PATCH] perf: fix wrong DEBUG configuration
Date: Mon, 25 May 2015 13:04:51 +0200	[thread overview]
Message-ID: <556301D3.5040100@suse.cz> (raw)
In-Reply-To: <20150525104708.GB30252@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1506 bytes --]

On 05/25/2015 12:47 PM, Ingo Molnar wrote:
>
> * Martin Liška <mliska@suse.cz> wrote:
>
>> Currently, GCC optimizes -O6 same as -O3 level, thus change the value
>> to -O6.
>
> s/to -O6
>    to -O3
>
>> Right optimize debugging experience is given by passing -Og to
>> compiler. Assign default value for pointers that are identified by
>> compiler as non-initialized.
>
> s/Right optimize debugging experience is given/
>    Correct debugging experience is given/
>
> s/identified by compiler
>    identified by the compiler
>
>>   ifeq ($(DEBUG),0)
>> -  CFLAGS += -O6
>> +  CFLAGS += -O3
>> +else
>> +  CFLAGS += $(call cc-option,-Og,-O0)
>>   endif
>
>> +# try-run
>> +# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
>> +# Exit code chooses option. "$$TMP" is can be used as temporary file and
>> +# is automatically cleaned up.
>> +try-run = $(shell set -e;		\
>> +	TMP="$(TMPOUT).$$$$.tmp";	\
>> +	TMPO="$(TMPOUT).$$$$.o";	\
>> +	if ($(1)) >/dev/null 2>&1;	\
>> +	then echo "$(2)";		\
>> +	else echo "$(3)";		\
>> +	fi;				\
>> +	rm -f "$$TMP" "$$TMPO")
>> +
>> +# cc-option
>> +# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
>> +
>> +cc-option = $(call try-run,\
>> +	$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
>
> Looks good to me!
>
> Acked-by: Ingo Molnar <mingo@kernel.org>
>
> Thanks,
>
> 	Ingo
>

Thank you for review.

This is final version of the patch, where I appended your acknowledgment.

Martin

[-- Attachment #2: 0001-perf-fix-wrong-DEBUG-configuration-v5.patch --]
[-- Type: text/x-patch, Size: 3196 bytes --]

Currently, GCC optimizes -O6 same as -O3 level, thus change the value
to -O3.
Right debugging experience is given by passing -Og to compiler.
Assign default value for pointers that are identified by the compiler as
non-initialized.

Signed-off-by: Martin Liska <mliska@suse.cz>
Acked-by: Ingo Molnar <mingo@kernel.org>
---
 tools/perf/arch/common.c            |  2 +-
 tools/perf/config/Makefile          |  4 +++-
 tools/perf/config/utilities.mak     | 19 +++++++++++++++++++
 tools/perf/util/symbol.c            |  2 +-
 tools/perf/util/trace-event-parse.c |  2 +-
 5 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c
index 49776f1..b7bb42c 100644
--- a/tools/perf/arch/common.c
+++ b/tools/perf/arch/common.c
@@ -61,7 +61,7 @@ const char *const mips_triplets[] = {
 static bool lookup_path(char *name)
 {
 	bool found = false;
-	char *path, *tmp;
+	char *path, *tmp = NULL;
 	char buf[PATH_MAX];
 	char *env = getenv("PATH");
 
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index e3b3724..47e4ae1 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -129,7 +129,9 @@ ifndef DEBUG
 endif
 
 ifeq ($(DEBUG),0)
-  CFLAGS += -O6
+  CFLAGS += -O3
+else
+  CFLAGS += $(call cc-option,-Og,-O0)
 endif
 
 ifdef PARSER_DEBUG
diff --git a/tools/perf/config/utilities.mak b/tools/perf/config/utilities.mak
index c16ce83..0ebef09 100644
--- a/tools/perf/config/utilities.mak
+++ b/tools/perf/config/utilities.mak
@@ -177,3 +177,22 @@ $(if $($(1)),$(call _ge_attempt,$($(1)),$(1)),$(call _ge_attempt,$(2)))
 endef
 _ge_attempt = $(if $(get-executable),$(get-executable),$(call _gea_err,$(2)))
 _gea_err  = $(if $(1),$(error Please set '$(1)' appropriately))
+
+# try-run
+# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
+# Exit code chooses option. "$$TMP" is can be used as temporary file and
+# is automatically cleaned up.
+try-run = $(shell set -e;		\
+	TMP="$(TMPOUT).$$$$.tmp";	\
+	TMPO="$(TMPOUT).$$$$.o";	\
+	if ($(1)) >/dev/null 2>&1;	\
+	then echo "$(2)";		\
+	else echo "$(3)";		\
+	fi;				\
+	rm -f "$$TMP" "$$TMPO")
+
+# cc-option
+# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
+
+cc-option = $(call try-run,\
+	$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 82a31fd..a19fbd4 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -400,7 +400,7 @@ static struct symbol *symbols__find_by_name(struct rb_root *symbols,
 					    const char *name)
 {
 	struct rb_node *n;
-	struct symbol_name_rb_node *s;
+	struct symbol_name_rb_node *s = NULL;
 
 	if (symbols == NULL)
 		return NULL;
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 25d6c73..d495741 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -173,7 +173,7 @@ void parse_ftrace_printk(struct pevent *pevent,
 	char *line;
 	char *next = NULL;
 	char *addr_str;
-	char *fmt;
+	char *fmt = NULL;
 
 	line = strtok_r(file, "\n", &next);
 	while (line) {
-- 
2.1.4


  reply	other threads:[~2015-05-25 11:04 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-19 13:41 [PATCH] perf: fix wrong DEBUG configuration Martin Liška
2015-05-19 14:04 ` Arnaldo Carvalho de Melo
2015-05-20 13:07   ` Martin Liška
2015-05-20 13:17     ` Arnaldo Carvalho de Melo
2015-05-20 13:29       ` Martin Liška
2015-05-20 13:53         ` Arnaldo Carvalho de Melo
2015-05-20 14:55           ` Ingo Molnar
2015-05-20 16:16             ` Martin Liška
2015-05-21 15:05               ` Arnaldo Carvalho de Melo
2015-05-22  7:02                 ` Ingo Molnar
2015-05-22 13:50                   ` Martin Liška
2015-05-25  8:04                   ` Martin Liška
2015-05-25 10:47                     ` Ingo Molnar
2015-05-25 11:04                       ` Martin Liška [this message]
2015-05-25 11:09                         ` Ingo Molnar
2015-05-25 11:12                           ` Martin Liška
2015-05-25 13:52                             ` Arnaldo Carvalho de Melo
2015-05-25 18:32                               ` Ingo Molnar
2015-05-26  9:13                                 ` Martin Liška
2015-05-26 14:36                                   ` Arnaldo Carvalho de Melo
2015-05-26 15:22                                     ` Arnaldo Carvalho de Melo
2015-05-26 15:39                                       ` Martin Liška
2015-05-26 15:48                                     ` Martin Liška
2015-05-26 15:53                                       ` Arnaldo Carvalho de Melo
2015-05-27 16:51                                   ` [tip:perf/core] perf tools: Assign default value for some pointers tip-bot for Martin Liška
2015-05-27 16:51                                   ` [tip:perf/core] perf tools: Improve setting of gcc debug option tip-bot for Martin Liska

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=556301D3.5040100@suse.cz \
    --to=mliska@suse.cz \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).