From patchwork Sun Oct 28 13:09:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changbin Du X-Patchwork-Id: 10658629 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9D429109C for ; Sun, 28 Oct 2018 13:13:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A314285D1 for ; Sun, 28 Oct 2018 13:13:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C2A5285F0; Sun, 28 Oct 2018 13:13:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 301D0285D1 for ; Sun, 28 Oct 2018 13:13:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=nzdsO8CnzdYJF+pUEZQAPowgX9smZqG58F5U0sSkVSg=; b=JGY7PRP+V5ekivuP7zzo5/3+U6 mMXG+qDdyNnoR3RldW6IWviaC9ErI87VOzG1K3u1U7zd3CzM3C8Fhqwh5tDqhmzoqiPAl7CioivnF 3WT90skH8Q2+9mw/aHNyYewu0asHue4Jrre8/K/jLvOCMv0ficnuzjGVEsjJRAp11X3j9dAlHH3rK aD+SeBxlJL0zkREM6ohYNhskxZBe+JHyI0Zd9OWFOkL5nQK8VQuSZuCqJ978LwShO8RZgHmvxVtYH QLCHgsHNbDzJG6mYX4PXY9aYbVxm8VgVSupzAZtdXDJSIGdiYadD7gclcbWqoS7iclTjAMeY483Ca P9Y7ZhOQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gGksj-0001eZ-Ml; Sun, 28 Oct 2018 13:13:29 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gGkq1-0000Ot-GU for linux-arm-kernel@lists.infradead.org; Sun, 28 Oct 2018 13:10:49 +0000 Received: by mail-pg1-x541.google.com with SMTP id k1-v6so1174814pgq.1 for ; Sun, 28 Oct 2018 06:10:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Z1p1Mx8pgPnws2nPs4SRISeGm4KePLjEigb8toAYrzc=; b=p70glEk2yIucDRr40/8Hr1khRVVKJNRIDH5GYhj9Q0/g7Z+dOkKBVaZDZ98t6IJVCJ PbD7er//t9LHVRYB+C+YEoVZxlBecTg0kl1EW6Twv3wswZJpD8oSpcg+jPxjUdhyJpYh 8NkSxTYPKy8bEh2LBgb6Vcc6HIwzHsPvuBmx6Wwld/2KZ+53cQEzhCRQXA77xVT5pI3P QsbNUdTF83/EGw2ZGg8xiNLqirLreNo6qGh9OX/M6aGnbuyXebaamKkU/aovLXC1AhLF pHUiSumZHFKjHAwx+8wzEmX8XkqwufG1Mj+Qt5FiDDQPLHZ1aSpF/K13FXu5JIkdMUjb mWZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Z1p1Mx8pgPnws2nPs4SRISeGm4KePLjEigb8toAYrzc=; b=UUVSjKqP1QznhPBn03uyd8dcQ7R5O+FJvt4f9qgLRE0/Jvih/AXevqLBjmgWzsdaaS 9vM6opMJBID60Rv9u9GdrQEYRFph+gg2JnnIeBMsRYpFw7iJ2u4bLyH48Ft6RMCkkQcC qtJnxqDYf+IOnwSSe+waeD/W0hdH++kID+7mp1XLiE022uy+fzxBtIGf+b89UVZFqQap PMl9RLyOf+MV40hNIAPCNboTxy37Q1eww/NvvbqNF2u2DCrdBZURN+YI03Q1fcV/+3Fb n5jldb64rMLY3lLl853PuSWa/BJL/V8wgHrDp6QxJTxWWt1B/L4vGWqBq7o/0V7LYIYy JOLA== X-Gm-Message-State: AGRZ1gKIHSxsVMIyzYBIjtWVNzTpMRr9FdfUATvR+SvDaNapXlG79+QE VyutWZScQmbJe+CuGzTSUts= X-Google-Smtp-Source: AJdET5cLbwkXzA9J08vC2kuEb0XRP43sQtDazJtqPYG0V2E1TwCUeCXE6abOHRLPKtZT9JI1faLr9g== X-Received: by 2002:a65:56cc:: with SMTP id w12-v6mr9868447pgs.224.1540732230956; Sun, 28 Oct 2018 06:10:30 -0700 (PDT) Received: from vultr.guest ([2001:19f0:6001:4ff6:5400:1ff:feb7:a195]) by smtp.gmail.com with ESMTPSA id e3-v6sm24520585pgc.71.2018.10.28.06.10.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Oct 2018 06:10:30 -0700 (PDT) From: Changbin Du To: yamada.masahiro@socionext.com, michal.lkml@markovi.net, tglx@linutronix.de, mingo@redhat.com, linux@armlinux.org.uk, akpm@linux-foundation.org, gregkh@linuxfoundation.org Subject: [PATCH v3 2/4] kernel hacking: new config NO_AUTO_INLINE to disable compiler auto-inline optimizations Date: Sun, 28 Oct 2018 13:09:43 +0000 Message-Id: <20181028130945.23581-3-changbin.du@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181028130945.23581-1-changbin.du@gmail.com> References: <20181028130945.23581-1-changbin.du@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181028_061041_545911_8F2957C9 X-CRM114-Status: GOOD ( 12.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kbuild@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, rostedt@goodmis.org, linux-sparse@vger.kernel.org, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org, Changbin Du MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch add a new kernel hacking option NO_AUTO_INLINE. Selecting this option will prevent the compiler from optimizing the kernel by auto-inlining functions not marked with the inline keyword. 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. Signed-off-by: Changbin Du Acked-by: Steven Rostedt (VMware) --- Makefile | 6 ++++++ lib/Kconfig.debug | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Makefile b/Makefile index 7d4ba5196010..04beb822ddfc 100644 --- a/Makefile +++ b/Makefile @@ -749,6 +749,12 @@ KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ $(call cc-option,-fno-var-tracking) endif +ifdef CONFIG_NO_AUTO_INLINE +KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions) \ + $(call cc-option, -fno-inline-small-functions) \ + $(call cc-option, -fno-inline-functions-called-once) +endif + ifdef CONFIG_FUNCTION_TRACER ifdef CONFIG_FTRACE_MCOUNT_RECORD # gcc 5 supports generating the mcount tables directly diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 04adfc3b185e..d50711b41dad 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -211,6 +211,23 @@ config GDB_SCRIPTS instance. See Documentation/dev-tools/gdb-kernel-debugging.rst for further details. +config NO_AUTO_INLINE + bool "Disable compiler auto-inline optimizations" + help + This will prevent the compiler from optimizing the kernel by + auto-inlining functions not marked with the inline keyword. + 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. + + Enabling this function can help debugging a kernel if using + the function tracer. But it can also change how the kernel + works, because inlining functions may change the timing, + which could make it difficult while debugging race conditions. + + If unsure, select N. + config ENABLE_MUST_CHECK bool "Enable __must_check logic" default y