Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5337409rwd; Tue, 23 May 2023 23:38:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5VxMMibp7k4c0jQgg1+v09yaEJxQtrKJuG+ZjbgH9kvT7ShTOJu3FI5gqkNemvzCkLoDYf X-Received: by 2002:a17:90a:6e0d:b0:255:d86c:baec with SMTP id b13-20020a17090a6e0d00b00255d86cbaecmr1178896pjk.46.1684910294137; Tue, 23 May 2023 23:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684910294; cv=none; d=google.com; s=arc-20160816; b=sKvT14t1Msop7sqe5ons8PsidbRl8fq3J0UdLsqMMlL+HllbpdYuweIccDK74EUUkg MRhgqI0of4j+7iHbHtVRJ8v0NbGo/MDIkSJWIVquBNlI5lugxEb0adsrgVM6MjQFKWce QgaU2UmENzJINec5lFomhzsHawV4jrze+Z5RL7R7fIe6qRutA6q2EJyZ6mXp+ESL9K2T zUX6jQDytu34jMtAUrgwQ0SvG7upJE+yCTgyxgMwI9jBGgEFaVp61zgU9qhINrjh7stk McbS3Y0aTfVJNL9jI/9gT1gxuMqa2BPc6cu2wx0jFyZkcmi5XEquI5FAlN3DgtAtgDMA ztbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=FRxwRtcr1/ScoI159Ks1cKJ3AGr7MNst7lDOXoOCA4w=; b=0OI+FtMnS09kZA9tMCK9wHZKxzbCmFlrIyIawSo2gbBGSUU0iXWDPjhjDFkXSpOHOH 46HT8p7g574BSAZc3y8gTiQARtlZmHfusccVzyikRs+3zD1/oQ/clZN+DuwBl0Pfhg6S vfa27f8Vi5XOjvgGki+sGQiQ8yXpEKtvHoRPyuY7RXYcceJSj4nbFO7bKCJtnzWk7DDT HjO4thOP7s6jjkzBN6YBFZBwbzmC3MNlJHeOx99PHwTEM8mmkNth58Yz+OnUUoefr+5/ Dsccos7KLCJZH8HYbMj/w7nmgMEnIAcD4z3us0BAkC3uhYyRqVzr85AP2+YocuqRQlpX ZUAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="C/Dzk0WT"; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f28-20020a63755c000000b00530b6228f91si7862711pgn.895.2023.05.23.23.38.01; Tue, 23 May 2023 23:38:13 -0700 (PDT) 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=@intel.com header.s=Intel header.b="C/Dzk0WT"; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239602AbjEXGLd (ORCPT + 99 others); Wed, 24 May 2023 02:11:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231889AbjEXGLc (ORCPT ); Wed, 24 May 2023 02:11:32 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39CAB132; Tue, 23 May 2023 23:11:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684908691; x=1716444691; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=O8+zjVGkmsV8WxLXPH1S//zGH1GxEA5OLj1YtPlPvMQ=; b=C/Dzk0WTSPlNJ1JNwR6ESwKGSnhYnfddFfRiEwD8cjYfzlewLxs4Trzu WTi5MOPPxdcdX488EO3uEi2HETFOkufR7kUmzoMelns0OGM1S5j2+J4Rt A+//nBTMII+JTgLXNDbOMOGO2+YuO0LwIcJ5LrTL4pMmOH+DGG57dfZU1 /nsoGfkrdxgRc83lOaH/oo5sc8oaERcMBUDR74wTMpazI3G70MOeIH2Cy KL1Uzslkil9F6FRTOWV7MD4FG7KySW+MpiM+4OhDJJsro6Q1sRwfeQZG/ s8xT0l071PqoiVyAIsdTafsZ6WgT9TcYXf6YtLnXEC1yC0F8dVoWXYgsX Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="352313648" X-IronPort-AV: E=Sophos;i="6.00,188,1681196400"; d="scan'208";a="352313648" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2023 23:11:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="735039598" X-IronPort-AV: E=Sophos;i="6.00,188,1681196400"; d="scan'208";a="735039598" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO [10.0.2.15]) ([10.251.223.197]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2023 23:11:27 -0700 Message-ID: Date: Wed, 24 May 2023 09:11:23 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.11.0 Subject: Re: [PATCH 1/2] perf annotate: Handle x86 instruction suffix generally Content-Language: en-US To: Namhyung Kim , Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ian Rogers , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Andi Kleen , Masami Hiramatsu , Kan Liang References: <20230524052834.1041418-1-namhyung@kernel.org> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki In-Reply-To: <20230524052834.1041418-1-namhyung@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On 24/05/23 08:28, Namhyung Kim wrote: > Most of x86 instructions can have size suffix like b, w, l or q. (AT&T mnemonics) > Instead of adding all these instructions in the table, we can handle > them in a general way. For example, it can try to find an instruction > as is. If not found, it'd try again without the suffix if it's one of > the allowed suffixes. I guess it might be possible that xyz is in the table but xyz is a completely different instruction? > > Signed-off-by: Namhyung Kim > --- > tools/perf/util/annotate.c | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c > index b708bbc49c9e..7f05f2a2aa83 100644 > --- a/tools/perf/util/annotate.c > +++ b/tools/perf/util/annotate.c > @@ -70,6 +70,7 @@ struct arch { > struct ins_ops *(*associate_instruction_ops)(struct arch *arch, const char *name); > bool sorted_instructions; > bool initialized; > + const char *insn_suffix; > void *priv; > unsigned int model; > unsigned int family; > @@ -179,6 +180,7 @@ static struct arch architectures[] = { > .init = x86__annotate_init, > .instructions = x86__instructions, > .nr_instructions = ARRAY_SIZE(x86__instructions), > + .insn_suffix = "bwlq", > .objdump = { > .comment_char = '#', > }, > @@ -720,6 +722,26 @@ static struct ins_ops *__ins__find(struct arch *arch, const char *name) > } > > ins = bsearch(name, arch->instructions, nmemb, sizeof(struct ins), ins__key_cmp); > + if (ins) > + return ins->ops; > + > + if (arch->insn_suffix) { > + char tmp[32]; > + char suffix; > + size_t len = strlen(name); > + > + if (len == 0 || len >= sizeof(tmp)) > + return NULL; > + > + suffix = name[len - 1]; > + if (strchr(arch->insn_suffix, suffix) == NULL) > + return NULL; > + > + strcpy(tmp, name); > + tmp[len - 1] = '\0'; /* remove the suffix and check again */ > + > + ins = bsearch(tmp, arch->instructions, nmemb, sizeof(struct ins), ins__key_cmp); > + } > return ins ? ins->ops : NULL; > } >