Received: by 10.213.65.68 with SMTP id h4csp982310imn; Fri, 6 Apr 2018 12:20:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx49oO3sclYWZF0WV7q55YIHWKck/MX7Z5K2t+X46FXf9K3uRNS+Rnpzagl3F8uF49r1zqYMg X-Received: by 2002:a17:902:6b04:: with SMTP id o4-v6mr10074683plk.332.1523042409885; Fri, 06 Apr 2018 12:20:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523042409; cv=none; d=google.com; s=arc-20160816; b=DUeBoP+NyA78KVMEfKLTx3PtyW0XPRUx4qyMSnFi/YxXgq05Wgh99Ib3WqK8exp5MC pHJYhchkk0xJsUbmz6CncyawjjNYZI2q4a+zpF7NQPJIDUmE1X2IdiAkkUXgtigUBCaS KaRTFyxSJSYGWDxGD9QN7E9a6qSbzRLvzkMXa3eYkKrOfs+dcfODGZB67VJtMSctnjXG ZdD3pqR2i/Q734zYo2nfjUoj2s7YZ9SmhX1jRE4VWURk7LU/eRAHtfCsJkMYVsqpi9Ib SAH1jireI9ANosWy3rfK/ONgRbfHJZh8bDDTJCoyvqCz7FFSLPRRxyxPg5X4MQtDwv9D lQlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :references:subject:cc:to:from:date:user-agent:message-id :dmarc-filter:arc-authentication-results; bh=p/hCyLGs1P9Ko9wMFH2RpcNJjqvlMGc89f+wmnWfr2E=; b=tju6Z3H3B/m6rO9I4Wx6iye60RFqbJk4ON4uOeVvi5Q/XmbxYq7zji1bE+kUybBHNj KzfCHbhP1C2Kly1SpizNowG95FSkVbd2SlsbSZj87Yhku7yvGvpStZ6cVDJVP8IJEQm3 rK4HJmZyB0xImMoRPc67g4kBRU6UhaIkTd3O8FXk4OyfBkaUovRNaqCLVuyq6iebf25W 6u5DMtZuMQFsaYCLeYtcQ/+ZpKKv3koOb3J0lg9dDkEwZEh6H4yWH/NukVpJcfYAAxAN F+PJE/mg+F9b++AvFsLQZpmIPj5kX/bSF7N0huzN1yuj3rItIMksfMcVY104fND9GoAh KW8g== 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 s9-v6si8736510plr.493.2018.04.06.12.19.32; Fri, 06 Apr 2018 12:20:09 -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; 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 S1752171AbeDFTOo (ORCPT + 99 others); Fri, 6 Apr 2018 15:14:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:47132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751482AbeDFTNh (ORCPT ); Fri, 6 Apr 2018 15:13:37 -0400 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7976521834; Fri, 6 Apr 2018 19:13:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7976521834 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Received: from rostedt by gandalf.local.home with local (Exim 4.90) (envelope-from ) id 1f4Wnm-0001Fz-Eh; Fri, 06 Apr 2018 15:13:34 -0400 Message-Id: <20180406191334.357550809@goodmis.org> User-Agent: quilt/0.63-1 Date: Fri, 06 Apr 2018 15:08:57 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Andrew Morton , Frederic Weisbecker , Thomas Gleixner , Peter Zijlstra , "Joel Fernandes (Google)" Subject: [PATCH 3/4 v2] init, tracing: Have printk come through the trace events for initcall_debug References: <20180406190854.875810797@goodmis.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=0003-init-tracing-Have-printk-come-through-the-trace-even.patch Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Steven Rostedt (VMware)" With trace events set before and after the initcall function calls, instead of having a separate routine for printing out the initcalls when initcall_debug is specified on the kernel command line, have the code register a callback to the tracepoints where the initcall trace events are. This removes the need for having a separate function to do the initcalls as the tracepoint callbacks can handle the printk. It also includes other initcalls that are not called by the do_one_initcall() which includes console and security initcalls. Signed-off-by: Steven Rostedt (VMware) --- init/main.c | 51 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/init/main.c b/init/main.c index 2af8f2bb5ca8..589d1226016e 100644 --- a/init/main.c +++ b/init/main.c @@ -494,6 +494,10 @@ void __init __weak thread_stack_cache_init(void) void __init __weak mem_encrypt_init(void) { } +bool initcall_debug; +core_param(initcall_debug, initcall_debug, bool, 0644); +static void __init initcall_debug_enable(void); + /* * Set up kernel memory allocators */ @@ -615,6 +619,9 @@ asmlinkage __visible void __init start_kernel(void) /* Trace events are available after this */ trace_init(); + if (initcall_debug) + initcall_debug_enable(); + context_tracking_init(); /* init some links before init_ISA_irqs() */ early_irq_init(); @@ -731,9 +738,6 @@ static void __init do_ctors(void) #endif } -bool initcall_debug; -core_param(initcall_debug, initcall_debug, bool, 0644); - #ifdef CONFIG_KALLSYMS struct blacklist_entry { struct list_head next; @@ -803,38 +807,53 @@ static bool __init_or_module initcall_blacklisted(initcall_t fn) #endif __setup("initcall_blacklist=", initcall_blacklist); -static int __init_or_module do_one_initcall_debug(initcall_t fn) +static __init_or_module void +trace_initcall_start_cb(void *data, initcall_t fn) { - ktime_t calltime, delta, rettime; - unsigned long long duration; - int ret; + ktime_t *calltime = (ktime_t *)data; printk(KERN_DEBUG "calling %pF @ %i\n", fn, task_pid_nr(current)); - calltime = ktime_get(); - ret = fn(); + *calltime = ktime_get(); +} + +static __init_or_module void +trace_initcall_finish_cb(void *data, initcall_t fn, int ret) +{ + ktime_t *calltime = (ktime_t *)data; + ktime_t delta, rettime; + unsigned long long duration; + rettime = ktime_get(); - delta = ktime_sub(rettime, calltime); + delta = ktime_sub(rettime, *calltime); duration = (unsigned long long) ktime_to_ns(delta) >> 10; printk(KERN_DEBUG "initcall %pF returned %d after %lld usecs\n", fn, ret, duration); +} - return ret; +static ktime_t initcall_calltime; + +static void __init initcall_debug_enable(void) +{ + int ret; + + ret = register_trace_initcall_start(trace_initcall_start_cb, + &initcall_calltime); + ret |= register_trace_initcall_finish(trace_initcall_finish_cb, + &initcall_calltime); + WARN(ret, "Failed to register initcall tracepoints\n"); } int __init_or_module do_one_initcall(initcall_t fn) { int count = preempt_count(); - int ret; char msgbuf[64]; + int ret; if (initcall_blacklisted(fn)) return -EPERM; trace_initcall_start(fn); - if (initcall_debug) - ret = do_one_initcall_debug(fn); - else - ret = fn(); + ret = fn(); trace_initcall_finish(fn, ret); msgbuf[0] = 0; -- 2.15.1