Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp819576rdb; Fri, 2 Feb 2024 05:13:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdm1mp/uuylwAFXHZDiWiVB6AaSmk/EWzjgItGMG81B+NE+zHAkUau/WKDIaI5lTk5lGJ+ X-Received: by 2002:a17:906:681:b0:a35:84fa:6d85 with SMTP id u1-20020a170906068100b00a3584fa6d85mr1444053ejb.72.1706879580409; Fri, 02 Feb 2024 05:13:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706879580; cv=pass; d=google.com; s=arc-20160816; b=auUfeMekolA0LS5WPUnV7+ssT73WQHG8KRv7cB6jL1PUh9J8B7YErKfoeibjneNwTq sRuRLiuCYHwPRkmTEWR+NZZRryG4lVl8sv0Hr8zoxBhjvhQtUkoMMXdddA9Mke+OFGyp ee+kYDtA2dFDpQp16IhuMMOfO5EeaXF7NfcXhUUhK+/IfSHx/1LoCafuPMwmJ46pn1NM WiF9taKUsZXsM9j4PweekXincHPxXDJg3szWEosqy7R/OCb3bRjHkMNfO1wAyyynxWpm DOXHbJR5+QIWv1vrdfwL01PZgToiywGN25K8NBzW+4dw4qRmNeE3v5lv6iSV8ch6md+5 vzQQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=Go7hic6sIpmy9mL74HjzpgQtWLqSJVSK82lRbqq/7V8=; fh=t5FVEADQ5JxLrF4txyEHmnfihhvb+flY33BNFyWMYT4=; b=xOveAB92+n1LQdf4JVv5i3BvUqxpd8+DyWOT0cEum8nYmD0tTYC2Rj9qWRDerTIAVb jX/5eI7GEK2DvYnsYDxWJNjeCG2eRg2m2M+1n8IShUm//AqDQxg4PzIXWqvYL+HR4v0k O1sMduvOUZOlXj2onTx3UqPPGZhVJeRSEjNZHwq1U029N8yX5r4HxcWGUO6iwp33iMI9 LzC62Vjl1d8czJsiYdhkE6T6znGollCSN7FZXh1h8x+4/KqjROaK/R1viHzB8lvWffB4 0DD1Q1HgZm3MR9+P+C/TJBpK1yrPbojzJQ28v7OvEXHK1SdHI5inEDVv5F5eUuETLwvh PXDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-49881-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49881-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCUd6OpNst67zegiqowmGH7pSTZuZ2GeqxuT8zPfw/zOg1uzbwnfSjpxoSpDXPwiEcV7HxfRMpgrPX0XAog6urj/lTQu8kliP07oeBu4oA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id j13-20020a170906830d00b00a36481d25desi753408ejx.308.2024.02.02.05.13.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 05:13:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49881-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-49881-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49881-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E69C01F25253 for ; Fri, 2 Feb 2024 13:12:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A2B6A182CA; Fri, 2 Feb 2024 13:12:52 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7131E523F for ; Fri, 2 Feb 2024 13:12:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706879572; cv=none; b=ue0vyU/8OTSfyiiiVdkO6yIiAki/kT+wa79xhHxAZI0DMuus6wHX1f7GTmnFbPuXU9kSJ0Jt6nCGg8PW9OhmOwFjKh64BLEcNME2bsnifXZnZaXXH+kNT7yvtWvxJ0+x4wpkCo13DFxdXtC0NLMKhpUM/ch5piZrJ+6Euy+rq7I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706879572; c=relaxed/simple; bh=2chKkVNyv+a25tr2l19cV9NQvnf2nRozHkVqSiQZ+jo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ChpYTambjPk6wKck+9eWeFpRZjCkr/gOCsKl8zS7xtR9bEKq0IRONbA3b7A/dJaORqt45LN4spJG3wWJ3rugB0vIZkTpFqWtrm/HCMdxv7zLMQEzWgwJIjRVXr/BpFDkFUol+xDrOZEUN7kSTeAt/20/M647CHOsSDNMzMf5NGs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=[127.0.0.1]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1rVtLY-0003u8-4f; Fri, 02 Feb 2024 14:12:44 +0100 Message-ID: <0db9ff92-c643-4559-929b-fb375efab514@pengutronix.de> Date: Fri, 2 Feb 2024 14:12:42 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Boot-time dumping of ftrace fuctiongraph buffer Content-Language: en-US To: "Masami Hiramatsu (Google)" Cc: linux-trace-kernel@vger.kernel.org, "linux-kernel@vger.kernel.org" , Pengutronix Kernel Team References: <20240202150403.7ccc4126dbeaad8bdf77c384@kernel.org> From: Ahmad Fatoum In-Reply-To: <20240202150403.7ccc4126dbeaad8bdf77c384@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: a.fatoum@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Hello Masami-san, On 02.02.24 07:04, Masami Hiramatsu (Google) wrote: > On Thu, 1 Feb 2024 13:21:37 +0100 > Ahmad Fatoum wrote: >> For drivers that don't call dev_err_probe, I find myself sometimes doing printf >> debugging inside the probe function. [snip] >> I would like to replace this with the function graph tracer: >> >> - record the probe function, configured over kernel command line >> (The device indefinitely deferring probe is printed to the console, >> so I know what I am looking for on the next boot) >> >> - Dump the function graph trace >> >> - See if the last call before (non-devm) cleanup is getting a clock, a GPIO, >> a regulator or w/e. > > What kind of information you prints by the printk()? Just littering around some: pr_notice("%s:%d\n", __func__, __LINE__); to find where the probe function exits. > If the target (suspicious driver probe function) is obvious, you can use kprobe > event and tp_printk. Or, even if you don't know, if you are sure which function > is the starting/ending point, you can use bootconfig to record the specific part > of execution in the ring buffer, and dump it as Steve said. > > In Documentation/trace/boottime-trace.rst, there is an example. > ----- > With the trigger action and kprobes, you can trace function-graph while > a function is called. For example, this will trace all function calls in > the pci_proc_init():: > > ftrace { > tracing_on = 0 > tracer = function_graph > event.kprobes { > start_event { > probes = "pci_proc_init" > actions = "traceon" > } > end_event { > probes = "pci_proc_init%return" > actions = "traceoff" > } > } > } I get comparable tracing with the kernel command line, but lacked a way to dump it at boot-time. Sorry should have been clearer. Grepping the kernel source for `ftrace_func_command' lets me think that what I am after might be: end_event { actions = "traceoff", "dump" } I need to try it out. Do you happen to know if the equivalent is possible without bootconfig? Thank you! Ahmad > ----- > > Thank you, > >> >> For this to be maximally useful, I need to configure this not only at boot-time, >> but also dump the ftrace buffer at boot time. Probe deferral can hinder the kernel from >> calling init and providing a shell, where I could read /sys/kernel/tracing/trace. >> >> I found following two mechanisms that looked relevant, but seem not to >> do exactly what I want: >> >> - tp_printk: seems to be related to trace points only and not usable >> for the function graph output >> >> - dump_on_oops: I don't get an Oops if probe deferral times out, but maybe >> one could patch the kernel to check a oops_on_probe_deferral or dump_on_probe_deferral >> kernel command line parameter in deferred_probe_timeout_work_func()? >> >> >> Is there existing support that I am missing? Any input on whether this >> would be a welcome feature to have? >> >> Thanks! >> >> Cheers, >> Ahmad >> >> -- >> Pengutronix e.K. | | >> Steuerwalder Str. 21 | http://www.pengutronix.de/ | >> 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | >> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | >> > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |