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=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 7F1D0C04AB4 for ; Tue, 14 May 2019 17:46:31 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (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 4011120879 for ; Tue, 14 May 2019 17:46:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4011120879 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=vt.edu Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.91) (envelope-from ) id 1hQbVC-0002oJ-Ur; Tue, 14 May 2019 13:46:10 -0400 Received: from omr1.cc.ipv6.vt.edu ([2607:b400:92:8300:0:c6:2117:b0e] helo=omr1.cc.vt.edu) by shelob.surriel.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1hQbVA-0002oD-Js for kernelnewbies@kernelnewbies.org; Tue, 14 May 2019 13:46:08 -0400 Received: from mr4.cc.vt.edu (smtp.ipv6.vt.edu [IPv6:2607:b400:92:9:0:9d:8fcb:4116]) by omr1.cc.vt.edu (8.14.4/8.14.4) with ESMTP id x4EHk7Vd024301 for ; Tue, 14 May 2019 13:46:07 -0400 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by mr4.cc.vt.edu (8.14.7/8.14.7) with ESMTP id x4EHk1qr014196 for ; Tue, 14 May 2019 13:46:06 -0400 Received: by mail-qk1-f197.google.com with SMTP id x23so16674573qka.19 for ; Tue, 14 May 2019 10:46:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:in-reply-to:references :mime-version:content-transfer-encoding:date:message-id; bh=2v6jmrj73o6cTrn9dcicRsd9KYo/n9Fh1ihh42JZntg=; b=OMgNcVowiw0XglEj68F5gqpjHniRR8DBIRgNP6VfJK8YBqL9CCGi37EGeLt4u5MZvd Q3FM2RTVbHeYqmbjWpfvL4Upx+BJgBRRgvEIe2/0SKuuO5ebYnSl0DPVegoBxkyu4bZr 91ELi9wDokCPDMypZXG4U2vFku4+yNv8a2v49T97QOD7z0L/E6VOh5algvMli3+gB84l WS4w5ycVx31jWr3n6alN85yBG2Ejw6lVfYJGmVxVQNg9f9UQRfEoisJZ3gZfYE+GERxE vhhUXY3M0Mi7h7jN23rOOM6+4/Z+RaGhY5obia8kWYp0ZnV9Ln5HlDP4o0hhB+wrftBo vF4Q== X-Gm-Message-State: APjAAAUpe7dazCvi/W3l3O7kxlw71yetnnarUz+bcDmAyWzbn3akB7mz AG+h4KCD2uTEPhKGpLX5tpQVXm8UqP03lTaIviFaMkbDhrowDnbs0tk/A77WETjMcFRg8ff12gZ OX0Hg9ZSekq/bR+90hmpgt6M2OBlIJxW83+tCZ7k= X-Received: by 2002:ae9:ef45:: with SMTP id d66mr29407923qkg.313.1557855961439; Tue, 14 May 2019 10:46:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRNNhFBckxg4yV1codov/HOJXSFMFGVQEHlZBhfZghS3aBSIAUnyqGECZMqpve0TLsqu99wg== X-Received: by 2002:ae9:ef45:: with SMTP id d66mr29407904qkg.313.1557855961170; Tue, 14 May 2019 10:46:01 -0700 (PDT) Received: from turing-police ([2601:5c0:c001:4341::bf6]) by smtp.gmail.com with ESMTPSA id j5sm8961763qtb.30.2019.05.14.10.45.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 May 2019 10:45:59 -0700 (PDT) From: "Valdis Kl=?utf-8?Q?=c4=93?=tnieks" X-Google-Original-From: "Valdis Kl=?utf-8?Q?=c4=93?=tnieks" X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.7+dev To: Pedro Terra Delboni Subject: Re: how to collect information regarding function calls in run time? In-Reply-To: References: Mime-Version: 1.0 Date: Tue, 14 May 2019 13:45:58 -0400 Message-ID: <2216.1557855958@turing-police> Cc: kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============5822741251941808645==" Errors-To: kernelnewbies-bounces@kernelnewbies.org --===============5822741251941808645== Content-Type: multipart/signed; boundary="==_Exmh_1557855957_1872P"; micalg=pgp-sha1; protocol="application/pgp-signature" Content-Transfer-Encoding: 7bit --==_Exmh_1557855957_1872P Content-Type: text/plain; charset=us-ascii On Tue, 14 May 2019 10:55:40 -0300, Pedro Terra Delboni said: > Regarding bpftrace: This seemed like the best option since I could use it > to count frames of the stack with depth 2, allowing me to know precisely > the amount of times each specific call has been made. However, I could not > use it because since I have to probe every function, it would raise an > error related to open file limit. I've tried setting the open file limit to > unlimited, but the command I used to do so said it was impossible, also the > current limit is set to 1048576, so I'm guessing that probing every > function isn't a viable solution. What problem are you trying to solve? If you're trying to count how often *every* function is called, and the fact that one way to do it has an upper limit of a million is a problem, chances are that you haven't figured out what the *question* is yet. Usually, the number of calls isn't that important, the total runtime spent in the function is important. A one-liner inline accessor function that compiles down to 2-3 machine opcodes can be called tens of thousands of times a second and not be noticed. A function that takes milliseconds to complete will be noticed if it's called only a few dozen times a second. If you're trying to figure out how the functions fit together, a static call graph analysis tool to produce a map of what calls what may be what you need. Having said that, a kernel built with gcov or ftrace support will give you the info you need. See kernel/gcove/Kconfig and http://heim.ifi.uio.no/~knuto/kernel/4.14/dev-tools/gcov.html if you want to go that route. Resources for ftrace call counts: http://www.brendangregg.com/blog/2014-07-13/linux-ftrace-function-counting.html https://wiki.linaro.org/KenWerner/Sandbox/ftrace and see section 'function profiler'. Be prepared for your kernel to be quite slow, and have to do a *lot* of data reduction. Note that you'll probably need to run for at least several hours, and of course the function counts will be *very* dependent on what you do - what gets called while I'm doing stuff like writing e-mail is very different from what happens during a kernel compile, and both of those are different from the function counts that happen when I back up my laptop to an external USB disk. (Note I've not *tried* any of the above - this laptop is slow enough as it is :) --==_Exmh_1557855957_1872P Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Comment: Exmh version 2.9.0 11/07/2018 iQIVAwUBXNr+1QdmEQWDXROgAQL5lxAAhIGNHK+lXeWUn7YFhXo4EOdHXcmD1WeX 9ni0ISvgA9m+lgKzgPTn4WUebThPpil9Gv8riDFdmo3wjrjMgik3T9LRA68i90Zz 9rhsWxsH5kWZyty+jMkIRfZGLXWwohal7kM68OpeSBfMZtOBbx3AreFNOTidLofK mwqbPA0uqR6BGtR03c1YX7mrj5We8ByDkcHszecxnX9V//E3vAuCz6MnxsuWfzC2 pMhtuTHJt/jOoiDLhBVe7Sz9S5JtOPFG+Mrwnd7/d9nise6LbX2tSQWpaHPPLUjW Gi2Rxhn7goeyHZO6SZ1PXuJcnxpW+Arsag7709NYwgSblVjeUiulaqfQw9PnZFOy PwTxFGnKNUirewADJ2tnybBSb6PvDmXG6rEScz3AB4laZJaUNyQxiObgl7n8Boid d937L9mIicBK8elel/VCmHXLGNflyfMFLDmodpSfvxd2JClrLsuoCrzafzEjHZvY 0WiwyP24QyWQMcAfz90vWoVMue2nOiBf/VpZLKgXhQY9cGf/bNJDvSQca3MAS2vq 43W+xrzWzdJnJy6qpVw/RmFTIFV7jclIbJzxA3kxGuboAqS8XZNx/9sK9l3I8CO0 1k60lmy6sTXQZT23qjxdX7vbqqPFxzSuKyqbiV+BLTaxS9BX26lRYjPx2p/PmCBo U0Xry4yEDM0= =rwc7 -----END PGP SIGNATURE----- --==_Exmh_1557855957_1872P-- --===============5822741251941808645== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============5822741251941808645==--