From patchwork Thu Oct 27 08:53:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Shuai X-Patchwork-Id: 11668 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp115687wru; Thu, 27 Oct 2022 02:03:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6KnRC67t29Myemdp2OQqG74mPxm5CP6/qfrMaPwm7bKLVkUtg5i9sP/L39/3YxLhQ92Cb6 X-Received: by 2002:aa7:ccd2:0:b0:462:73bd:3acb with SMTP id y18-20020aa7ccd2000000b0046273bd3acbmr5436134edt.378.1666861403320; Thu, 27 Oct 2022 02:03:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666861403; cv=none; d=google.com; s=arc-20160816; b=u5n008PmM1SQNQFvQSncFU2VFOQjP2PSd9GDh+djszF0Mf54NSzTx7nDg2SNYKXhli yYHrsS5QxNtg035WRnEDXEHsLT5Rw5EF5r/JtJSCWILJOsGGhu3BAfAUzgHLQv4ld2UQ Mw1+crl/o5W+YM9/o5Rr04I39Hjb9PkSv6/JbwGR6sn1dleDsZiF9pfi6EwxSf7jdMFA ClUTiBJ2uwwqCYVKFWXpipymKpchrZCkNJzMOKV1E/FxIhTUGkVyUlEIGAix4SStAaB6 PbaI+dHzIa9RHa2M+3TwRWYzazUAgLxIaLvaM2cgRSYzqslrSg1+8KFcxNbZOB/J3aik 0BAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=rxILUEhhuIRRDXNGGTClKXs5A57MKkYLhJBHPtEVeMk=; b=tlYUNdHEZkspWDxh3Ncr48ZQ2zl0XAUko2YC0Go2uhLcrHGWJyzdqaJedvDzKzIyBf GeT9V4KCFyd+AF+IsECF1TT9YHFeVWdgZEXRgYyp7zAGs//XJQ9FCLXW4IqtDS+DclJ4 5Rus4Y5nG33BpjcE20v9w6XZ3sTp7qyPpnWE5OOzlF/8x9Nc9cG28rTsoVMrt6htyIo9 lTTLihUM5wYnvgcb7yQlcKv2zN23YwGaG0LnzcwLAUkf5F5BcDRXlPOvG86eO3MoC2iJ NhgZdofmamo+/4VT+WpHtwc4t2VXHEhBk8+gp/57oUF8NQks0c8BKfKnUO/xqqOttmFw /eQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZYH3ZRbJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o10-20020a170906974a00b0072ef52514f6si1069692ejy.629.2022.10.27.02.02.58; Thu, 27 Oct 2022 02:03:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZYH3ZRbJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234748AbiJ0Ixy (ORCPT + 99 others); Thu, 27 Oct 2022 04:53:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233295AbiJ0Ixw (ORCPT ); Thu, 27 Oct 2022 04:53:52 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4903F15D0AA for ; Thu, 27 Oct 2022 01:53:52 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id r61-20020a17090a43c300b00212f4e9cccdso5608899pjg.5 for ; Thu, 27 Oct 2022 01:53:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=rxILUEhhuIRRDXNGGTClKXs5A57MKkYLhJBHPtEVeMk=; b=ZYH3ZRbJiHV4047FALOjGhndjJy9T8t65dSVQn/JOmOW2sm1HNdoKsxcTrqkqqU7+C VkJHoKNVr43ZIY0pEdWsfzXhUb0CyvZY739xAeDrC+A4wm67MUuVHcV/mhuwCrWrX/8T L4VwIGzT3KGYXTB5mvEjb47ReZSQg4L71Pags/pUwr+Xybpd/Axm/HyOmN758pvna57e OPaieyXaNhxM15T3Jsy2BZ7GZE6JiZpG8/8v4PyD1Ey8bVHqrUutUSB9IVh4ELTx3Ziu IqT9dyugY6GhU7pnNrpiFZlnqoFBUbX0aD6w/5koYBgyrCHXauNG5YADjr45xvSItIyH 5xkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rxILUEhhuIRRDXNGGTClKXs5A57MKkYLhJBHPtEVeMk=; b=UaHbYHe3w6k9sKA6yA4n2bSrAxCWZMKnHeFgTwYTtVRiwr99L3NkQZ8TEW5fl8QR5j 8OFd4vu+KntReXmNvqDv9AVRDU0xie40A4GF8RSueu2qmdoKAUOo+pGbU5dRM0rmpp2c K87c+yuUbTFsioIo+yT5z0SLJHC4iPhAevgrd7BnT6DaZMKoAXNvQj3Gmkiyb6we9d8Z s4uFLlX1mcofZuW2qEWsOESymIZWQfj8mrUhASpzKvrwA6Ue1K24zhRcqJGcqdelGvxZ qc6x2dfcXj82cerHMsGm/UmkEpLoYOr8VX+wPmRGVK8ZaiYEpC4EQ8jNrnoUe6f0yxW4 cTbg== X-Gm-Message-State: ACrzQf10OL6qsdnTNZrmzgSXKlvzgVWsQJOQ2G8M7uBAm7QCGo6nMbW3 L6sf53tJ91Tk1t56eb1ZX3KUZoDVLlpNOQ== X-Received: by 2002:a17:90b:1806:b0:20d:3256:38 with SMTP id lw6-20020a17090b180600b0020d32560038mr8727249pjb.94.1666860831788; Thu, 27 Oct 2022 01:53:51 -0700 (PDT) Received: from localhost.localdomain ([221.226.144.218]) by smtp.gmail.com with ESMTPSA id u1-20020a17090a1d4100b0020dda7efe61sm2314581pju.5.2022.10.27.01.53.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 01:53:51 -0700 (PDT) From: Song Shuai To: rostedt@goodmis.org, mingo@redhat.com Cc: linux-kernel@vger.kernel.org, Song Shuai Subject: [PATCH] ftrace: fix static function tracer not working Date: Thu, 27 Oct 2022 16:53:43 +0800 Message-Id: <20221027085343.2388485-1-suagrfillet@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747830862749430093?= X-GMAIL-MSGID: =?utf-8?q?1747830862749430093?= Setting kernel command line parameter ftrace=function shows nothing on the kernel built with static ftrace. In static ftrace, ftrace_nodyn_init should be executed before initializing tracers. While this commit `dbeafd0d6131` brings the initialization of function tracer forward from core_initcall where ftrace_nodyn_init still remains. This patch puts ftrace_nodyn_init and ftrace_init together and makes function tracer works in static ftrace. Fixes: dbeafd0d6131 ("ftrace: Have function tracing start in early boot up") Signed-off-by: Song Shuai --- include/linux/ftrace.h | 6 ++++++ init/main.c | 1 + kernel/trace/ftrace.c | 4 +--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index 0b61371e287b..4bdab0461b10 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -978,6 +978,12 @@ extern void ftrace_init(void); static inline void ftrace_init(void) { } #endif + +#ifndef CONFIG_FTRACE_MCOUNT_RECORD +extern void ftrace_nodyn_init(void); +#else +static inline void ftrace_nodyn_init(void) { } +#endif /* * Structure that defines an entry function trace. * It's already packed but the attribute "packed" is needed diff --git a/init/main.c b/init/main.c index 91642a4e69be..ebf8136e828a 100644 --- a/init/main.c +++ b/init/main.c @@ -986,6 +986,7 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void) trap_init(); mm_init(); + ftrace_nodyn_init(); ftrace_init(); /* trace_printk can be enabled here */ diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 56b1a42e1937..40325ae575a5 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -7454,12 +7454,10 @@ struct ftrace_ops global_ops = { FTRACE_OPS_FL_PID, }; -static int __init ftrace_nodyn_init(void) +void __init ftrace_nodyn_init(void) { ftrace_enabled = 1; - return 0; } -core_initcall(ftrace_nodyn_init); static inline int ftrace_init_dyn_tracefs(struct dentry *d_tracer) { return 0; } static inline void ftrace_startup_all(int command) { }