From patchwork Thu Oct 12 03:50: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: 151703 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp965116vqb; Wed, 11 Oct 2023 20:54:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFSIHy8LqSZrrxReQVUKb0G5yJE8ONPh+MtdYdL5XST31AVdUIttrh8l/nS3HBeCwaf6EQy X-Received: by 2002:a05:6a20:3d85:b0:163:f945:42c4 with SMTP id s5-20020a056a203d8500b00163f94542c4mr26604605pzi.1.1697082866714; Wed, 11 Oct 2023 20:54:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697082866; cv=none; d=google.com; s=arc-20160816; b=XM7ziFe4UfGv3/ZvLKR5+JualjJiDeFea8dZQVHq4ulpLZOfualkhUXXDptpZBFAqn 8/EXmmny1W29ds/1nNaipB7OTTzszclgm6ozkYvZHqKAhShbisiHcnGhKxXtH6QLwMXT DZfEL8wdOdnFHPV5e4NHSNErLlmMiuNbN/i+XQ+YAvr5lPcY0UYEU3NWl1+CW8YFjWic 5bD5mJ6sIQIxqmMWRwLgVCAyXYcb6mip+gDa1Q0ORkYs95YLXtlKrfDIoFbdSj0DgtYw IYG+Bw7oEWi5xWauhxQnXvp567ySypXlWOTQsrcEvedxFULsiPb3P+yfnhIozLh5eSUZ 6QFQ== 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=tHRD9kCjTkWVMzvqCRV9itspmVJvTLZ+rMPWUUQpDy0=; fh=7Id7wL2M+oCJXD4imOzx4OKioxBXSOZqypDprm7aO4E=; b=DKv3mHy7Ax9M9cDdlqupljuBItZEGSDa3VEOCVaK/m2FX1LcKJ8I2xNzMVdN0oWwBn Tu1PT4TuvixeOT6ox6QkWff89oLp6dRMkCrbBjmJpVSWdmrmF0KSTzcgGCmPfYldLJgA ofhd3IDpGtpsmKWYjvwqQRGmN+1UQlDMmo49ZNfL6PdC4p+/yuokjac5KDDrnQ8K1fWB a6FX4gfcZUvbgbeMLT4KbMce8/fokRcyX5aXzPuaynfKRYshh0iRJK78bjAFgMPrTdru g1qhWmJJh/FcGvXcIHsophhInSMIB806PfnD+4jECHMMlX9CejbKRup1nQRWrsc/lt/7 QhbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XINusBF0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id ep3-20020a17090ae64300b0027cfcb6bfc8si1280002pjb.96.2023.10.11.20.54.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 20:54:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XINusBF0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 73FA380F6694; Wed, 11 Oct 2023 20:54:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377133AbjJLDyI (ORCPT + 18 others); Wed, 11 Oct 2023 23:54:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376920AbjJLDwy (ORCPT ); Wed, 11 Oct 2023 23:52:54 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05BE6D5D; Wed, 11 Oct 2023 20:51:48 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1c9d3a21f7aso4510215ad.2; Wed, 11 Oct 2023 20:51:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697082706; x=1697687506; 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=tHRD9kCjTkWVMzvqCRV9itspmVJvTLZ+rMPWUUQpDy0=; b=XINusBF0gHNj2rSlBlEKNCJQL6v1m3lkiON5G2iLAPI0iPBX+YAT+RwHnqKlvdWoXN cs6CHDboOCn9YiPjzGbX2cdLyp8uA/lvtc0JDwJUmD4XCg1ZO/7nicyAmxpzgdlJmLfo wz7QyDGpanJRNZweugZfPasBV2QvEUxFX+oGSkwEOQ2vDDRevXHBf5KkIHvicmrXfZbh hQ6FpKlid2nmIeS/BobA7vgRio6qaKS6Y1iJRHLtLpAE1YvF5tynrQrEU5Q2tgsBr5ND lFPm4kx0jiUYcxJjg4nooCLgj2ZOl9aoX/Fg2rDdgdRZ5j6Z7ySsSgcbAI5uOXpJxlQv UG3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697082706; x=1697687506; 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=tHRD9kCjTkWVMzvqCRV9itspmVJvTLZ+rMPWUUQpDy0=; b=O7rpZ+4Eu+XZ+DKI12f8VmwVyiDSx8REbRkvWB1IlBWMBA2O7wrJ+NnDVvrzJAA0po +edz6fuGQPPHJBfon0LI5K9cZTe2JwkeBdXIDsnS6NpCdrx5emNQy7Zb0i7HoKR6aPwD pUrxoBXILYuVt+h8BMDKWZjNS+aORN5aaO0MxOyw7xhd1okUhjdkRgkxhT1jh5DcP8hG KcIQqnVA8Iv2SvUQk9TCdlEPvCwGa0/ZHAGHGkRj/j38x8uDIJ0NER1SwoSCE3yRUE1y mii0dQTvCdU71r4iIXh7RBjQl5MzZ1fnD25Y85ChPIAJegzlAZAboIeRzQ/gKtsDqc5D ikAQ== X-Gm-Message-State: AOJu0Yw5Fqe5ShbSwoFKUd0dbQecetngfXtjKfsCkpJ03NH2BC+3EZtB tiDtCtWhFhhKpHq8sOVpL4g= X-Received: by 2002:a17:902:e84a:b0:1c2:218c:3754 with SMTP id t10-20020a170902e84a00b001c2218c3754mr28229405plg.53.1697082706299; Wed, 11 Oct 2023 20:51:46 -0700 (PDT) Received: from bangji.hsd1.ca.comcast.net ([2601:647:6780:42e0:b1b9:d490:2f5e:be06]) by smtp.gmail.com with ESMTPSA id w8-20020a170902d70800b001bc18e579aesm711374ply.101.2023.10.11.20.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 20:51:45 -0700 (PDT) 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 , linux-toolchains@vger.kernel.org, linux-trace-devel@vger.kernel.org Subject: [PATCH 24/48] perf annotate-data: Parse 'lock' prefix from llvm-objdump Date: Wed, 11 Oct 2023 20:50:47 -0700 Message-ID: <20231012035111.676789-25-namhyung@kernel.org> X-Mailer: git-send-email 2.42.0.655.g421f12c284-goog In-Reply-To: <20231012035111.676789-1-namhyung@kernel.org> References: <20231012035111.676789-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Wed, 11 Oct 2023 20:54:24 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779520364132257877 X-GMAIL-MSGID: 1779520364132257877 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 3f3cc7ae751f..190489df0fb7 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -3624,8 +3624,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; } @@ -3717,6 +3726,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++;