Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3744760imj; Tue, 12 Feb 2019 04:02:27 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib+I8fnw+wJYM68bhXtYEM9G6zgEIUCW4QDAerzL57SpnxdCsd8KxnmpPDMq/9dEfyV1mGZ X-Received: by 2002:aa7:8d51:: with SMTP id s17mr3758304pfe.16.1549972947550; Tue, 12 Feb 2019 04:02:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549972947; cv=none; d=google.com; s=arc-20160816; b=yKRwGUQ6SSa8UpcIvi3ZufHH0k1HnI48V1TJRdP//RYZ/PzNAO0HpxuNCUPW9kOTmq IuH1QnzHpU3LjySponhCoHWOuFoCZsld9NT7vH2BXEclMPOkHJHX2BESWnwx2oF9YZ1S p7EQ9Y6gZ4+heYZxTxRH9kQRcbKataAiuOEjzdVKsABVJIfjY3wk6bW84MLuIaYHdp+g lZCDk7ziVzB4Auw5/V3fzZr02V9UXL4F1ziyoG2U+DLYUbcZ1oMYN0GruLdEjvYUvxhu FieSEJNFI+JVYabBsbGtli08bU7A249zUw/iFoIxMH86wSvS2qSBclioSRYenF0e4BNx KgkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=i2RXVbSuooniRWkR1jpoYhg9TvyoxlKXJUOHrUF2t+4=; b=sV7cgniKFH831GF3pMXidPDlMMVba0tlyLzMIN1BsLNdxnkSawA9bibOwAIeqt3CEO 8NwcdmnR/jI7HRRstbgHbWtW/zjex0a0yKNnGoGKIiWitsxyIwVH9x544VpXT5Ew0t/3 yFw24u1kgsq7oLugjGoe5aZEOhhCB8widHFNED96yr9KW+H/pXm73XbWwy3IGBR2tvgM hxQpsNqTLjsOBhtNTZiyXAvYIC0jd24TX588GCiWC8zHv2kFiwljnLU9LNfH03AIlevK HSgrwo75/i8R9S81qCnjnlkPq5F9+xJqpaR1PZFtRupsWvGXm8lg78Fx12JUOtTjLNFk 3dlg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n20si3657766pgb.195.2019.02.12.04.02.09; Tue, 12 Feb 2019 04:02:27 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728347AbfBLLmM (ORCPT + 99 others); Tue, 12 Feb 2019 06:42:12 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:35706 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726480AbfBLLmM (ORCPT ); Tue, 12 Feb 2019 06:42:12 -0500 X-UUID: e282b5ff1914481abc10a8993419a65d-20190212 X-UUID: e282b5ff1914481abc10a8993419a65d-20190212 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 136087710; Tue, 12 Feb 2019 19:42:02 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs03n2.mediatek.inc (172.21.101.182) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 12 Feb 2019 19:42:00 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 12 Feb 2019 19:42:00 +0800 From: Mars Cheng To: Steven Rostedt CC: CC Hwang , , , , Andress Kuo , Mars Cheng Subject: [PATCH 1/1] tracing: Fix event_trace_printk loss on printk_format. Date: Tue, 12 Feb 2019 19:41:57 +0800 Message-ID: <1549971717-4693-1-git-send-email-mars.cheng@mediatek.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 06594692839B4E64C47D721B1963D00E961641334FFE7C874C63EAD4120692B22000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andress Kuo If fmt on event_trace_printk is not a constant, It means that something not guaranteed, so the compiler optimizes the fmt out, and then the __trace_printk_fmt section is not filled. if __trace_printk_fmt is not filled, the kernel will not allocate the special buffers needed for the event_trace_printk() and then not shown in the file output sys/kernel/debug/tracing/print_formats. Adding a "__used" to the variable in the __trace_printk_fmt section on event_trace_printk() will keep it around, even though it is set to NULL. This will keep the string from being printed in the sys/kernel/debug/tracing/printk_formats section. We can also refer to commit 3debb0a9ddb1 ("tracing: Fix trace_printk() to print when not using bprintk()")that it had similar issue on path of trace_printk(). Signed-off-by: Andress Kuo Signed-off-by: Mars Cheng --- include/linux/trace_events.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h index 8a62731..26bd7c4 100644 --- a/include/linux/trace_events.h +++ b/include/linux/trace_events.h @@ -551,7 +551,7 @@ extern int trace_define_field(struct trace_event_call *call, const char *type, __trace_printk_check_format(fmt, ##args); \ tracing_record_cmdline(current); \ if (__builtin_constant_p(fmt)) { \ - static const char *trace_printk_fmt \ + static const char *trace_printk_fmt __used \ __attribute__((section("__trace_printk_fmt"))) = \ __builtin_constant_p(fmt) ? fmt : NULL; \ \ -- 1.7.9.5