From patchwork Thu Dec 15 19:28:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 33804 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp559778wrn; Thu, 15 Dec 2022 11:29:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf6+dPcWbfgD/ZKJregzjcxuxtvgTBfmsbuZ0SsMalHpkSaTFTwObH7oGeN6B3ZJGCh0wpbR X-Received: by 2002:a17:907:a078:b0:7c0:f213:4485 with SMTP id ia24-20020a170907a07800b007c0f2134485mr25545203ejc.73.1671132593553; Thu, 15 Dec 2022 11:29:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671132593; cv=none; d=google.com; s=arc-20160816; b=Kg4n9zLYI1ZZ5Gb5fxW1s3GHCI+Rvi0JXHTsVNz6tKhEPW+7hYU3gr8jqZXK0rjPex /a+U83cfoTnH/nltxXB7On+a3O1CaNUEP7Hb3UVRqjrKlqfXXnluE0f6KeNrc7YiYwWB Kof4lNIpPbznb07RUeQySLLR1+Sj+tdXr9AmExaLW5EBqIdBGmnZgnOQJ6a+4UK/09mz SCJURwAHDwI0WwolYYKx3x27oAYiPzS85buSUldVz/lTpmJfdvEUSzVUByuGJUhw8Hzp mGDxMdWDZwnDtyTutqJsSlfNOvLtQ/moI7Y8b4QsRxWyJ2t63jjFfemM/mMyVSbtiG+J 6MJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=Tcnm4Zq93QUEsGpL/XwELq+tM+TYBnIw8vL4+pn2Juc=; b=O4hPogrlRfjt+rsWG7b/D54QkKUGcDiNlLHyEmWDZ9LyQhhhRc/fqPOQ6qpSdp5V83 YB7283x3ZnhuQ4z/HW3UGDuNXrWVf9utRqUQEnddwdgBXf5QBcwJi9ZzCC3O4jARrg67 wpoG4Z7PhQkyvCxzzYz6FUCMsjzqF9yAbbh51hr1kQSALfIcWVtc9mYp+fwSJNYQ+Zrz XxY8CETjGkne4nnOV0VVqRPPX4+mT//AoYCylJXymYWTjTBlGv0OIvf93q9JftZVWWU1 s4jZdu7M2kuIP+4fUoTn9OHZCKyF7gzborKeBg6EC+gFrX5SWKxhdWddCb3R5zLIqL9J gN8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=djhlXXsB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn21-20020a1709070d1500b007c17b2f6ba7si10146196ejc.1000.2022.12.15.11.29.30; Thu, 15 Dec 2022 11:29:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=djhlXXsB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230060AbiLOT22 (ORCPT + 99 others); Thu, 15 Dec 2022 14:28:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229948AbiLOT2X (ORCPT ); Thu, 15 Dec 2022 14:28:23 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F59947310; Thu, 15 Dec 2022 11:28:22 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id l10so7893plb.8; Thu, 15 Dec 2022 11:28:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Tcnm4Zq93QUEsGpL/XwELq+tM+TYBnIw8vL4+pn2Juc=; b=djhlXXsB0/6QWxwYZIivL1rWWU3Jgt1lnyFA1luTJfnAArtoWBQXRYf1klMZtruE3f 3ZClMW21ekZecQNwH+Y6NcYFgh9TI92hIAqpZNrpg429K0Au152qTR1MQdAlvyn+BLUz 79G4lwNmD66L36k76vbaXmpBebWzkEmCqe3LV57J2F92T7li+nnUpDbzAN9TxmimL14t sv48p2QjfyiOcmK/4hJLULCuDMkWusZeq7xINUt9cb171D6nRZazmcCbupZRx2jrJvfN d9NNtNXPNOhSJYysvE4q7A6A8yGkD9Fa/vm6ZskShaknok0qcMQbyH6RvT3uva532tfF MBrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Tcnm4Zq93QUEsGpL/XwELq+tM+TYBnIw8vL4+pn2Juc=; b=4mzEQnl28/zDW5iMfJKkE250aSISMZxzNV7WAxhaIni0ZQSilhbG+1+T1U9swtOcrf 2odoBT60/4TS1X1gaojLY8jr6TaRZIxyYbJ6yydnqGP12teJPpfZHtOGAVDsoQrMNTB2 Rlu4vV3yKXrWhXENkIOlCQqL0YN3VmKQL3OFajViDk77J0qn2Q1EwcYJWqv3uGsi2fmr X59uK3wpcbKEwdV1sIvLp3HGAAwn6CVrIwG/DQM5eol8ZfL2baDPpKTqmQZwEI0en8hA aB9tIoQeN04BTKIan7wTpn3gBDrIJEBLHryc/8fpIa4Yygv2GxEgUlTmcbgomPne3tFZ cM5Q== X-Gm-Message-State: ANoB5pnMRPew/PajQDzMs1/Z4b80juKOfYHznWOJJAaytlCUrdj3FWna FheUo2ISUAaMeOFUKDf9Z/I= X-Received: by 2002:a17:90a:fe0a:b0:219:8cba:cbbd with SMTP id ck10-20020a17090afe0a00b002198cbacbbdmr30647158pjb.32.1671132501846; Thu, 15 Dec 2022 11:28:21 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:ecc1:3e44:be34:129c]) by smtp.gmail.com with ESMTPSA id ep14-20020a17090ae64e00b00219cf5c3829sm3475129pjb.57.2022.12.15.11.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 11:28:21 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Andi Kleen , Milian Wolff , Leo Yan Subject: [PATCH 1/9] perf srcline: Do not return NULL for srcline Date: Thu, 15 Dec 2022 11:28:09 -0800 Message-Id: <20221215192817.2734573-2-namhyung@kernel.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221215192817.2734573-1-namhyung@kernel.org> References: <20221215192817.2734573-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752309530487838149?= X-GMAIL-MSGID: =?utf-8?q?1752309530487838149?= The code assumes non-NULL srcline value always, let's return the usual SRCLINE_UNKNOWN ("??:0") string instead. Signed-off-by: Namhyung Kim --- tools/perf/util/srcline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c index af468e3bb6fa..5319efb16a5a 100644 --- a/tools/perf/util/srcline.c +++ b/tools/perf/util/srcline.c @@ -716,7 +716,7 @@ char *__get_srcline(struct dso *dso, u64 addr, struct symbol *sym, if (!show_addr) return (show_sym && sym) ? - strndup(sym->name, sym->namelen) : NULL; + strndup(sym->name, sym->namelen) : SRCLINE_UNKNOWN; if (sym) { if (asprintf(&srcline, "%s+%" PRIu64, show_sym ? sym->name : "", From patchwork Thu Dec 15 19:28:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 33803 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp559740wrn; Thu, 15 Dec 2022 11:29:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf4/bHq4NcaiPaxuEZWSiV15rg77loqCAcm2Nk2x0kNMjkbeB30LEyAX2xwYDOdKlaPK3ps+ X-Received: by 2002:a17:907:2b20:b0:7c0:e7a8:bc41 with SMTP id gc32-20020a1709072b2000b007c0e7a8bc41mr20471518ejc.74.1671132588222; Thu, 15 Dec 2022 11:29:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671132588; cv=none; d=google.com; s=arc-20160816; b=LviWGl9ZuJ1d0tD+VI7LbMP2oY1B9dxK2blHdquoYdnmLno9AarO9frDfn/vcCVCpr ExRor242huZFs3nar3BbjPK8aEPnf51ivcrcAR9Yi4B3hf7NF79swHuXPM1mKSwvSYx+ mLPPCF7xeyEUKOqs5SAJeoML/nCBYt+ZhSCWdyXhN9AJMg6HnEnQOPrp6ons2R9nudcU L1xhCKXUOagdegb05K8/UbuV5jS3MIN2pEH1GCTfN0SnvmSlTaGHbdk6EtsqCtV1oniO Rg4KKbT81JipMjEAwKh9VcO40yj+My3434w5pg3MsE6AG/Gz5nF1QT+P7Z4brMgoKN4K e3Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=tipLqS6lnT+NPiZNAnQKxBxZNV4m8p01r3QYvYfozxo=; b=WEk2sLrNQmKitx81GGkY/aOiJajkxfDn2z4wkD5KdFTtxvqUwA85zlyTtX+GlcW9Dq KWsM1LVpglJE9YCthNTvbFFISAgkCk/SiGIFUvlgWDXwnNHIBm8ZlBvyvqiSzvzH1nR7 uSg7iWlTBNRv0NmVser2Kye8QGBTvR3bn/q6ZO8I8jwj9scy/IV/CBv42SkvNfe8ioJ4 +zHic946mDoE6pBYbvYcYdTQd6iyayjAFkMkDZyrxHk9lJo+5QqUbFeZBsAFrrWiAgil IOv0dhVVSv5hePJCjFg8JD7fmbep42aaM0y1yN3yIg8uywnijo5UQ1KYyRjgcI/lOAyT Mxzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=OQnOVTdS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ec15-20020a0564020d4f00b00460ce6c3a1asi108054edb.454.2022.12.15.11.29.25; Thu, 15 Dec 2022 11:29:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=OQnOVTdS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230113AbiLOT2f (ORCPT + 99 others); Thu, 15 Dec 2022 14:28:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229955AbiLOT2Y (ORCPT ); Thu, 15 Dec 2022 14:28:24 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6A1E4AF13; Thu, 15 Dec 2022 11:28:23 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id js9so195289pjb.2; Thu, 15 Dec 2022 11:28:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=tipLqS6lnT+NPiZNAnQKxBxZNV4m8p01r3QYvYfozxo=; b=OQnOVTdSIOnnq3cpTAUZRcQj3kjXX0N3xhDZgDjXC3RAarlzoMtiwDG1g4Q3iHe0Hk HUtW8k7FIWj9dVATdx2xAjLtZXS9odIJ6JSMk7BGooFihyVViCGEWvkWNLwPFPFCHDyF 3koLjxv3dSMRnz3mYaLwsu9bd7OzKo1ORevXHebSpkNVTUPA7CkRk2Uee0nY0p1a+eS2 zUDmeYd2p6RtYOVLiV750h3iXyJ8r6ujriYJkVilBjXkR9VJGJp2so8INGb2BE7isVrN Ly/4zbn/AsO/YXgrScrb+eyB4H+dZbK7MBA5tVbWABHfxqcuZdhiKZ6IzD1s99JHIP1B p7Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=tipLqS6lnT+NPiZNAnQKxBxZNV4m8p01r3QYvYfozxo=; b=LtgXagXAdV6dTC0bVwgPlOGLbAq8jA/jMqyIj9y6JxP3inl9R+KavOl3uYo3AGjG10 PquivvrIqy/z02zrUZONGw/ULqvvmK+n1m3riTUr+VEB4LFMu1MwUONyFu6ThuBUrSq/ O0i4zDuOXkRMQoxqXOs26maLNY9lSZvIw8+doozLrvge5DWYdKZWiCmkOQN6bbOnQJ8J Syjz1eIZWay15qw51sdrLz1wPN3nHBrcIHDBJaTZhaRL8BW4IvHMIU60P+x/LDGu0NoH sR7LU8juxtHWbku6CyGVOBzxJQf3Wai2uvyhJut8XVbVCTtWXQbiny2IiEBKarWV3XI5 1WoA== X-Gm-Message-State: ANoB5pnRV2ZeHG4yZobREcrG8VBoHWgtYY0C5CISPUd3OaFOO/oyfLnG jmtiE4ncHvnZBCSW2JAW86U= X-Received: by 2002:a17:90a:1b45:b0:219:64ca:49a0 with SMTP id q63-20020a17090a1b4500b0021964ca49a0mr29623814pjq.22.1671132503015; Thu, 15 Dec 2022 11:28:23 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:ecc1:3e44:be34:129c]) by smtp.gmail.com with ESMTPSA id ep14-20020a17090ae64e00b00219cf5c3829sm3475129pjb.57.2022.12.15.11.28.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 11:28:22 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Andi Kleen , Milian Wolff , Leo Yan Subject: [PATCH 2/9] perf report: Ignore SIGPIPE for srcline Date: Thu, 15 Dec 2022 11:28:10 -0800 Message-Id: <20221215192817.2734573-3-namhyung@kernel.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221215192817.2734573-1-namhyung@kernel.org> References: <20221215192817.2734573-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752309524802273636?= X-GMAIL-MSGID: =?utf-8?q?1752309524802273636?= It can get SIGPIPE when it uses an external addr2line process and the process was terminated unexpectedly. Let's ignore the signal and move on to the next sample. The sample will get the default srcline value anyway. Signed-off-by: Namhyung Kim --- tools/perf/builtin-report.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 2ee2ecca208e..d98112f173b0 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -949,6 +949,7 @@ static int __cmd_report(struct report *rep) struct perf_data *data = session->data; signal(SIGINT, sig_handler); + signal(SIGPIPE, SIG_IGN); if (rep->cpu_list) { ret = perf_session__cpu_bitmap(session, rep->cpu_list, From patchwork Thu Dec 15 19:28:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 33805 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp559839wrn; Thu, 15 Dec 2022 11:30:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf6h6HpcaDiylUBbQJrTEslCHokUBAttkbzeqrLMjXHm+7P+E+YfTcu8nERrAWkD4MN9g6kc X-Received: by 2002:a17:907:90d4:b0:7c0:db61:dbd5 with SMTP id gk20-20020a17090790d400b007c0db61dbd5mr22095395ejb.62.1671132603005; Thu, 15 Dec 2022 11:30:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671132602; cv=none; d=google.com; s=arc-20160816; b=brnWkp3B7DYjKXwhex5f5J5Jg65+WfoDjnkrzVVpOlou5wfbNYjVpcDxiQ5LFhJ5QE Qr7+1K97e1LhI2yjEVP63/guFmRX3gLGzzpqgjuTGa4iraDEFrPArBNM6Ic2t8bt3GQZ BIGU3RtTiKsVa7ayQgevHePlIt+6eYBA3+artAGgmx146Lo7PuNrXuE6OiwZaOi9iwtl z7uQm+tgd+gaxyi6oJS3A8DhEhvhT5KWQ4CEhN0ZRXGqmrBjQmAeJyVaMpeVjaWRy56j qWSSwRr8ZEJR84MaLLqE74jdzHfvzSa0jBuHFCT0KhfbOGJT9/DJDAAzJ1worz9oJwbb rcdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=yJtu96UaLUbxmrQaw47zeCnhCw3DINxkl6YWOTS0s0A=; b=RbXfk1/+sNhP42a3pTCR4ZRnJL0UUJalRrL6ZF4dBSX1WWqdasgbAcXgkaXCO0InRL WgXiAAZ8KypEwEX80esHeIomPo2kJsIXwPlf+4/QBXP3tLfFYWzj3DI+Z3zTsKFxSbHI YepiYpfckBwp4IBgTUSJOi97P2BgGJl/R/gxNXjIJ0EmK8d62saSY1dPxHI83bTPk2eY xH+n1ydaxvjbz61DLqbT/rKqOBf08k/w6/qTd4hTbWHK+/T1fXBgQa6dXeVl8qqrkVas yuxQPcaUK00Trd7hcuyiUYoW0akhREhCDkdRPanhVbOp1QWHavi5Y/Ran8LiTn96ysZE Y36A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qhgx6fDu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn19-20020a1709070d1300b007c14e98e3a1si13267302ejc.752.2022.12.15.11.29.40; Thu, 15 Dec 2022 11:30:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qhgx6fDu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230223AbiLOT2j (ORCPT + 99 others); Thu, 15 Dec 2022 14:28:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbiLOT2Z (ORCPT ); Thu, 15 Dec 2022 14:28:25 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8EE547310; Thu, 15 Dec 2022 11:28:24 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id v13-20020a17090a6b0d00b00219c3be9830so122588pjj.4; Thu, 15 Dec 2022 11:28:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=yJtu96UaLUbxmrQaw47zeCnhCw3DINxkl6YWOTS0s0A=; b=qhgx6fDuh1uq//jERerz82Du7xXn0/9GhYjPUsjvIF1t/xm7f1Lbka9VnZKKN+VxBp cyKtsGYFN4TR/bn23IlUg/8yMNINkiqCVjUC0AWbQCjaK3ml6Flq8PlNoDgVyXtXkhVq v5acFGQ9D2WjVMuQ8pyeiwCwNIu2TLY7NLgF1tBdxT1kIRhbw5pSJUQDcp6+XnF3HXZH T07wdy/kEZFErte0xjbrzXVZCi1bizWWPc5i1rer5w2FX0Dwcfc3WiMWtmUOmbuRP6AI fFm4oPl7US12fKGCxeoDIX39wk7knGh8K2RPLkvkBu1UjduppoBwc3PYvQaBof4B7kGL UrRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=yJtu96UaLUbxmrQaw47zeCnhCw3DINxkl6YWOTS0s0A=; b=HYocK/IPKds966oN+WWal8IkiBg6pwkfliLGjrCWUaUluwntnkjGx5WbVZOEeqj6Np TIU1AH2kZjgjRavnvPo6i2R9S21VH9vFSWwpSYffI5qpybYGLDvBBUsiGPPAq/ekGzFh vCzq1BISzW8Kr6PCC9vr3m4FX8Qv2VjjVmK000nnvfh21hJ21GOm1ZNnzNCAkNxHkyeq y08XayEgrW56IHtv4Ix+MM4ptYX2FcH1E+aasx7U7QRvh4j0NX89Tbo2LYRxpMh2p61A lMiL155eGRlItg81J0Uzeqzv1CC2IxfM2DDM08uIvX7chSCdx4mOJY7ry1PBR5hleO4e zLIg== X-Gm-Message-State: ANoB5pnm5pFaMd4A7xqYskuoEov8vgC734MbMkEzIwx9A5+9zh1rIsL4 jD89+a3eRPmYFC4erTovRdKnKXY8kT8= X-Received: by 2002:a17:90a:9b0b:b0:219:28b7:c580 with SMTP id f11-20020a17090a9b0b00b0021928b7c580mr29605270pjp.22.1671132504206; Thu, 15 Dec 2022 11:28:24 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:ecc1:3e44:be34:129c]) by smtp.gmail.com with ESMTPSA id ep14-20020a17090ae64e00b00219cf5c3829sm3475129pjb.57.2022.12.15.11.28.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 11:28:23 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Andi Kleen , Milian Wolff , Leo Yan Subject: [PATCH 3/9] perf symbol: Add filename__has_section() Date: Thu, 15 Dec 2022 11:28:11 -0800 Message-Id: <20221215192817.2734573-4-namhyung@kernel.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221215192817.2734573-1-namhyung@kernel.org> References: <20221215192817.2734573-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752309540422973450?= X-GMAIL-MSGID: =?utf-8?q?1752309540422973450?= The filename__has_section() is to check if the given section name is in the binary. It'd be used for checking debug info for srcline. Signed-off-by: Namhyung Kim --- tools/perf/util/symbol-elf.c | 28 ++++++++++++++++++++++++++++ tools/perf/util/symbol-minimal.c | 5 +++++ tools/perf/util/symbol.h | 1 + 3 files changed, 34 insertions(+) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 80345695b136..96767d1b3f1c 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -233,6 +233,34 @@ Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep, return NULL; } +bool filename__has_section(const char *filename, const char *sec) +{ + int fd; + Elf *elf; + GElf_Ehdr ehdr; + GElf_Shdr shdr; + bool found = false; + + fd = open(filename, O_RDONLY); + if (fd < 0) + return false; + + elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL); + if (elf == NULL) + goto out; + + if (gelf_getehdr(elf, &ehdr) == NULL) + goto elf_out; + + found = !!elf_section_by_name(elf, &ehdr, &shdr, sec, NULL); + +elf_out: + elf_end(elf); +out: + close(fd); + return found; +} + static int elf_read_program_header(Elf *elf, u64 vaddr, GElf_Phdr *phdr) { size_t i, phdrnum; diff --git a/tools/perf/util/symbol-minimal.c b/tools/perf/util/symbol-minimal.c index f9eb0bee7f15..de84da3b0d96 100644 --- a/tools/perf/util/symbol-minimal.c +++ b/tools/perf/util/symbol-minimal.c @@ -385,3 +385,8 @@ char *dso__demangle_sym(struct dso *dso __maybe_unused, { return NULL; } + +bool filename__has_section(const char *filename, const char *sec) +{ + return false; +} diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index e297de14184c..f735108c4d4e 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -165,6 +165,7 @@ int modules__parse(const char *filename, void *arg, u64 start, u64 size)); int filename__read_debuglink(const char *filename, char *debuglink, size_t size); +bool filename__has_section(const char *filename, const char *sec); struct perf_env; int symbol__init(struct perf_env *env); From patchwork Thu Dec 15 19:28:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 33806 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp559875wrn; Thu, 15 Dec 2022 11:30:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf6XqSsIp0T4ZIyqKrtzSzlNmNW1tO1n/j68S77lREPydg9UWsxQhq898bCiLYOdBSi/UgTN X-Received: by 2002:a17:906:eb5b:b0:7c0:dd66:e991 with SMTP id mc27-20020a170906eb5b00b007c0dd66e991mr24368939ejb.6.1671132605870; Thu, 15 Dec 2022 11:30:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671132605; cv=none; d=google.com; s=arc-20160816; b=ETn1Fuucl40boUSTT5/LaVdW/P2kus29Yh+JaATwY2s4F0OE2deHLn9FgeT9PnylXS g0VvVcZ3x/5YR29wUDp44hM0hAc+VHqPMEQCu+oKP6ptOLp+uPIF3W6b+VuD0I0NsqZw 7gbpg0mWK+S4KqyzRjZUWwKF7jVr4LkwYnE9dLDxMcagiXTQ6nRIcQH/Qa4Vws1Gn3GL AR73jn8BLq6N90ihVEhpXr2un7rJJQ7ALV/tfLJiK6+9SQtcz6t8RaQlFmvEsA5zThpW oF9fEq6LYgEG/fn5TZDiYOG7Y2g/V5mlAb7ykestXMJzy59WxEpE9Bn7wk7meAcmXw8k wEhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=PmvCh9yWugB6d0aTmM0VqqANfCxzP4Vie55qPJtB7BM=; b=P2+3HGGEAYB7t2U5/4FLzjAFYBdOvFsGbN86Y7cPv5g4QZyGhSDwTRM1Em+ve5bfuR C5zDqtojiTDO8M9h86JgspkVIUKTMnEaAWHxYmJL1C5YyqoplAyMcM61RiWMxbGPI38u /f8KlPNNqOw+1ver2q/doieZMJOTUP970Jhtx4EKmB+SCyRg6Yoo4N4egUPxF+8ZO8Zn vlw7Bjfd1B9npmiflfE4ydUxtPLCoNyNSH8PiLX83p8nxjlNoP8+cz0tra65I5cGVYWI 9nrvPS+vzyQBCtSofkqiv2A6uciAz/0249MGM8+xyfnZS984Pkt5K3YKF+H+S44BhEFA bo0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=CeLAmgOi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sz27-20020a1709078b1b00b007a7d37e4681si13543914ejc.845.2022.12.15.11.29.43; Thu, 15 Dec 2022 11:30:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=CeLAmgOi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230263AbiLOT2o (ORCPT + 99 others); Thu, 15 Dec 2022 14:28:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230024AbiLOT20 (ORCPT ); Thu, 15 Dec 2022 14:28:26 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E015A47310; Thu, 15 Dec 2022 11:28:25 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id d7so1408pll.9; Thu, 15 Dec 2022 11:28:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=PmvCh9yWugB6d0aTmM0VqqANfCxzP4Vie55qPJtB7BM=; b=CeLAmgOiXHIHJn83Qhm5ixy1ObxMdDGRJ4N7S+Zg1RY0kHpTS85+DNblRtc3BhUPZl m1V9YMC5Z+MCEYu1fiNjjpzZUdzLSb6EFz+USZtexhudhKn5jgM8y4qiBM2ZPv4SfMOU gxfgxDlGPbnRBprjU8nBze+xAloxq5caTp+RufjQfwQ0ZJmyQpW4l8HgUczdUwq8nECy K4ZsjIDeNuYH0u11lFU+yyEg5nz3x/r0oUC/Ul0wvhEdyquwGNbHBrawfWC1y/d2uA2x WpH7uEQI1eqQMsrq+ENkq0YwaCxHl37umCz/GaYlXhBRvH7g5A8mfYUlRXMbOYJwQ50m 1Dsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PmvCh9yWugB6d0aTmM0VqqANfCxzP4Vie55qPJtB7BM=; b=uF0KJBtRoNfsnyvNVQXlP9fN58AZvZ7u7ggvPPS8fdSG87UtXKyZinx0VLp5w5rZZj WTrlro+04h49tbm5aBPtVLYXYYFvlyL3i2qJXL+3O8ynpDV3xjUgzPdU7T/UeVoczN2y mWr64fCID/1q2Xt7gt/s1mDuDLqt5WB++JImVzw/IcfapjXddj3m2PZzTcRgEIp1bizV z47QmPKmb/Df0ddtdTt83ZIpx0ceYXzO5W8/Zm2FfhizjIUxfvoIax3879giERUd/RTq YHfV/AFwukExBlnXQquee3Bl/646Riq3hycN+/kRIiY+c/UCiHrCpRIVYw/EQvKcN6P/ cLrw== X-Gm-Message-State: ANoB5plIfaUtXMXQqXaN9mYDdXs/Zc1KQyoJKriNGxmTjz4G33QX7RcT 0sxFcDc4d6Oy5OCrgzH9pV0= X-Received: by 2002:a17:90a:740e:b0:219:78e:9c3c with SMTP id a14-20020a17090a740e00b00219078e9c3cmr30076808pjg.39.1671132505350; Thu, 15 Dec 2022 11:28:25 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:ecc1:3e44:be34:129c]) by smtp.gmail.com with ESMTPSA id ep14-20020a17090ae64e00b00219cf5c3829sm3475129pjb.57.2022.12.15.11.28.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 11:28:25 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Andi Kleen , Milian Wolff , Leo Yan Subject: [PATCH 4/9] perf srcline: Skip srcline if .debug_line is missing Date: Thu, 15 Dec 2022 11:28:12 -0800 Message-Id: <20221215192817.2734573-5-namhyung@kernel.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221215192817.2734573-1-namhyung@kernel.org> References: <20221215192817.2734573-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752309543329681843?= X-GMAIL-MSGID: =?utf-8?q?1752309543329681843?= The srcline info is from the .debug_line section. No need to setup addr2line subprocess if the section is missing. Signed-off-by: Namhyung Kim --- tools/perf/util/srcline.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c index 5319efb16a5a..2c212e2e1b65 100644 --- a/tools/perf/util/srcline.c +++ b/tools/perf/util/srcline.c @@ -550,6 +550,9 @@ static int addr2line(const char *dso_name, u64 addr, size_t inline_count = 0; if (!a2l) { + if (!filename__has_section(dso_name, ".debug_line")) + goto out; + dso->a2l = addr2line_subprocess_init(dso_name); a2l = dso->a2l; } From patchwork Thu Dec 15 19:28:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 33807 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp559940wrn; Thu, 15 Dec 2022 11:30:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf5dyrujRxV4Pv8zkPR3BqXE0mphHmzWTaUEWchX8r4FXZuFkSdGYXIY2yoMLnjI8LsU2Ku0 X-Received: by 2002:a17:907:3ac2:b0:7c1:765:9cfc with SMTP id fi2-20020a1709073ac200b007c107659cfcmr18538964ejc.34.1671132613231; Thu, 15 Dec 2022 11:30:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671132613; cv=none; d=google.com; s=arc-20160816; b=r3FGDgSvn7otMQAinqhL5AMYDIUPDnmxMr8EkRprNgem9wwOEzytfMgXfpOXupl3Rt GZRq6JxmNWp9CSS3DmPPS3lAf5oI/NDS9wFZdiCtBGV9XM4iC1PhYSeJrMRft256r0oD R+EA+3DWP791G3M/TO5u4/0Slj472IfjtBGwzkl+gBz+xnrg4HfSK+EZZZQIgaGwVHuS 562NGN64aFk4MoXgPUiq4c5EvnBjDdC96lqAA3k21fCwJRv4xC+VDCovRRZXilhYX42C k84Vj4dbpyDg+HvIXxiLUv9wRS8YpmpDbizcK9eGfaCSWXphfteIN1Ev85q1d0r6Ass4 qcvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=6mw/wiOLYoXrXq7I0XRVNFT/hMNwNwhuLxRKV5JN7S8=; b=m4V+yepsOlyOsqlgHkizHjy1xkF0DW/HpOdazpMDkxXVPAfHayHTV+uzbKkhS18MeL 0bjlnyzx0OSibuckPY291HvYMaZ3yrxlu4Mpzb8ekR+aNNyedX+8NF3gx+9VjIAwMfmA ml/GjWSAsXYiJVuwYHBjrPIYb+7iwZclbtxygzQrmGFnzbiWKLP4iP2I7yVL01ngUt52 aNMQf2s0AHYfBQ0tDikqk/E8yXj2c7ntQl42+cV0+iMWzqUtcO8w1fhnvCQ7EF7cTXFi 8cTKlSvk1nx4jRq7lqkp/oy/aFcYXfWsbIwlTEb+E9jJop/WycipGcfH7NyVDp23ZRIK Dlww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=e7QSbOZJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sh15-20020a1709076e8f00b007c0f7b5d8e6si24635ejc.2.2022.12.15.11.29.48; Thu, 15 Dec 2022 11:30:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=e7QSbOZJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230296AbiLOT2t (ORCPT + 99 others); Thu, 15 Dec 2022 14:28:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230043AbiLOT21 (ORCPT ); Thu, 15 Dec 2022 14:28:27 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDFFB4AF13; Thu, 15 Dec 2022 11:28:26 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id 4so36692plj.3; Thu, 15 Dec 2022 11:28:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=6mw/wiOLYoXrXq7I0XRVNFT/hMNwNwhuLxRKV5JN7S8=; b=e7QSbOZJCoCBHRDDhIIsWJbh9O3T0nRnBRdCY1f9w67KpjfbuGUtOpHOLjxP6hqaac dVHRLk15l31Q5yvmpjwvPE2wVJFQNpR5r1Pau2VMRwL2agIQ30eoijGfz2FrLucFUleU 6FyV+1QEv4XEegfd3afqrxFOPSFDQYGeJv+e61aVn87uheIWTfEl81h/4XXdK1GMYXeu LUxQvqfbzeN4IZMP8NVP6krYJUetkbq8unNfHi1l2R1y8xAqEC/0I9bzoz0aLEpF2Ege Skut7ltKgXlKfn1Yv/gzUyPL1S5TE/OmISbOLHxi7PHX4unRVqDWW5RbY0EkGr7Riife +Jbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=6mw/wiOLYoXrXq7I0XRVNFT/hMNwNwhuLxRKV5JN7S8=; b=PP1OgpByVecRCN3HWWYZZGKGcyYrUq67Wg72beA59fz1dh1Q6wTOpItV+f7TEx/OJp E0e97tjOTqr9xLib0I78RpRnDpW8Vy91TfqXwA6xFn5eyrKfgX5/ppYLobjAIARu6VbV W34cLl9ifGHIuikvH3g5U+XFEW78/AL4a2JBCuv0Dfizcd2OO9JxjMCUGjIdmFi7pWZs so1iU+6MSHNg7XI6iGYn183k2BdWfZ9DRNNYXAx49asfoULdVqVVa7YOVhyaP/oizLeR gnpM9aTmqwRX0knQMEWIj+CKpvxs3L9lHjb6IAP34A5D5sSvYad4sT0RNEM2wZ2fqW7f WwOg== X-Gm-Message-State: AFqh2krlCAz1kFvKll57HT+UPklzVUSA8D4Uj0X3FaRpdkJ+W0yVfbva oPdOXt4DuDlhvmXcqFtmpbWjHFlLFpc= X-Received: by 2002:a17:90a:d993:b0:223:415d:5441 with SMTP id d19-20020a17090ad99300b00223415d5441mr5235510pjv.21.1671132506485; Thu, 15 Dec 2022 11:28:26 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:ecc1:3e44:be34:129c]) by smtp.gmail.com with ESMTPSA id ep14-20020a17090ae64e00b00219cf5c3829sm3475129pjb.57.2022.12.15.11.28.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 11:28:26 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Andi Kleen , Milian Wolff , Leo Yan Subject: [PATCH 5/9] perf srcline: Conditionally suppress addr2line warnings Date: Thu, 15 Dec 2022 11:28:13 -0800 Message-Id: <20221215192817.2734573-6-namhyung@kernel.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221215192817.2734573-1-namhyung@kernel.org> References: <20221215192817.2734573-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752309551448871208?= X-GMAIL-MSGID: =?utf-8?q?1752309551448871208?= It has symbol_conf.disable_add2line_warn to suppress some warnings. Let's make it consistent with others. Signed-off-by: Namhyung Kim --- tools/perf/util/srcline.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c index 2c212e2e1b65..33321867416b 100644 --- a/tools/perf/util/srcline.c +++ b/tools/perf/util/srcline.c @@ -573,13 +573,15 @@ static int addr2line(const char *dso_name, u64 addr, * "??"/"??:0" lines. */ if (fprintf(a2l->to_child, "%016"PRIx64"\n,\n", addr) < 0 || fflush(a2l->to_child) != 0) { - pr_warning("%s %s: could not send request\n", __func__, dso_name); + if (!symbol_conf.disable_add2line_warn) + pr_warning("%s %s: could not send request\n", __func__, dso_name); goto out; } switch (read_addr2line_record(a2l, &record_function, &record_filename, &record_line_nr)) { case -1: - pr_warning("%s %s: could not read first record\n", __func__, dso_name); + if (!symbol_conf.disable_add2line_warn) + pr_warning("%s %s: could not read first record\n", __func__, dso_name); goto out; case 0: /* @@ -588,14 +590,17 @@ static int addr2line(const char *dso_name, u64 addr, */ switch (read_addr2line_record(a2l, NULL, NULL, NULL)) { case -1: - pr_warning("%s %s: could not read delimiter record\n", __func__, dso_name); + if (!symbol_conf.disable_add2line_warn) + pr_warning("%s %s: could not read delimiter record\n", + __func__, dso_name); break; case 0: /* As expected. */ break; default: - pr_warning("%s %s: unexpected record instead of sentinel", - __func__, dso_name); + if (!symbol_conf.disable_add2line_warn) + pr_warning("%s %s: unexpected record instead of sentinel", + __func__, dso_name); break; } goto out; From patchwork Thu Dec 15 19:28:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 33811 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp561411wrn; Thu, 15 Dec 2022 11:33:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf5k9uM6YjbR8LBIx2k7tRh+Q9UaEPdNNzoNTuU1Yyds3rSEMMdcPleB2xbB4cfoav45LvFu X-Received: by 2002:a17:906:6d8e:b0:7ad:b6d8:c9d0 with SMTP id h14-20020a1709066d8e00b007adb6d8c9d0mr24412706ejt.53.1671132789490; Thu, 15 Dec 2022 11:33:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671132789; cv=none; d=google.com; s=arc-20160816; b=e2b6nuhLyfO0tgzdUC7mOqV9jisGa+uxWlZlVJjiVJe//ItQbR9WwLL7SILehFe5yv +YQeB0A+hRxk3KZCra3iDy/7LmwvcsKxbxmjh/ihqiBVQEMR7Hx7J7I6BkuikObfh5SV M0Lc5dgkLJHukUzfCHm8FEkuIMcJ6fHShS75yfh58ZPdAc6GU/DLQ7Xf3YPgJii5mKn3 PIMxyaddfBe5k0xHGTBQcICWLa1Svh3EpKJ8MAjEujwDLBpW+aHEkD7XmeIYcfakdAzO LFLn5t6pJCvEDOIdcWl5ISzcornW3TVOX0kZkWycNePYs4Z7DKg0mlCrUk0UlygaI/gK /ctw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=2SWq8tpcCrwysvBsmnobWfCEN7jq3OKGDHoAjUmZcKM=; b=q/4kwwms4NYiMqMD/FcHKzOZvmOyGJtvXvOsXczJ8EDg53EJM90kjmHaU8iVv7bCyP vANSIMzqrhrO4iYIxLM/pHVr/07m8/j9jyG9BDFtpPaJFU1P4xVaVGMRpg70T53HmQh+ V4Ah503aZWWDGHlsFU77HtWm4b0TWcGybMvatLIGcmxpCjslmDjBkKSQ2gzSsrdnSTTy yF9PdwDeWe3FYrhbCLwr6T6mFzCZhPXP5VEXeHhNTnHyDadNqxndYdCXS2HJbU8luetz /t98C07s8+MecmYDCzv3ma651fd6AvYoW1pjOSltLnX9O7YmH+zZ9jek1P3ZKm7zY1Ek 7WLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aI78gKJv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o22-20020a170906975600b007c122a9ba98si16132466ejy.685.2022.12.15.11.32.45; Thu, 15 Dec 2022 11:33:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aI78gKJv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230322AbiLOT2w (ORCPT + 99 others); Thu, 15 Dec 2022 14:28:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230077AbiLOT23 (ORCPT ); Thu, 15 Dec 2022 14:28:29 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A98E84B986; Thu, 15 Dec 2022 11:28:28 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id n4so47874plp.1; Thu, 15 Dec 2022 11:28:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=2SWq8tpcCrwysvBsmnobWfCEN7jq3OKGDHoAjUmZcKM=; b=aI78gKJvL9S+95167GkI3Ge1ockEbEzp6hvrNPojeC288sACCfBe0NfmVWti/N6Qra z4PwACXjYHvbob9q1bOpJx39/U8LDs+vQxdT7QWb3jMkdQhb0/efj5n6SjPqwcsvzfla ajcrukOfh0ikfnFu0QObh1O4VLNk1FnlXRSnpZKRYu/qQ7lgyu1WCsBbLq+lR49wkMh9 M73PoOxV6lhJROKx4UNK81Vc1Zr5v90FbtUiYeV4uLvsLoScPPhNiDIrGvc/dDb2aXNB +v3NkQtUNyqZD3vCHf32vrQYYjbDr5T7WpfFhf/Ke3owKbPfx0KkvXWuI2/7As6O89Y8 eRFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2SWq8tpcCrwysvBsmnobWfCEN7jq3OKGDHoAjUmZcKM=; b=cb95U2ZbXl1xtLadDkjJNz8swlIjSLAHr0PH3bY9ghzvCxdxpu2BHWhce4bwQihHL5 13oTQrKktUQAPIQfHCxyTUzYfrhv/CeznPMA2uOKAduECy6Qu3RwuapkgPJNbAIjLAtl Ihj0pU3BY90T+83tqXmxNL+D6QipOJ5n4VfSI6YZbvTSSAKczg3Wm0WqNyz/D55z41yq vS56HaAN+CorBg5c3ObzF6wPjf86ONxXHzxFGCXW3v9ii1A//WiWFUKcu3mjxDUvNvdQ yfSvI7ZaU8pX4veQ6rkTi8TfXK7mgeGCjSb8RgdJjOe4VKhtAogBlFHwalUFryYJGUKh CaYg== X-Gm-Message-State: ANoB5plIinCPsC7sUI3RcxJ4IXM2KdwwxDjnLK5UvA+JVg7RdCm5d/jF QYU/LY7rV7AZAqAqhnSTtUQ= X-Received: by 2002:a17:90a:348e:b0:219:8cbb:c158 with SMTP id p14-20020a17090a348e00b002198cbbc158mr30920771pjb.5.1671132507614; Thu, 15 Dec 2022 11:28:27 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:ecc1:3e44:be34:129c]) by smtp.gmail.com with ESMTPSA id ep14-20020a17090ae64e00b00219cf5c3829sm3475129pjb.57.2022.12.15.11.28.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 11:28:27 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Andi Kleen , Milian Wolff , Leo Yan Subject: [PATCH 6/9] perf hist: Add perf_hpp_fmt->init() callback Date: Thu, 15 Dec 2022 11:28:14 -0800 Message-Id: <20221215192817.2734573-7-namhyung@kernel.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221215192817.2734573-1-namhyung@kernel.org> References: <20221215192817.2734573-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752309735891873877?= X-GMAIL-MSGID: =?utf-8?q?1752309735891873877?= In __hists__insert_output_entry(), it calls fmt->sort() for dynamic entries with NULL to update column width for tracepoint fields. But it's a hacky abuse of the sort callback, better to have a proper callback for that. I'll add more use cases later. Signed-off-by: Namhyung Kim --- tools/perf/util/hist.c | 10 +++++----- tools/perf/util/hist.h | 1 + tools/perf/util/sort.c | 31 ++++++++++++++++++++++++++----- tools/perf/util/sort.h | 1 + 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 17a05e943b44..b6e4b4edde43 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -1781,8 +1781,8 @@ static void hierarchy_insert_output_entry(struct rb_root_cached *root, /* update column width of dynamic entry */ perf_hpp_list__for_each_sort_list(he->hpp_list, fmt) { - if (perf_hpp__is_dynamic_entry(fmt)) - fmt->sort(fmt, he, NULL); + if (fmt->init) + fmt->init(fmt, he); } } @@ -1879,10 +1879,10 @@ static void __hists__insert_output_entry(struct rb_root_cached *entries, rb_link_node(&he->rb_node, parent, p); rb_insert_color_cached(&he->rb_node, entries, leftmost); + /* update column width of dynamic entries */ perf_hpp_list__for_each_sort_list(&perf_hpp_list, fmt) { - if (perf_hpp__is_dynamic_entry(fmt) && - perf_hpp__defined_dynamic_entry(fmt, he->hists)) - fmt->sort(fmt, he, NULL); /* update column width */ + if (fmt->init) + fmt->init(fmt, he); } } diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index ebd8a8f783ee..d93a4e510dc7 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -272,6 +272,7 @@ struct perf_hpp_fmt { struct hists *hists, int line, int *span); int (*width)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, struct hists *hists); + void (*init)(struct perf_hpp_fmt *fmt, struct hist_entry *he); int (*color)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, struct hist_entry *he); int (*entry)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 0ecc2cb13792..f6333b3dca35 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -2251,6 +2251,19 @@ static void hse_free(struct perf_hpp_fmt *fmt) free(hse); } +static void hse_init(struct perf_hpp_fmt *fmt, struct hist_entry *he) +{ + struct hpp_sort_entry *hse; + + if (!perf_hpp__is_sort_entry(fmt)) + return; + + hse = container_of(fmt, struct hpp_sort_entry, hpp); + + if (hse->se->se_init) + hse->se->se_init(he); +} + static struct hpp_sort_entry * __sort_dimension__alloc_hpp(struct sort_dimension *sd, int level) { @@ -2274,6 +2287,7 @@ __sort_dimension__alloc_hpp(struct sort_dimension *sd, int level) hse->hpp.sort = __sort__hpp_sort; hse->hpp.equal = __sort__hpp_equal; hse->hpp.free = hse_free; + hse->hpp.init = hse_init; INIT_LIST_HEAD(&hse->hpp.list); INIT_LIST_HEAD(&hse->hpp.sort_list); @@ -2556,11 +2570,6 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt, hde = container_of(fmt, struct hpp_dynamic_entry, hpp); - if (b == NULL) { - update_dynamic_len(hde, a); - return 0; - } - field = hde->field; if (field->flags & TEP_FIELD_IS_DYNAMIC) { unsigned long long dyn; @@ -2610,6 +2619,17 @@ static void hde_free(struct perf_hpp_fmt *fmt) free(hde); } +static void __sort__hde_init(struct perf_hpp_fmt *fmt, struct hist_entry *he) +{ + struct hpp_dynamic_entry *hde; + + if (!perf_hpp__is_dynamic_entry(fmt)) + return; + + hde = container_of(fmt, struct hpp_dynamic_entry, hpp); + update_dynamic_len(hde, he); +} + static struct hpp_dynamic_entry * __alloc_dynamic_entry(struct evsel *evsel, struct tep_format_field *field, int level) @@ -2632,6 +2652,7 @@ __alloc_dynamic_entry(struct evsel *evsel, struct tep_format_field *field, hde->hpp.entry = __sort__hde_entry; hde->hpp.color = NULL; + hde->hpp.init = __sort__hde_init; hde->hpp.cmp = __sort__hde_cmp; hde->hpp.collapse = __sort__hde_cmp; hde->hpp.sort = __sort__hde_cmp; diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 04ff8b61a2a7..921715e6aec4 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -282,6 +282,7 @@ struct sort_entry { int (*se_snprintf)(struct hist_entry *he, char *bf, size_t size, unsigned int width); int (*se_filter)(struct hist_entry *he, int type, const void *arg); + void (*se_init)(struct hist_entry *he); u8 se_width_idx; }; From patchwork Thu Dec 15 19:28:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 33808 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp561118wrn; Thu, 15 Dec 2022 11:32:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXtqm99bPeMUIB0E5UNONjEw+RCfiU3Ynp9EA2W4QnKElzVol/1p6SDZHD2RIGU7FyE1a0HB X-Received: by 2002:a05:6402:5d0:b0:474:5de4:a5d1 with SMTP id n16-20020a05640205d000b004745de4a5d1mr3580070edx.39.1671132752123; Thu, 15 Dec 2022 11:32:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671132752; cv=none; d=google.com; s=arc-20160816; b=zS+v1/yFEw8JN2tuqP0cTPSDkW88SYZfZXJWtErHIbnaGp6fFAGOhI/WKBfGdS8z8o TdmmGugVYzhT8XGiV1PYDA8TfwElGEuaup/0NivXt0w/Xnn62cMgzNvbv0IPT8eEmhdH FuYBZ5evmqjXG463g7Dvop44NKGrH/jWgQ0pe8D+BLHg07mWG4bkA38AyeTrr/kgCry4 YM9+LyJLnldWVFKgdzH5YJuohdOjTvWBani89G3Rg6iZQkPwSE4IQW8g2pWaB6pXw1ZT 065tkFRo6R1WcAqJW09dCq7WSgZgg/cvHA3cFFo/h+iCsa+Naa3Om2fkDjba04NPAz1Y UlJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=rlyNdOzS6lefhSSM/VlTz3GSPTVPpMK1oqgfJv5rmjM=; b=cBSb+RMngBGHQj9QlEeWipaz40gjnsV6rXRhyRZiFIbaee6/PAOuRaYign/eMBZwpA pznstDAEVLbZSqyiBBPS5wIZPYuthx7EkqmzW2m0fVICxSP9Ga12I7sTfuWxQHQRM2m1 5dHmZZotI1C3R8+o1r5lGbp5VyzzLSmfFEitpTidKTXXJlGBAnW9K1Pp0sY9ryRGT/QE JLR3CJjxUGWn27JZ4gG4mrOb1Mx7ICwrosTt0zdE7J/sMU6znt98lr81DrHhnZVCc7w5 OI9KyOPgZTbdI7JvYeNsLH3iL8pAc+x+soOAnY54cB5wNEHs+jR/WRK+wI5cxsOIXNLS SrLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZgWLJedY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p15-20020a056402500f00b0046ca78c5bffsi119972eda.449.2022.12.15.11.32.08; Thu, 15 Dec 2022 11:32:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZgWLJedY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230330AbiLOT2z (ORCPT + 99 others); Thu, 15 Dec 2022 14:28:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230091AbiLOT2b (ORCPT ); Thu, 15 Dec 2022 14:28:31 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5085847310; Thu, 15 Dec 2022 11:28:29 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id m4so31385pls.4; Thu, 15 Dec 2022 11:28:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=rlyNdOzS6lefhSSM/VlTz3GSPTVPpMK1oqgfJv5rmjM=; b=ZgWLJedYJWqeU21kwV1U4jSCjyytuO7e/mc+L1bD3knCJBNvT/LsCEKT6X6UdBTzHr r2krlBSmYgKXcS0AFPDmeL8MvSFznFYDZ/ok4Mqk+lbvEWY9B6VFOfSxJzyWmKockKtp JJGmfdApCm1DAAzmEixI6JdkgSIFJFJELW0PAIwqodbenS2sESq41Oi6C16eoSLRmes5 +Ibka/Nv7i+L2jgddMoYZILVURo6IylI2QYDbVLXUCZdj/LFw+Xpn14mtUg1C+TnxG0x WiEKYPZP88XIbw1UuhG53wklEG/ttt2T7wvXTcY2/Oy8PH90Kh4argzwCNvb25grFv4i qPpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=rlyNdOzS6lefhSSM/VlTz3GSPTVPpMK1oqgfJv5rmjM=; b=NnGW9fpBhG//zG61/eYqlXCRp8dSdQqxz94NKiuwz8Sh4F6eMWOSEfnDsAcIX/EBlr SzvG1Dh78RebHRKBNwUQgFfFeP+ltKCeNKpnmB/U7gdYRoNozO6ju0+ZbTa2CDnB4vB5 7oo2yRY7Gl3udR/8qTilW2DFSW5rrGuDsNWqjY2xVveARgHKrTEEVevS9WvP1+h8+TH7 lfASYj4JP3AvrbmS6IEWQ7gnqa67R0CIRrBReOjropmBscDeaAOFwchCldpPsX/ICGpy X3emMx4PMM+q+xJnmRypd1UrEUWA31M3uTnpiNU8RxeLR2N2Yvj0OURa3HdbGAyPatec rY3g== X-Gm-Message-State: ANoB5pn2uly5KD0zRHAErSTnN2fiDu22xjWugHdF06l/L1u7qYPXihEO idMmtjR4yEvXLfVMM8fUuto= X-Received: by 2002:a17:90b:2315:b0:219:8b27:e065 with SMTP id mt21-20020a17090b231500b002198b27e065mr36884986pjb.17.1671132508708; Thu, 15 Dec 2022 11:28:28 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:ecc1:3e44:be34:129c]) by smtp.gmail.com with ESMTPSA id ep14-20020a17090ae64e00b00219cf5c3829sm3475129pjb.57.2022.12.15.11.28.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 11:28:28 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Andi Kleen , Milian Wolff , Leo Yan Subject: [PATCH 7/9] perf hist: Improve srcline sort key performance Date: Thu, 15 Dec 2022 11:28:15 -0800 Message-Id: <20221215192817.2734573-8-namhyung@kernel.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221215192817.2734573-1-namhyung@kernel.org> References: <20221215192817.2734573-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752309696700065179?= X-GMAIL-MSGID: =?utf-8?q?1752309696700065179?= The sort_entry->cmp() will be called for eventy sample data to find a matching entry. When it has 'srcline' sort key, that means it needs to call addr2line or libbfd everytime. This is not optimal because many samples will have same address and it just can call addr2line once. So postpone the actual srcline check to the sort_entry->collpase() and compare addresses in ->cmp(). Also it needs to add ->init() callback to make sure it has srcline info. If a sample has a unique data, chances are the entry can be sorted out by other (previous) keys and callbacks in sort_srcline never called. Signed-off-by: Namhyung Kim --- tools/perf/util/sort.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index f6333b3dca35..913045c5b2b2 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -373,6 +373,18 @@ char *hist_entry__srcline(struct hist_entry *he) static int64_t sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right) +{ + int64_t ret; + + ret = _sort__addr_cmp(left->ip, right->ip); + if (ret) + return ret; + + return sort__dso_cmp(left, right); +} + +static int64_t +sort__srcline_collapse(struct hist_entry *left, struct hist_entry *right) { if (!left->srcline) left->srcline = hist_entry__srcline(left); @@ -382,18 +394,31 @@ sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right) return strcmp(right->srcline, left->srcline); } -static int hist_entry__srcline_snprintf(struct hist_entry *he, char *bf, - size_t size, unsigned int width) +static int64_t +sort__srcline_sort(struct hist_entry *left, struct hist_entry *right) +{ + return sort__srcline_collapse(left, right); +} + +static void +sort__srcline_init(struct hist_entry *he) { if (!he->srcline) he->srcline = hist_entry__srcline(he); +} +static int hist_entry__srcline_snprintf(struct hist_entry *he, char *bf, + size_t size, unsigned int width) +{ return repsep_snprintf(bf, size, "%-.*s", width, he->srcline); } struct sort_entry sort_srcline = { .se_header = "Source:Line", .se_cmp = sort__srcline_cmp, + .se_collapse = sort__srcline_collapse, + .se_sort = sort__srcline_sort, + .se_init = sort__srcline_init, .se_snprintf = hist_entry__srcline_snprintf, .se_width_idx = HISTC_SRCLINE, }; From patchwork Thu Dec 15 19:28:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 33809 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp561349wrn; Thu, 15 Dec 2022 11:33:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf6IFvJgJVZsj0aSJ8VM93XNXVB8Na5ZYRLf3y4yP90UF3GXSggs6dG0jHOISM/csdqFl56Q X-Received: by 2002:a05:6a21:7881:b0:9d:efbf:785f with SMTP id bf1-20020a056a21788100b0009defbf785fmr44471068pzc.20.1671132781105; Thu, 15 Dec 2022 11:33:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671132781; cv=none; d=google.com; s=arc-20160816; b=nKMLLXCKl8XoWakyTNmpSPVf5tUoygsonSrV5L4OmoXMuoqkR+mdmWS2kw4xGB9bGN Kghto1EwBGAz6ZEHcYAISpWbN5oacAquyjgvIc/gChvVKgtalyeP63Cj/SQRhPU5VvSr kzHWNfLiItu5TnYMKgHNLHv/btYFvo7SBAlSYsgawmCii+0IEvl1c7OpYUHalJzRijUq dltbuwi+sZdYkhNPifWjIwaww66As0QWWf3fWe2LCLk95Ds1e0B2m4vTjUXtPGn0znTl w9yoYaHdo5HJT/HzICVLZSn6HZOL/a8nViIXc7ifwWv6MC5P6PD49HyGlzAbOh5v+iFL 1VEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=lRJhsYD6Q8d3CjTB733ncypYkegZvAGinKhexPwhiRs=; b=Q6BSccy/t/eHVpBn61z5xqfxEQfq6ppVEhvHD+xSjEiYE4fnEBRmvhX4d8k4j0QT8A b04I2UxKD8ABjFt6nKvy91YfsGCAJqyw65o1vBRPSD78xceoUr9GlU0tdV13iPKLrkSV n6G9RQ6UZTPOIIbUjF5VD8a5OQgPDxakujNODfjwqqlaAKBMomsk4Qks8upJGlkwKaXb RJALV9/bSKuDBe14NT1zhPvnjShKVsUaPYCq5AFTd7uADDZVTZZOtp76N1EfoDKL0OAn jCZG2W2a9lFq5MNvRkF+yRHAB4jHsT0KpsQItMDMSuufwJ5w997RuwHQ9idQ1EktSHV0 GFuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Om7CYEY7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 136-20020a63028e000000b004776765cf3csi218183pgc.605.2022.12.15.11.32.47; Thu, 15 Dec 2022 11:33:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Om7CYEY7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230338AbiLOT3A (ORCPT + 99 others); Thu, 15 Dec 2022 14:29:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230111AbiLOT2b (ORCPT ); Thu, 15 Dec 2022 14:28:31 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39F104B9A1; Thu, 15 Dec 2022 11:28:30 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id 4so36842plj.3; Thu, 15 Dec 2022 11:28:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=lRJhsYD6Q8d3CjTB733ncypYkegZvAGinKhexPwhiRs=; b=Om7CYEY7dnjsSshVnzhztwQx5Wx7srg6j2+WpPqCN1ZKgkMHQ+mEVG7lE5zle0hmAX nCzlvchTjD5/hNptvIT4pQ+UZUN/CW/FWrWpVLWhA+ayzc3eCrGt0YO2W9ffWBNab+Mu p6SHupNBRrQ1Kb1viujAuVgjFmzgudeA0wG2ewKq89ti4t0UtJi/vhL33gBKdYCZxA0K D2C1udzxGBPCVyQgPIY7hHVHq398+47QYU7Ux79H+R6IPwAh4DXUAOK7UB1636U63hMY 5Q9BUOr+PW6XZ5SGfzRfsNyMI18hWUkGihMjfqh11Avuq22i1j0gRIZn2lGTm1ONeO5I aCYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=lRJhsYD6Q8d3CjTB733ncypYkegZvAGinKhexPwhiRs=; b=U5rVzb+10U/ins+bLuoNWSQBpi7cqoiy/H7H7JkBmbcfPL4B7wC7eYdUoiNUeceo/f KRJOQZpULeSYzQq8sDy8JVt2dXOOn+IJ9xVCxFQfwn33jpFAQ+ZibDkJX+LlVNlXQo/w bPVe7hVDlTvVj+yfC9jNDKQT6MfxYI/s4V6vT2fXgcDyE+f2IQSNTIq441ke9D4E1JRH T+kHnlrWU6GaK6wzG1sr6p7eOiZO2sv4JFSQyexbue5AEGwsOvRDtj+LtSoV6N672kg/ bOrwNuquYYqx3fAbcQlJnptMsQouv3bJ0A+Pj/9/sg8W48lYttdK3tzGeBUR5jnfDxWy yqMg== X-Gm-Message-State: ANoB5pmJPH5mKjYxhhkV/74h3txBd2xkeuYzXwp8g3RJ75vct4IRrvDS wTCQ3O0jC9l/cpVBaos0xXs= X-Received: by 2002:a05:6a20:9589:b0:9d:efbf:785d with SMTP id iu9-20020a056a20958900b0009defbf785dmr10620141pzb.18.1671132509823; Thu, 15 Dec 2022 11:28:29 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:ecc1:3e44:be34:129c]) by smtp.gmail.com with ESMTPSA id ep14-20020a17090ae64e00b00219cf5c3829sm3475129pjb.57.2022.12.15.11.28.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 11:28:29 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Andi Kleen , Milian Wolff , Leo Yan Subject: [PATCH 8/9] perf hist: Improve srcfile sort key performance Date: Thu, 15 Dec 2022 11:28:16 -0800 Message-Id: <20221215192817.2734573-9-namhyung@kernel.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221215192817.2734573-1-namhyung@kernel.org> References: <20221215192817.2734573-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752309727332982874?= X-GMAIL-MSGID: =?utf-8?q?1752309727332982874?= Likewise, modify ->cmp() callback to compare sample address and map address. And add ->collapse() and ->sort() to check the actual srcfile string. Also add ->init() to make sure it has the srcfile. Signed-off-by: Namhyung Kim --- tools/perf/util/sort.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 913045c5b2b2..c290539dcf43 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -569,18 +569,41 @@ sort__srcfile_cmp(struct hist_entry *left, struct hist_entry *right) return strcmp(right->srcfile, left->srcfile); } -static int hist_entry__srcfile_snprintf(struct hist_entry *he, char *bf, - size_t size, unsigned int width) +static int64_t +sort__srcfile_collapse(struct hist_entry *left, struct hist_entry *right) +{ + if (!left->srcfile) + left->srcfile = hist_entry__get_srcfile(left); + if (!right->srcfile) + right->srcfile = hist_entry__get_srcfile(right); + + return strcmp(right->srcfile, left->srcfile); +} + +static int64_t +sort__srcfile_sort(struct hist_entry *left, struct hist_entry *right) +{ + return sort__srcfile_collapse(left, right); +} + +static void sort__srcfile_init(struct hist_entry *he) { if (!he->srcfile) he->srcfile = hist_entry__get_srcfile(he); +} +static int hist_entry__srcfile_snprintf(struct hist_entry *he, char *bf, + size_t size, unsigned int width) +{ return repsep_snprintf(bf, size, "%-.*s", width, he->srcfile); } struct sort_entry sort_srcfile = { .se_header = "Source File", .se_cmp = sort__srcfile_cmp, + .se_collapse = sort__srcfile_collapse, + .se_sort = sort__srcfile_sort, + .se_init = sort__srcfile_init, .se_snprintf = hist_entry__srcfile_snprintf, .se_width_idx = HISTC_SRCFILE, }; From patchwork Thu Dec 15 19:28:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 33810 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp561348wrn; Thu, 15 Dec 2022 11:33:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf59S7uY2WosXnTK2j4hwn6t0lDakojqoLcx2Tpjs2qZZlzDEXaF8EzJ/JojVUNZ+DMzKUHm X-Received: by 2002:a62:a509:0:b0:56b:f127:f21f with SMTP id v9-20020a62a509000000b0056bf127f21fmr28680447pfm.13.1671132781103; Thu, 15 Dec 2022 11:33:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671132781; cv=none; d=google.com; s=arc-20160816; b=gh3CHKIdg9LaJLff21L9J70SVak92FrQ7B8h8ak7DCjMWCFAT8HaWFaxHOxBGTjg4C acSENbHsOX3BDo1AYQjASdt2OsKdEeULLKuTLE+AyBN67T9ttv8PaRQBVHpgtoaiXyQl bpTvJFt6cMfw+XpVaUCenutHoaWT2aDdG65xYmBjr3RiMY0byGtxoJVvbv6JBGGqtnt6 2YQWgScj9Q+PGZ7ONtmq52D6x+mVxMRpeVjHhd++cFXqcX3e2dZBI46/eS3wGmw9SrTp /74u/jQZKBBTwO6ITB+PN93LoaSpJzVs0nfPZmZG5uZGofsUZ1kGjvkaMcjUzgj4sQ7E nQdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=PJJL5CU7ptHXr+iHLPpq+YgdyRtPuip5im73Jo4lYDM=; b=rI3G0+FkeqdPHOptAS9giKruYbctEd81k619mPGla5ug4ZXfkJxIqwVdZTaJdhI6Mh 60BYqToPXgTX5eEryaeQekFfpuHvcQHA2XJ83zsghsnDtmEdwqDGTRHVocGOTCKOnrid 8W+fvbs87fNNlFlPbxXX8H/jbQxTIQp8+rn9RdmajRVGQWVqUALkRTSyPuL9z5QS/Or+ o66EH/gw444HqdaJXK3Iw75kofJ4/eb4R7zlQRz7315tgrWCxDBNITtVgS5XPfFUWkKw E9+pZ/15amBaJT+MQEoxzTgEtXSV1rTdggP6dOoUuUNwOpvAFVoLyWd4LEvBEcyoxzLv E7PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=R2FycQjg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t9-20020aa78f89000000b0056c882d3d06si3318608pfs.199.2022.12.15.11.32.46; Thu, 15 Dec 2022 11:33:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=R2FycQjg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230176AbiLOT3F (ORCPT + 99 others); Thu, 15 Dec 2022 14:29:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230156AbiLOT2f (ORCPT ); Thu, 15 Dec 2022 14:28:35 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8446550D50; Thu, 15 Dec 2022 11:28:31 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id x2so6599227plb.13; Thu, 15 Dec 2022 11:28:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=PJJL5CU7ptHXr+iHLPpq+YgdyRtPuip5im73Jo4lYDM=; b=R2FycQjgluMgwJfWkdtp6gE6fj/eN6kjSEw5X/LK9opDYuWTGtP0YQ3rQKEu89EyHs BqrSj7SZ8qJhdlgx5bPS0DVtBA9iMVJPIotietniCz6iDuatLriqtkqUWiOT0JWa2tq6 Ixq0zD90mL6WORlCLzq0DF9V5FzWZTjGu05zubAEAJ3A6pFXcFiNJ8wH6H4bD8wChEHc k8wIVz6qFxyDn+MABc6A2UEFSm6O4TSFDujsypFP+xfu/k5ea2vYIsDgswOUrOUJ71Id N8jI9D4g5J11rnc+vrr3WOcLZ/KDJ0o7HJ8uVpkHgNAmBWv5H3rlKiOwkr6nb3XrQlD5 mUyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PJJL5CU7ptHXr+iHLPpq+YgdyRtPuip5im73Jo4lYDM=; b=zz/7QdIRsCbUcLwKw8toVonCmQClZm/Wg67+X4XCuXOC6Gdmj4ObcOr3Tlkc72peMd UTlc0hhfgAml/Jcyd+aJeK+H0yx+xk39HvuhZ47u8sM7owXw9Uxxb6BaPisMIPfAejEi qx7kvOJXj1DrZCXQd2cjQRLCBBEdD2hw1RIKIWEwYDOlCYbjsn7kQX18fPSWsQja5yH7 sw+ejTU84oCLo7ZXOi0XHDylLgLFH0jvKhQ2z2/VhdhichQpCNnqi7CPkwH7azBVu3Ku zX8qlCQHm6A5PGfpOBin2kIUkNGl6dDnqrNtyRAOM6rg5fpjHd2wUolIsZj3ZaYLrmwE HoRA== X-Gm-Message-State: ANoB5pksDIpvHzvvnQzxT+NSa1rmgqn6JNt4AhzTbmLYyOpjspvd4u/I XTvbfgDgq0IVaHpemXVREDo= X-Received: by 2002:a17:90a:e608:b0:219:705e:67b2 with SMTP id j8-20020a17090ae60800b00219705e67b2mr30567281pjy.10.1671132510943; Thu, 15 Dec 2022 11:28:30 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:ecc1:3e44:be34:129c]) by smtp.gmail.com with ESMTPSA id ep14-20020a17090ae64e00b00219cf5c3829sm3475129pjb.57.2022.12.15.11.28.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 11:28:30 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Andi Kleen , Milian Wolff , Leo Yan Subject: [PATCH 9/9] perf hist: Improve srcline_{from,to} sort key performance Date: Thu, 15 Dec 2022 11:28:17 -0800 Message-Id: <20221215192817.2734573-10-namhyung@kernel.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20221215192817.2734573-1-namhyung@kernel.org> References: <20221215192817.2734573-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752309727090955782?= X-GMAIL-MSGID: =?utf-8?q?1752309727090955782?= Likewise, modify ->cmp() callback to compare sample address and map address. And add ->collapse() and ->sort() to check the actual srcfile string. Also add ->init() to make sure it has the srcfile. Signed-off-by: Namhyung Kim --- tools/perf/util/sort.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index c290539dcf43..e188f74698dd 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -432,6 +432,12 @@ static char *addr_map_symbol__srcline(struct addr_map_symbol *ams) static int64_t sort__srcline_from_cmp(struct hist_entry *left, struct hist_entry *right) +{ + return left->branch_info->from.addr - right->branch_info->from.addr; +} + +static int64_t +sort__srcline_from_collapse(struct hist_entry *left, struct hist_entry *right) { if (!left->branch_info->srcline_from) left->branch_info->srcline_from = addr_map_symbol__srcline(&left->branch_info->from); @@ -442,6 +448,18 @@ sort__srcline_from_cmp(struct hist_entry *left, struct hist_entry *right) return strcmp(right->branch_info->srcline_from, left->branch_info->srcline_from); } +static int64_t +sort__srcline_from_sort(struct hist_entry *left, struct hist_entry *right) +{ + return sort__srcline_from_collapse(left, right); +} + +static void sort__srcline_from_init(struct hist_entry *he) +{ + if (!he->branch_info->srcline_from) + he->branch_info->srcline_from = addr_map_symbol__srcline(&he->branch_info->from); +} + static int hist_entry__srcline_from_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) { @@ -451,6 +469,9 @@ static int hist_entry__srcline_from_snprintf(struct hist_entry *he, char *bf, struct sort_entry sort_srcline_from = { .se_header = "From Source:Line", .se_cmp = sort__srcline_from_cmp, + .se_collapse = sort__srcline_from_collapse, + .se_sort = sort__srcline_from_sort, + .se_init = sort__srcline_from_init, .se_snprintf = hist_entry__srcline_from_snprintf, .se_width_idx = HISTC_SRCLINE_FROM, }; @@ -459,6 +480,12 @@ struct sort_entry sort_srcline_from = { static int64_t sort__srcline_to_cmp(struct hist_entry *left, struct hist_entry *right) +{ + return left->branch_info->to.addr - right->branch_info->to.addr; +} + +static int64_t +sort__srcline_to_collapse(struct hist_entry *left, struct hist_entry *right) { if (!left->branch_info->srcline_to) left->branch_info->srcline_to = addr_map_symbol__srcline(&left->branch_info->to); @@ -469,6 +496,18 @@ sort__srcline_to_cmp(struct hist_entry *left, struct hist_entry *right) return strcmp(right->branch_info->srcline_to, left->branch_info->srcline_to); } +static int64_t +sort__srcline_to_sort(struct hist_entry *left, struct hist_entry *right) +{ + return sort__srcline_to_collapse(left, right); +} + +static void sort__srcline_to_init(struct hist_entry *he) +{ + if (!he->branch_info->srcline_to) + he->branch_info->srcline_to = addr_map_symbol__srcline(&he->branch_info->to); +} + static int hist_entry__srcline_to_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) { @@ -478,6 +517,9 @@ static int hist_entry__srcline_to_snprintf(struct hist_entry *he, char *bf, struct sort_entry sort_srcline_to = { .se_header = "To Source:Line", .se_cmp = sort__srcline_to_cmp, + .se_collapse = sort__srcline_to_collapse, + .se_sort = sort__srcline_to_sort, + .se_init = sort__srcline_to_init, .se_snprintf = hist_entry__srcline_to_snprintf, .se_width_idx = HISTC_SRCLINE_TO, };