From patchwork Thu Nov 9 23:59:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 163669 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp787440vqs; Thu, 9 Nov 2023 16:04:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHqyWh5eWXNWJYeIfncv9UVXOEEGO6r7a8x8eauTitP2/jWn4t35/WG/J0/ABob0JoPZ9Cc X-Received: by 2002:a17:902:d5cd:b0:1cc:59a1:79c6 with SMTP id g13-20020a170902d5cd00b001cc59a179c6mr6345305plh.18.1699574661160; Thu, 09 Nov 2023 16:04:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699574661; cv=none; d=google.com; s=arc-20160816; b=SOg6MwOmOZqfqeiW4P9Jap/iX7tHwCTfNAEbyJAUhV4f7S4GB7jx9XLe+wBqzogVa8 r6cRDV2+XXWphbrDoDtcH2y5UAF3zRjH2gzba09aPfrwUwM+dIcykv2zdWnuo1ZIiezY TDiKSrieWIFNizBAdjJmcAupoqvXyzPYF8wjgWng7ngk0W8gDM8A0jdbKzktgY1Lab3B 6ytEKQmkHO9DbMnMi37INMvG06LSvWBkmVEHwfbvFHSAptgzItUOSvmsSZD5NPQ4Lq+S Ybn+JFd7Vsh4XWLRD5iard8LUOLUVMbzrPUuRd/Kdgy6EKMkV6SxaQyw2xtuJDjLiXBQ ep2w== 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=4VL5lFahygayw5UMi6X2ej0x4hwwXaVjpVtEOwOIuJ0=; fh=K//si1Hi/RYC7s39rVvmvh0YbZGmBrdWWHQg3cPF7Xc=; b=yiywbnwEIlDwK0Ea79OHUpsui8tDSevkbDRMrLCnc1YyfV54DcEuVVyEVpVy1csLh8 2PNxi0loW91AVfSxLjkMO4YXkXKKSuGFPerg40gbraPrusC63HnAj/xZaJt1eCh8EpjY afGyPRFQO4yJ4P7VDqanc1oldjg9r9M/sFymwEQ1Mk84FvJMkzOPq+erXrVvGE2CZcRL K7/liGhavrfmR19Gh77XlOfg4TV0ugmvnb04NqCJzt2RZdZICNPEblAWbXxY3AkVA5l6 xmIp0I+opUxEATkqdE/73SGgSKgxJSB4BdIYat2D8U9tiwmC0BTWpTzg/0xo1KP+17Yo wvDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="MhvZQEh/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id j15-20020a170902da8f00b001cc283d99a6si6396063plx.474.2023.11.09.16.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 16:04:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="MhvZQEh/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 4F73D80A4A09; Thu, 9 Nov 2023 16:04:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345695AbjKJACn (ORCPT + 30 others); Thu, 9 Nov 2023 19:02:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234817AbjKJABz (ORCPT ); Thu, 9 Nov 2023 19:01:55 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B645C4EC4; Thu, 9 Nov 2023 16:00:58 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-280260db156so1276076a91.2; Thu, 09 Nov 2023 16:00:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699574458; x=1700179258; darn=vger.kernel.org; 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=4VL5lFahygayw5UMi6X2ej0x4hwwXaVjpVtEOwOIuJ0=; b=MhvZQEh/BGG8l4eAag3n5BBmx2AC+35Qb+sllIKYUW/NjMiE2k1pZT758yErUjkTDv vn85WMTpGMPLWJl9RYFQS20e8tij23ZvTUFsWDUBS+o8q/xj81W7lUnh2kaz+KTSbnTL euXi8A9l2lTir8HWrpb8nzv4aCCajPBn23Sl/7cdhrlrW0yYUTatva6EhbNL9OtLOmFK qKjdJH+zPtHKBUZEQhrG59lyOl/2BZc1FuwDohRMMCWYQ2Eq5JwT5SlDrY0sWVLTxq3E 1TKlEFhypikbZmem8LW/i0/T9TqL5DLCLTkSs8oRpXZ3ogV2qw5/QUVlNKGjdvDl/Z+s iHLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699574458; x=1700179258; 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=4VL5lFahygayw5UMi6X2ej0x4hwwXaVjpVtEOwOIuJ0=; b=h/KaLOfTlBlfs7Rr7PrXjLc/dEwUf5s29651Xxu/3t6nIzO5KIMoLpP4Z492zk55n4 I65WXFmOfZ6/SDFl6aweGFxvIa9XZBwSxLm1pFlFUj1FtNvPhfRH8f1uyBC8O+gHVWef 0Wl/eD3Kn8mUWuXKPHWYEirEGtS4jz1ecJIaWVJrPecJEl2g7vdmvtv2XFSRM+Cn4anA uTEcq0hI+kXVP0iEZg8CUDc0gMjhpHyRCaJ6IsrSSGeeoVb8LucNt35O42JNeNexx+rp OPxdd8alq2K6DoXCRYwzMK0w+PG5JyDGEsrEHF7BYRFNO8GywXoRrhV5XNiWl1ltuWyh I8lA== X-Gm-Message-State: AOJu0YyszSB9XfeOUEIigaPxgrT7Z96rF2wWP45LGimjWL9iwyvn/10I QyciQ5nIye8i/IXhqXaRM3VRR1KA9bo= X-Received: by 2002:a17:90b:4f49:b0:27d:4b6e:b405 with SMTP id pj9-20020a17090b4f4900b0027d4b6eb405mr3562538pjb.33.1699574458144; Thu, 09 Nov 2023 16:00:58 -0800 (PST) Received: from bangji.corp.google.com ([2620:15c:2c0:5:d45c:ae16:d959:a5f1]) by smtp.gmail.com with ESMTPSA id k32-20020a17090a4ca300b002635db431a0sm371312pjh.45.2023.11.09.16.00.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 16:00:57 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa , Peter Zijlstra Cc: Ian Rogers , Adrian Hunter , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Linus Torvalds , Stephane Eranian , Masami Hiramatsu , Andi Kleen , linux-trace-devel@vger.kernel.org, linux-toolchains@vger.kernel.org Subject: [PATCH 28/52] perf annotate-data: Parse 'lock' prefix from llvm-objdump Date: Thu, 9 Nov 2023 15:59:47 -0800 Message-ID: <20231110000012.3538610-29-namhyung@kernel.org> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog In-Reply-To: <20231110000012.3538610-1-namhyung@kernel.org> References: <20231110000012.3538610-1-namhyung@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 09 Nov 2023 16:04:01 -0800 (PST) X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782133199950331310 X-GMAIL-MSGID: 1782133199950331310 For the performance reason, I prefer llvm-objdump over GNU's. But I found that llvm-objdump puts x86 lock prefix in a separate line like below. ffffffff81000695: f0 lock ffffffff81000696: ff 83 54 0b 00 00 incl 2900(%rbx) This should be parsed properly, but I just changed to find the insn with next offset for now. This improves the statistics as it can process more instructions. Annotate data type stats: total 294, ok 144 (49.0%), bad 150 (51.0%) ----------------------------------------------------------- 30 : no_sym 35 : no_mem_ops 71 : no_var 6 : no_typeinfo 8 : bad_offset Signed-off-by: Namhyung Kim --- tools/perf/util/annotate.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 3ac601d70f61..2f325a9cf33a 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -3664,8 +3664,17 @@ static struct disasm_line *find_disasm_line(struct symbol *sym, u64 ip) notes = symbol__annotation(sym); list_for_each_entry(dl, ¬es->src->source, al.node) { - if (sym->start + dl->al.offset == ip) + if (sym->start + dl->al.offset == ip) { + /* + * llvm-objdump places "lock" in a separate line and + * in that case, we want to get the next line. + */ + if (!strcmp(dl->ins.name, "lock") && *dl->ops.raw == '\0') { + ip++; + continue; + } return dl; + } } return NULL; } @@ -3757,6 +3766,9 @@ struct annotated_data_type *hist_entry__get_data_type(struct hist_entry *he) if (!op_loc->mem_ref) continue; + /* Recalculate IP since it can be changed due to LOCK prefix */ + ip = ms->sym->start + dl->al.offset; + mem_type = find_data_type(ms, ip, op_loc->reg, op_loc->offset); if (mem_type) istat->good++;