Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751645AbbEYIEb (ORCPT ); Mon, 25 May 2015 04:04:31 -0400 Received: from cantor2.suse.de ([195.135.220.15]:41230 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750971AbbEYIE0 (ORCPT ); Mon, 25 May 2015 04:04:26 -0400 Message-ID: <5562D788.9000201@suse.cz> Date: Mon, 25 May 2015 10:04:24 +0200 From: =?UTF-8?B?TWFydGluIExpxaFrYQ==?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Ingo Molnar , Arnaldo Carvalho de Melo CC: linux-kernel@vger.kernel.org, Ingo Molnar , Paul Mackerras , Peter Zijlstra Subject: Re: [PATCH] perf: fix wrong DEBUG configuration References: <555B3D6F.6000301@suse.cz> <20150519140422.GJ13946@kernel.org> <555C871B.90900@suse.cz> <20150520131748.GC2955@kernel.org> <555C8C41.1080608@suse.cz> <20150520135333.GE2955@kernel.org> <20150520145506.GA15679@gmail.com> <555CB373.7090007@suse.cz> <20150521150536.GB13933@kernel.org> <20150522070250.GA30715@gmail.com> In-Reply-To: <20150522070250.GA30715@gmail.com> Content-Type: multipart/mixed; boundary="------------080903050701000304090303" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5869 Lines: 177 This is a multi-part message in MIME format. --------------080903050701000304090303 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 05/22/2015 09:02 AM, Ingo Molnar wrote: > > * Arnaldo Carvalho de Melo wrote: > >> Em Wed, May 20, 2015 at 06:16:51PM +0200, Martin Liška escreveu: >>> On 05/20/2015 04:55 PM, Ingo Molnar wrote: >>>> * Arnaldo Carvalho de Melo wrote: >>>>> So the rule has been: What are the kernel requirements for the >>>>> toolchain? tools/perf/ should build with that. >>>> >>>> So we could use -Og if it works, like Kbuild does it: >>>> >>>> KBUILD_CFLAGS += $(call cc-option,-mno-fp-ret-in-387) >>>> >>>> the 'cc-option' Make function does some magic of silently calling GCC >>>> with that option and observing the result. >> >>>> See: >> >>>> scripts/Kbuild.include:cc-option = $(call try-run,\ >> >>> I am sorry, I did mistake in understanding of DEBUG variable. >>> Following patch should be fixed, except missing auto-detection >>> of -Og option. >>> >>> Unfortunately, following hunk does not work, no -Ox is added to CFLAGS? >>> >>> -- CFLAGS += -Og >>> ++ CFLAGS += $(call cc-option,-Og,-O0) >> >> I don't know if we have this cc-option, perhaps Ingo is suggesting >> we get it in tools/build/? Or include scripts/Kbuild.include and >> then use it? >> >> I.e. we have checks to see if we can use, for instance >> -fstack-protector-all, see tools/build/feature/Makefile, using this >> cc-option thing, importing it from Kbuild would solve the issue at >> hand in a definitive way and in line with what we have been >> pursuing: to make the tools/ build system be based on Kbuild. > > So I'd suggest copying any necessary functions instead of outright > including all of Kbuild in the tooling build system which creates > non-trivial dependencies that is not necessarily tested as thoroughly > on the kbuild side as on the tooling side. > > Thanks, > > Ingo > Hi. Thanks for advice, I copied necessary functions to include/utilities.mak. Following patch works for, tested both with a compiler capable of -Og and a not capable one. Thanks, Martin --------------080903050701000304090303 Content-Type: text/x-patch; name="0001-perf-fix-wrong-DEBUG-configuration-v4.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-perf-fix-wrong-DEBUG-configuration-v4.patch" Currently, GCC optimizes -O6 same as -O3 level, thus change the value to -O6. Right optimize debugging experience is given by passing -Og to compiler. Assign default value for pointers that are identified by compiler as non-initialized. Signed-off-by: Martin Liska --- 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 --------------080903050701000304090303-- -- 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/