From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2E31C7618F for ; Tue, 16 Jul 2019 14:08:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C7F3D20693 for ; Tue, 16 Jul 2019 14:08:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Hfuvm5HY"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aKYEDpBl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C7F3D20693 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=D4GFsiYAxEoTFSJgq3JRKk9pAXEwCJXVxU/jIYO7HRY=; b=Hfuvm5HYP/ts0h akVzPCMCfvCgP6k1/pn8rTUXg13/IzKQPm1b+juCXraj8w+kEqKGp2AtOCU4BeRX3Dt33D+IqB11i r8CtrJszEvJ8I8fbEXsdk0s1dUeCT3sZo86PN54y1eP4dHKtMITmeUi5CD+BBTDAsMX8DQeCbtYDq eQh02ERIvXF9ZQnzZ8zzmpSeJn5h/cfIQ/RKl5cEk0wZReEpa93F/waWOJUKH0OPOe5ZvrpeyGcrd ESOTPFhbbvmqzeWcPWmI25dILS6qYwXciLyZmcIYcSM5RtQAxx2n2XtSPuNuRgla7JaA8FNmkaEHw OVSKv1z76EhtRtuCKGRA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hnO8B-00089w-LP; Tue, 16 Jul 2019 14:08:35 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hnO87-00088x-Jj for linux-arm-kernel@lists.infradead.org; Tue, 16 Jul 2019 14:08:33 +0000 Received: by mail-pg1-x542.google.com with SMTP id u17so9509313pgi.6 for ; Tue, 16 Jul 2019 07:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=2p5yNB9Fr54gFlTDgHP10Sy9vEwRFeMQvHFiEZuA438=; b=aKYEDpBl++j6Z+a9BhBDhIxY5CbfJ/+EEYObi3h17m/9O4CKQZBGVFubw4N5lG0O1q YRKAVpnuVHVl4o95IGdObu2WBSNTcoW2M2H1F1oRO/OT9ToPmMmyUQ/Pu8b+wTK/T1Xx q10qAI+DCgCA47SjxmPdZv3fPlxlB/0W0gTWV88XNWZ5TVAFnuNyaZ1ZegYV67jN4nLQ 3kczgUENKTNic5f1Kjatpmozpj1co8jj2E5aHO3ohTNA4/hOzP/zCoozh93Z7utHVV8h NFX9QG6Vz7fNu9tRmV2sjcGlZEdwaSQolcJ0IuqI+EWNmwrk9RsTvpPybUo7KfbVIypY GJHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=2p5yNB9Fr54gFlTDgHP10Sy9vEwRFeMQvHFiEZuA438=; b=pEoqdV4I8t7H9KV7mN+UuG0Tq2Y3sJGQvULQELqoIr2lLUL2l3A3Owov23EhtcixVv M5hHZ21rXq0NAAwJF0gWILFj9BJwHUMiz9AW/UrQtLwqTqZ0eqK7bj0Eug00NHcYDQ6G 9cRTCSCt1BiYZJ5NGnb8MnYrU/ul/uuOBexiYlJpNDe/1raFz0BC4uVBOhByNMrSZrM0 xQmb1/IhHPLYJSU4Pp6Ut5lsflRjLDsgWAeNdX8RNFaKgQ5iuWj0IddlGgpTJIEyjmB1 0NB0OlF4QWBc2K5xq7oSzC79mdBUm3ACqQ2SQ9Kn6zunKA90Envltsp23q30fOfaf7uv 04pA== X-Gm-Message-State: APjAAAUsH4gzHMBu+GGuZ7P/GP0rqV8mre/5MkQCOMOTEGC2la87iLuv UkSDR3ZgCDYKmothWx93HMJVnH90uDPOpA== X-Google-Smtp-Source: APXvYqzXpC63Aq383Ig6mtxbu2pKS8pBKp355OE6zLLHJi/TnGO3GwbhnVGRoMB+h1scO6W8iCKeXA== X-Received: by 2002:a17:90a:9a83:: with SMTP id e3mr36023349pjp.105.1563286109956; Tue, 16 Jul 2019 07:08:29 -0700 (PDT) Received: from mail.google.com ([149.28.153.17]) by smtp.gmail.com with ESMTPSA id c23sm12665035pgj.62.2019.07.16.07.08.22 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 16 Jul 2019 07:08:29 -0700 (PDT) Date: Tue, 16 Jul 2019 22:08:18 +0800 From: Changbin Du To: Peter Zijlstra Subject: Re: [PATCH] tracing/fgraph: support recording function return values Message-ID: <20190716140817.za4rad3hx76efqgp@mail.google.com> References: <20190713121026.11030-1-changbin.du@gmail.com> <20190715082930.uyxn2kklgw4yri5l@willie-the-truck> <20190715101231.GB3419@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190715101231.GB3419@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20180716 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190716_070831_982109_CBA7DFCE X-CRM114-Status: GOOD ( 19.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: corbet@lwn.net, catalin.marinas@arm.com, x86@kernel.org, linux-doc@vger.kernel.org, linux@armlinux.org.uk, rostedt@goodmis.org, linux-kernel@vger.kernel.org, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, tglx@linutronix.de, Will Deacon , linux-arm-kernel@lists.infradead.org, Changbin Du Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jul 15, 2019 at 12:12:31PM +0200, Peter Zijlstra wrote: > On Mon, Jul 15, 2019 at 09:29:30AM +0100, Will Deacon wrote: > > On Sat, Jul 13, 2019 at 08:10:26PM +0800, Changbin Du wrote: > > > This patch adds a new trace option 'funcgraph-retval' and is disabled by > > > default. When this option is enabled, fgraph tracer will show the return > > > value of each function. This is useful to find/analyze a original error > > > source in a call graph. > > > > > > One limitation is that the kernel doesn't know the prototype of functions. > > > So fgraph assumes all functions have a retvalue of type int. You must ignore > > > the value of *void* function. And if the retvalue looks like an error code > > > then both hexadecimal and decimal number are displayed. > > > > This seems like quite a significant drawback and I think it could be pretty > > confusing if you have to filter out bogus return values from the trace. > > > > For example, in your snippet: > > > > > 3) | kvm_vm_ioctl() { > > > 3) | mutex_lock() { > > > 3) | _cond_resched() { > > > 3) 0.234 us | rcu_all_qs(); /* ret=0x80000000 */ > > > 3) 0.704 us | } /* ret=0x0 */ > > > 3) 1.226 us | } /* ret=0x0 */ > > > 3) 0.247 us | mutex_unlock(); /* ret=0xffff8880738ed040 */ > > > > mutex_unlock() is wrongly listed as returning something. > > > > How much of this could be achieved from userspace by placing kretprobes on > > non-void functions instead? > > Alternatively, we can have recordmcount (or objtool) mark all functions > with a return value when the build has DEBUG_INFO on. The dwarves know > the function signature. > We can extend the recordmcount tool to search 'subprogram' tag in the DIE tree. In below example, the 'DW_AT_type' is the type of function pidfd_create(). $ readelf -w kernel/pid.o [...] <1><1b914>: Abbrev Number: 232 (DW_TAG_subprogram) <1b916> DW_AT_name : (indirect string, offset: 0x415e): pidfd_create <1b91a> DW_AT_decl_file : 1 <1b91b> DW_AT_decl_line : 471 <1b91d> DW_AT_decl_column : 12 <1b91e> DW_AT_prototyped : 1 <1b91e> DW_AT_type : <0xcc> <1b922> DW_AT_low_pc : 0x450 <1b92a> DW_AT_high_pc : 0x50 <1b932> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <1b934> DW_AT_GNU_all_call_sites: 1 <1b934> DW_AT_sibling : <0x1b9d9> [...] To that end, we need to introduce libdw library for recordmcount. I will have a try this week. And probably, we can also record the parameters? -- Cheers, Changbin Du _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel