Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp842239imm; Wed, 20 Jun 2018 07:30:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIyCKlW0CIgi6FrUV2Y3Z+uQVkm9shu7nD0fQ3ogDBb8zvC2vK+mzLPIRnL1jKai1UoTQJT X-Received: by 2002:a17:902:ac89:: with SMTP id h9-v6mr24280421plr.311.1529505025215; Wed, 20 Jun 2018 07:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529505025; cv=none; d=google.com; s=arc-20160816; b=p4goYyT90a4ozDiMp9Y/UHJFO/rTNjh2Cy3SK8pATt4dMi5bIKOQOfNrn1c0GDpm8w FQjnDrsErYae1X57P97hIX7HOOCSE4gF18HPRZoVWpOLZXCAGzo0uahLd7KFDgXOCofS 4v0Smu0NhV3/T7R0tgOzOZe4ReeLEW0RVjH5IScBic9OHVO3YxaeZco20Lws/a8pHJB5 ZKTXsfbIY7mDcZxh0XUFiz8LG3wBB+NEo0XsbD2Sqr8CxFoKj9j0l9FZ33CPVZnwcQw8 JJkt3+G0FAvX2cwMNZLaKljGpno0748UurgZcSULl6LIW+RcgYqujUAu24SolupLmwOC hoKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=YiKQhHJ2HpUzmUbfUrlmprYl4iP1FOebCAAMBtY5JuI=; b=IIDGcWuaijmV+EaLYueNCt5Wcv5HPO3QpISATXMWCpq6B7saP/zP8q2vDBPYp+/xYB GqXcjX5/e+O9xbOflfCX8hLDxUtxfArEyzPHJX008rTdubBluivnN2T4TeQcyykZe6vN 6bx3VQZ2ec4qSXFCuG4cboKYmoSJ1fR0EOgEGcAplFmJtr2gQTR4dGYU1cMja+MxAoDn whu4xjAxoNCcruBI0/LTvkW28O5ToP41iV/Y+y674ucxb+yEIY69rF9rpcLxAFLkqxqJ qjZSa60waBV3Nn0oYayfs8JaPlJkqXKRBVlwUOSi0QVPGPoxUQOmhYYaulLftjJCgaKD vg3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nghqM9T+; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10-v6si2414470pfh.119.2018.06.20.07.30.11; Wed, 20 Jun 2018 07:30:25 -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=@kernel.org header.s=default header.b=nghqM9T+; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754185AbeFTO3V (ORCPT + 99 others); Wed, 20 Jun 2018 10:29:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:45880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754131AbeFTO3T (ORCPT ); Wed, 20 Jun 2018 10:29:19 -0400 Received: from mail-io0-f172.google.com (mail-io0-f172.google.com [209.85.223.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A9EF920875; Wed, 20 Jun 2018 14:29:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1529504958; bh=Fs+mO2Ed87m1tVtstPbu/lGb9ID9rfQpyN5j87Iqj0k=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=nghqM9T+22JXbz1uGUzF8veXaE3ZuVRuzCK7kh0SjIkqi0zD+gMj0i1eYZ7r7QW67 cEBUxzVM7C/aGhg6Au0bmoERKMjKbhF5Fu+8N+Qb9BiiCC6ZHHulBr4G/qn9RWrSOh vqfgxuW0RVdvonjomEfDK8RQz/1vQu/biR0Tr2ec= Received: by mail-io0-f172.google.com with SMTP id g22-v6so3631257iob.7; Wed, 20 Jun 2018 07:29:18 -0700 (PDT) X-Gm-Message-State: APt69E2TFjAecwK7GSddEySk4gyMeVYC/gkDaRSaKnQu+XjbtmyrJUCu gN1Yq5WMJOUKiJbL3Jb9t1eETZnMV/GIrnZYbQ== X-Received: by 2002:a5e:9407:: with SMTP id q7-v6mr17891340ioj.268.1529504958087; Wed, 20 Jun 2018 07:29:18 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4f:6403:0:0:0:0:0 with HTTP; Wed, 20 Jun 2018 07:28:57 -0700 (PDT) In-Reply-To: <20180620023903.242758-1-toddpoynor@gmail.com> References: <20180620023903.242758-1-toddpoynor@gmail.com> From: Rob Herring Date: Wed, 20 Jun 2018 08:28:57 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] drivers: base: initcall_debug logs for driver probe times To: Todd Poynor Cc: Frank Rowand , devicetree@vger.kernel.org, Greg Kroah-Hartman , "linux-kernel@vger.kernel.org" , Android Kernel Team , Todd Poynor Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 19, 2018 at 8:39 PM, Todd Poynor wrote: > From: Todd Poynor > > Add initcall_debug logs for each driver device probe call, for example: > > probe of a3800000.ramoops returned after 3007 usecs > > This replaces the previous code added to report times for deferred > probes. It also reports OF platform bus device creates that were > formerly lumped together in a single entry for function > of_platform_default_populate_init, as well as helping to annotate other > initcalls that involve device probing. > > Signed-off-by: Todd Poynor > --- > drivers/base/dd.c | 50 +++++++++++++++++++++++------------------------ > 1 file changed, 24 insertions(+), 26 deletions(-) > > diff --git a/drivers/base/dd.c b/drivers/base/dd.c > index 1435d7281c66..56db446a467a 100644 > --- a/drivers/base/dd.c > +++ b/drivers/base/dd.c > @@ -62,26 +62,6 @@ static bool initcalls_done; > */ > static bool defer_all_probes; > > -/* > - * For initcall_debug, show the deferred probes executed in late_initcall > - * processing. > - */ > -static void deferred_probe_debug(struct device *dev) > -{ > - ktime_t calltime, delta, rettime; > - unsigned long long duration; > - > - printk(KERN_DEBUG "deferred probe %s @ %i\n", dev_name(dev), > - task_pid_nr(current)); > - calltime = ktime_get(); > - bus_probe_device(dev); > - rettime = ktime_get(); > - delta = ktime_sub(rettime, calltime); > - duration = (unsigned long long) ktime_to_ns(delta) >> 10; > - printk(KERN_DEBUG "deferred probe %s returned after %lld usecs\n", > - dev_name(dev), duration); > -} > - > /* > * deferred_probe_work_func() - Retry probing devices in the active list. > */ > @@ -125,11 +105,7 @@ static void deferred_probe_work_func(struct work_struct *work) > device_pm_move_to_tail(dev); > > dev_dbg(dev, "Retrying from deferred list\n"); > - if (initcall_debug && !initcalls_done) > - deferred_probe_debug(dev); > - else > - bus_probe_device(dev); > - > + bus_probe_device(dev); > mutex_lock(&deferred_probe_mutex); > > put_device(dev); > @@ -527,6 +503,25 @@ static int really_probe(struct device *dev, struct device_driver *drv) > return ret; > } > > +/* > + * For initcall_debug, show the driver probe time. > + */ > +static int really_probe_debug(struct device *dev, struct device_driver *drv) > +{ > + ktime_t calltime, delta, rettime; > + unsigned long long duration; Probably should be s64. > + int ret; > + > + calltime = ktime_get(); > + ret = really_probe(dev, drv); > + rettime = ktime_get(); > + delta = ktime_sub(rettime, calltime); > + duration = (unsigned long long) ktime_to_ns(delta) >> 10; Is avoiding a divide really worth optimizing here compared to the flood of messages typically on the serial port? Just use ktime_to_us. Perhaps just get rid of duration and do the conversion in the printk arg. > + printk(KERN_DEBUG "probe of %s returned after %lld usecs\n", > + dev_name(dev), duration); Including the return code here too would be good. > + return ret; > +} > + > /** > * driver_probe_done > * Determine if the probe sequence is finished or not. > @@ -585,7 +580,10 @@ int driver_probe_device(struct device_driver *drv, struct device *dev) > pm_runtime_get_sync(dev->parent); > > pm_runtime_barrier(dev); > - ret = really_probe(dev, drv); > + if (initcall_debug && !initcalls_done) > + ret = really_probe_debug(dev, drv); > + else > + ret = really_probe(dev, drv); > pm_request_idle(dev); > > if (dev->parent) > -- > 2.18.0.rc1.244.gcf134e6275-goog >