From patchwork Thu Nov 9 23:59:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 163642 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp786227vqs; Thu, 9 Nov 2023 16:02:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEnrlfEJMohyUNRZO5BzMsMiaiPP9zGAhCcYi5cLOnOgs9SKWHm1KeyXglJxzUltpjdAkYI X-Received: by 2002:a05:6a00:1708:b0:6c3:38f5:99d2 with SMTP id h8-20020a056a00170800b006c338f599d2mr6839541pfc.11.1699574546024; Thu, 09 Nov 2023 16:02:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699574546; cv=none; d=google.com; s=arc-20160816; b=J7PA1trmgJ72UIm2I7g+W00zz6fCW/kwsrUIGHt453um3SWCIb/ZlFFPU95qPvR/Gi nRvIyKdycu/JAWnflVE7lh6krjleZfwn5kZH92wb0iWAujm5loI/gKhMlIWZnQvNo6Si JSM2gJF4C3qYDvXldQOeMGQqMfeIvr+zw6dURGF+EfxZVzzyljw4sUVJN3nGCD7PGz6E yIMJ4Q0zC3hxTdHlMyifucsQUhnXit4hlBJyh0sc0ezKxRT0pixDoDJ3ILhBdCETY/45 ZDyUHYnCIyxuXiC9smzO2omSkWoAd8bF9RG4LOOna5W63dnU5DKoFuAhhYvPx/qHg0/5 T3bw== 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=Ey94DP/uelsbEgibz5QQXMU4gKyXrxF4jUDbY06eM9k=; fh=lVYSwwlOmXaUOYXxa+gNG5bJBJjTBONqK1hF9wIjV2E=; b=Ly3YWyfqGihqrBZim1ik9NAd3/jCSKsH1dBXxtFlKRLFmkjbrYmQeeLdNBOC9NXBCp 5nohlxpeaXOVPOIX8IlEG4CYxzqEUAg7dcMhGfJd2XJeIUHxx0n5OfGTdkerRL/mJR2Z KM1kygR1QaaEWTIXS+Tyxrriwi9B6wTq/JF2idXTcgHUmI3r/7eICYDVvkVSp3wdWnus kFdbBfZ0eV+ycP5zQpbEDHcIxpfx+JFV34t4n6mrfmm0b/MM32xKorGNq0mw2d3sli6J fFdMDJQy3VIrlowPAG474xXqvolwQwMPTA26NLFCQYidPecdfNN0gE/nv86dRZWBfNqD ykdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ephkuhv9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id u125-20020a637983000000b005b3e61af56esi7785882pgc.121.2023.11.09.16.02.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 16:02:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ephkuhv9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id A4DF3803BEB0; Thu, 9 Nov 2023 16:01:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345453AbjKJAA1 (ORCPT + 30 others); Thu, 9 Nov 2023 19:00:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234809AbjKJAAV (ORCPT ); Thu, 9 Nov 2023 19:00:21 -0500 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8888344B8; Thu, 9 Nov 2023 16:00:19 -0800 (PST) Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5bd6ac9833fso1120837a12.0; Thu, 09 Nov 2023 16:00:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699574419; x=1700179219; 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=Ey94DP/uelsbEgibz5QQXMU4gKyXrxF4jUDbY06eM9k=; b=Ephkuhv9YJ3flFd8uODkLImjUCiSTuItkx30J5PVBrnptk03z24GLYisdYEYXS953w SZsqr0hVWtPxbZ7kUrNo3SvVHwmj6qHSkeLjbAlUo5ZY0GM4b7RZqWn8HZELF71KTWC7 lwr9qeW87FN2q3f4j6/H9j+YN5e1eQIscjOIxEL5fy4W1M9fulucSDzM/FTPDN8J8w5k yYeLCMwNAXTi2Kd+jHXBGBIdiGpz2/Rwkd1Dsb1m1SIfkLE77Msr4xSgJv5L+r+rJgKT 1YDXUSSuQH17ldyeBxHwN+bb7VMAGBsSCRYMlVJaRn5BOe7prC4aD7aNB3343o9kLZzf UTsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699574419; x=1700179219; 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=Ey94DP/uelsbEgibz5QQXMU4gKyXrxF4jUDbY06eM9k=; b=uwmWVb8S1RxyiTZvlEatkp6oAZJ1GJUVu92gdrf1X2On9M18OEOR9rRs67CBR5rsma 5v9ianRYtvZ3AntdvktFEnN272MwtmK6nTbA4Lg+835qZWNOkPVlT26Bh74idEdpI8TC MD2tdw2RuQoLY2ELpIPF9zDv+dUqG3ALsHap/8a/3n/WWrG2nAIwY1cz32T1Ng4otIsU JGYue1osHSa3kraglJdvmA5d5AQekpNPcRWjwV7ZWoBW8Ey5yzhlvLL+sVZPDpy5ZSmQ KDmd0nePTqVCBjEoNlpeYbqgVrxv+llRZrRDCZaaHeFIpTu0n9ZucLEvFpNxuvJgjS5v bmpw== X-Gm-Message-State: AOJu0Ywe8yiBnvCpW4ueOBEJsZ4QVgG0QOsU06Bd13L4mPuMU/jPNoGw CJgDl4LwdGVKwYo8xO92Xw0= X-Received: by 2002:a05:6a20:441a:b0:16b:f3b1:c040 with SMTP id ce26-20020a056a20441a00b0016bf3b1c040mr8149334pzb.38.1699574418918; Thu, 09 Nov 2023 16:00:18 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 16:00:18 -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, Huacai Chen , WANG Rui Subject: [PATCH 02/52] perf annotate: Move raw_comment and raw_func_start Date: Thu, 9 Nov 2023 15:59:21 -0800 Message-ID: <20231110000012.3538610-3-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 (fry.vger.email [0.0.0.0]); Thu, 09 Nov 2023 16:01:16 -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 fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782133079439935326 X-GMAIL-MSGID: 1782133079439935326 Thoese two fields are used only for the jump_ops, so move them into the union to save some bytes. Also add jump__delete() callback not to free the fields as they didn't allocate new strings. Cc: Huacai Chen Cc: WANG Rui Signed-off-by: Namhyung Kim --- .../perf/arch/loongarch/annotate/instructions.c | 6 +++--- tools/perf/util/annotate.c | 17 +++++++++++++---- tools/perf/util/annotate.h | 6 ++++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/tools/perf/arch/loongarch/annotate/instructions.c b/tools/perf/arch/loongarch/annotate/instructions.c index 98e19c5366ac..21cc7e4149f7 100644 --- a/tools/perf/arch/loongarch/annotate/instructions.c +++ b/tools/perf/arch/loongarch/annotate/instructions.c @@ -61,10 +61,10 @@ static int loongarch_jump__parse(struct arch *arch, struct ins_operands *ops, st const char *c = strchr(ops->raw, '#'); u64 start, end; - ops->raw_comment = strchr(ops->raw, arch->objdump.comment_char); - ops->raw_func_start = strchr(ops->raw, '<'); + ops->jump.raw_comment = strchr(ops->raw, arch->objdump.comment_char); + ops->jump.raw_func_start = strchr(ops->raw, '<'); - if (ops->raw_func_start && c > ops->raw_func_start) + if (ops->jump.raw_func_start && c > ops->jump.raw_func_start) c = NULL; if (c++ != NULL) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 118195c787b9..3364edf30f50 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -340,10 +340,10 @@ bool ins__is_call(const struct ins *ins) */ static inline const char *validate_comma(const char *c, struct ins_operands *ops) { - if (ops->raw_comment && c > ops->raw_comment) + if (ops->jump.raw_comment && c > ops->jump.raw_comment) return NULL; - if (ops->raw_func_start && c > ops->raw_func_start) + if (ops->jump.raw_func_start && c > ops->jump.raw_func_start) return NULL; return c; @@ -359,8 +359,8 @@ static int jump__parse(struct arch *arch, struct ins_operands *ops, struct map_s const char *c = strchr(ops->raw, ','); u64 start, end; - ops->raw_comment = strchr(ops->raw, arch->objdump.comment_char); - ops->raw_func_start = strchr(ops->raw, '<'); + ops->jump.raw_comment = strchr(ops->raw, arch->objdump.comment_char); + ops->jump.raw_func_start = strchr(ops->raw, '<'); c = validate_comma(c, ops); @@ -462,7 +462,16 @@ static int jump__scnprintf(struct ins *ins, char *bf, size_t size, ops->target.offset); } +static void jump__delete(struct ins_operands *ops __maybe_unused) +{ + /* + * The ops->jump.raw_comment and ops->jump.raw_func_start belong to the + * raw string, don't free them. + */ +} + static struct ins_ops jump_ops = { + .free = jump__delete, .parse = jump__parse, .scnprintf = jump__scnprintf, }; diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index de59c1aff08e..bc8b95e8b1be 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -31,8 +31,6 @@ struct ins { struct ins_operands { char *raw; - char *raw_comment; - char *raw_func_start; struct { char *raw; char *name; @@ -52,6 +50,10 @@ struct ins_operands { struct ins ins; struct ins_operands *ops; } locked; + struct { + char *raw_comment; + char *raw_func_start; + } jump; }; };