Received: by 10.192.165.148 with SMTP id m20csp730335imm; Wed, 2 May 2018 07:57:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZph81cegpKEge1bCMzWDcfReEUbrAmpW7yPU5G57/V9/5i3RDKry12ngaagTS3D+X9LA3n4 X-Received: by 2002:a17:902:5304:: with SMTP id b4-v6mr19941241pli.231.1525273042379; Wed, 02 May 2018 07:57:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525273042; cv=none; d=google.com; s=arc-20160816; b=y9SclK5HQBaDUry5qmmzGHSMScX7Aa61n/cZ/Ao31zNFWoxYTg+4QwXvDLjWrZojvA m1jRkVe46rNmKV9U4RyEhng0uCxacEFi/LqW9N8nii3vHgqaiARF75w8Pi3MQZk1CpeU 7A1JIz6FtXgQJ5Mh8T5qBCXF0OIOcmmrYq3ih5fM4fXpEoaEB3+g/CBB03E31KWQD09K 9cCj55ZOMUm8QrI84EaC0Y/NIT87fzEJR/JkRDmTJJ0b65oG79RwmXue+RM+IDLNUeYH U9peKHutjeS7j0s4vB5b9S9OkxNPmoEIfbMrOR71UOv66QMUHAMpqTXMGiywqPQ2npVT IsoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=19NPrdqJNkUgQxukbW0APvd1CMVYHLciNmQKTlpiGXc=; b=gV4rRuhJJH5XWZsWnjqrBjVN7emlDXFF1+4wiVdyPFmf3k0XISn9QVh8bk833mqe5Z yZ8h4i0vFNWCLgYtZVl44ACmadypoCOYoNReoeI3A0j1X5fWzqpEqv3TjGFP1FiFLPX4 n1GM1x0uSo/KJI7Dwvqxdsv8Aqcz119f0g3AihA+/YlrbRl9cTp+J0/nmOIZjjPQDmeC +/BkbEIGm22vuhgq6AuNnAZPgebWgPFEd4ucopeJR6dXuQIvEO4U98v8ekkwKL2M8Q39 8HwHiq6Jcf3lglr4tG1AuYhY1aRd7C6grN0/cjf5CzMudiyxxJdp0fU9Jo8wzCt9oTAC zo5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=icMySiyp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n4si11389576pfa.66.2018.05.02.07.57.08; Wed, 02 May 2018 07:57:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=icMySiyp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751391AbeEBO4i (ORCPT + 99 others); Wed, 2 May 2018 10:56:38 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:36524 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751371AbeEBO4g (ORCPT ); Wed, 2 May 2018 10:56:36 -0400 Received: by mail-wm0-f67.google.com with SMTP id n10so24871130wmc.1 for ; Wed, 02 May 2018 07:56:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=19NPrdqJNkUgQxukbW0APvd1CMVYHLciNmQKTlpiGXc=; b=icMySiypczABXBtnlc/kIrtKnrGFA3KLAJ4GDphIe6xmxnxqGGySKa4NBAst658Fu7 SAAhsv9rBXXmjX9+dgC2qR1nuiM+dhkRBVvmT7OMMwrICd4FExQOuIoc31JWnWEdSkxL stD83Csbt8KxWiCUZb84Xl/tzAzCmSPry8dNQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=19NPrdqJNkUgQxukbW0APvd1CMVYHLciNmQKTlpiGXc=; b=awl3XpW1u1OkSnsWQ4us+oAWXKhnTA3pepUi/NrOB6H1hbkq9lRGSzvDcewj5wyWE4 RXQrT0jv95ubEUxmtsaE7HA6S1H+rzvFnQYiohRx9i4HHeWL3Bp+aa4WVSZKUZuaKzI5 8MgQVlyosslhmoEvEGWihHaRbwzYPrqg+yxkKBZfJX/lvEMZx8GuxbkLrp6LjfTPJLgp 8QB7duRnAVeuYQGI9KRnaAuB2+EoJ3f0t8w7J1b5dJK4gUgQURGRWz0rYs10x+LESPiS 7uAL7fahqQcYw874E07ev/bPeqWLft98503rwUIQb5ca5kVMB0gfj25z/k/GTNz0nAlB sQZw== X-Gm-Message-State: ALQs6tCe4pVerPByII7/gpXcJTIv1FOi3rW6Iry42SWavipkmFsWzR9z SVXhhSOr5OcIf4hg/nFEm3MOyg== X-Received: by 10.28.144.75 with SMTP id s72mr12238355wmd.85.1525272995006; Wed, 02 May 2018 07:56:35 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id u187sm10780386wmu.46.2018.05.02.07.56.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 02 May 2018 07:56:33 -0700 (PDT) Date: Wed, 2 May 2018 15:56:31 +0100 From: Daniel Thompson To: changbin.du@intel.com Cc: yamada.masahiro@socionext.com, michal.lkml@markovi.net, tglx@linutronix.de, mingo@redhat.com, akpm@linux-foundation.org, rostedt@goodmis.org, rdunlap@infradead.org, x86@kernel.org, lgirdwood@gmail.com, broonie@kernel.org, arnd@arndb.de, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Subject: Re: [PATCH v2 0/5] kernel hacking: GCC optimization for debug experience (-Og) Message-ID: <20180502145631.bzfqpw4izlrqhda6@holly.lan> References: <1525268700-10631-1-git-send-email-changbin.du@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1525268700-10631-1-git-send-email-changbin.du@intel.com> User-Agent: NeoMutt/20180323 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 02, 2018 at 09:44:55PM +0800, changbin.du@intel.com wrote: > From: Changbin Du > > Hi all, > I know some kernel developers was searching for a method to dissable GCC > optimizations, probably they want to apply GCC '-O0' option. But since Linux > kernel replys on GCC optimization to remove some dead code, so '-O0' just > breaks the build. They do need this because they want to debug kernel with > qemu, simics, kgtp or kgdb. > > Thanks for the GCC '-Og' optimization level introduced in GCC 4.8, which > offers a reasonable level of optimization while maintaining fast compilation > and a good debugging experience. It is similar to '-O1' while perfer keeping > debug ability over runtime speed. With '-Og', we can build a kernel with > better debug ability and little performance drop after some simple change. > > In this series, firstly introduce a new config CONFIG_NO_AUTO_INLINE after two > fixes for this new option. With this option, only functions explicitly marked > with "inline" will be inlined. This will allow the function tracer to trace > more functions because it only traces functions that the compiler has not > inlined. > > Then introduce new config CONFIG_DEBUG_EXPERIENCE which apply '-Og' > optimization level for whole kernel, with a simple fix in fix_to_virt(). > Currently this option is only tested on a QEMU gust and it works fine. > > > Comparison of vmlinux size: a bit smaller. > > w/o CONFIG_DEBUG_EXPERIENCE > $ size vmlinux > text data bss dec hex filename > 22665554 9709674 2920908 35296136 21a9388 vmlinux > > w/ CONFIG_DEBUG_EXPERIENCE > $ size vmlinux > text data bss dec hex filename > 21499032 10102758 2920908 34522698 20ec64a vmlinux > > > Comparison of system performance: a bit drop (~6%). > This benchmark of kernel compilation is suggested by Ingo Molnar. > https://lkml.org/lkml/2018/5/2/74 In my mind was the opposite question. When running on the same kernel does a kernel whose config contains CONFIG_DEBUG_EXPERIENCE build faster than one without (due to the disabled optimization passes). To be honest this is more curiosity than a review comment though... if you have the figures please share, if not then don't sweat it on my account! Daniel. > > Preparation: Set cpufreq to 'performance'. > for ((cpu=0; cpu<120; cpu++)); do > G=/sys/devices/system/cpu/cpu$cpu/cpufreq/scaling_governor > [ -f $G ] && echo performance > $G > done > > w/o CONFIG_DEBUG_EXPERIENCE > $ perf stat --repeat 5 --null --pre '\ > cp -a kernel ../kernel.copy.$(date +%s); \ > rm -rf *; \ > git checkout .; \ > echo 1 > /proc/sys/vm/drop_caches; \ > find ../kernel* -type f | xargs cat >/dev/null; \ > make -j kernel >/dev/null; \ > make clean >/dev/null 2>&1; \ > sync '\ > \ > make -j8 >/dev/null > > Performance counter stats for 'make -j8' (5 runs): > > 219.764246652 seconds time elapsed ( +- 0.78% ) > > w/ CONFIG_DEBUG_EXPERIENCE > $ perf stat --repeat 5 --null --pre '\ > cp -a kernel ../kernel.copy.$(date +%s); \ > rm -rf *; \ > git checkout .; \ > echo 1 > /proc/sys/vm/drop_caches; \ > find ../kernel* -type f | xargs cat >/dev/null; \ > make -j kernel >/dev/null; \ > make clean >/dev/null 2>&1; \ > sync '\ > \ > make -j8 >/dev/null > > Performance counter stats for 'make -j8' (5 runs): > > 233.574187771 seconds time elapsed ( +- 0.19% ) > > Changbin Du (5): > x86/mm: surround level4_kernel_pgt with #ifdef > CONFIG_X86_5LEVEL...#endif > regulator: add dummy function of_find_regulator_by_node > kernel hacking: new config NO_AUTO_INLINE to disable compiler > auto-inline optimizations > kernel hacking: new config DEBUG_EXPERIENCE to apply GCC -Og > optimization > asm-generic: fix build error in fix_to_virt with > CONFIG_DEBUG_EXPERIENCE > > Makefile | 10 ++++++++++ > arch/x86/include/asm/pgtable_64.h | 2 ++ > arch/x86/kernel/head64.c | 13 ++++++------- > drivers/regulator/internal.h | 9 +++++++-- > include/asm-generic/fixmap.h | 3 ++- > include/linux/compiler-gcc.h | 2 +- > include/linux/compiler.h | 2 +- > lib/Kconfig.debug | 39 +++++++++++++++++++++++++++++++++++++++ > 8 files changed, 68 insertions(+), 12 deletions(-) > > -- > 2.7.4 >