Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp926867lqm; Wed, 1 May 2024 23:01:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVixao3sT5Es3FzCfIdxtfJTjgF5aMWilDt1mxxmB6XYk5ZlqqUexRWWKU3HHDzgzsjkQJudTcPbVtXqt1LzUh9Gem8LAlb5G2xXyMYwA== X-Google-Smtp-Source: AGHT+IEYIaHCEJkxOXo3y8ZhDV4MJuS/wvLCssTw8kbrR2qs15EuZNYrM7fo8SqPNT1gfMNHwxKP X-Received: by 2002:ac8:5754:0:b0:43a:b324:1a22 with SMTP id 20-20020ac85754000000b0043ab3241a22mr5487673qtx.57.1714629681940; Wed, 01 May 2024 23:01:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714629681; cv=pass; d=google.com; s=arc-20160816; b=tCloOW8a/JPjkG/aZ31su2ROWPF2gZycLp08MK6IGM23x0ynVoIDYk7hZjwu0BX7TT I9osKFWtax+nsyLhQNCK8jfnUCDIoWKg56zYpoqaBFWF1nsT1Ij+GKuCp3P7hXttVSy3 YMu1MTHXWDxWDRBeJp6Due+KIZIA6ZuSpoisvQvNk5Pfo0hEeOwYU/sBR6TjPCFKYuV0 KmeluOjQsqqZ+uzyyslDkir3kNVkeTkqEUzjPQQE39tnWO+CpgrX24vczlYsUVPYBAzd 3xeVdFo7V0i7ro5/zQA0QCySvavNMMF+nS3F/64R2VCMQQwA0Nzt1mmNKhyz0Od4K0MQ gA1A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=StMXYHrhM98v7tzmfZ0MxlZUO9Sbi4378pkPvSAG2ZM=; fh=fHhbvXgCev/wpffLVpfaAi8pPyv7hrTyhVPgsZ7HNrs=; b=nKqHAUMQ9q8vU/kUqkjyQKbqGQlJ8dMSIfK/Q6uiNhCAgf90X7GzbjwKpfHWeeTQSb 7ulzUX8eRuyVl3zynA5IYBRRTVLzpoJ395LnWL/tT8MmcS/F1g9kmUweWYsSkT2Tzx/H SJGDDSvyXG48soTCyPX0DrmaUT+Uhn7lKK77+u2630ZOgK0cFwy9h1KwUfPtIBK9LGbL /n+wv93SHAXiDsJiYYyrbvES33L4XgmMUmcFQUU+cXSaQNm/00OA8TqwB8+MBXiAYjEz 7DZyGdrdvfExfXtFautseG4pBuDDVPuXcrFxFF7O/sl9lqnQuHJ1nc0fHuzOmS5nwr4L /+hw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KcVhjvN2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165998-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165998-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y13-20020a05622a164d00b0043cb229801asi304763qtj.181.2024.05.01.23.01.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 23:01:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165998-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KcVhjvN2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165998-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165998-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 648C71C214FD for ; Thu, 2 May 2024 06:01:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C73B42077; Thu, 2 May 2024 06:00:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KcVhjvN2" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE58E2E85A; Thu, 2 May 2024 06:00:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714629616; cv=none; b=QiCxMvYyjpUypR2kJ9jCh+hIj3LJUmSkB/kzKMxP0nt0A2EsH3MAtLPjoNJ9/y6bfWqfO7TmdDEl0vpP1oHV5skaj4yV3hKt3FymRcDn2LIHNp5SpvmYgWqcVdDBlyuN64iQl07rPu1EiTgRQjXnZikQwnvClIzV3V7JZdBEAW4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714629616; c=relaxed/simple; bh=bBO0Iqelj8fza63egsoXJuy9RT4wZZVSdAOcjGFLV54=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=paoekKwzETUW5bQdITTdUx6dEwEbXB+s+REXMX71wrh8u16Lson5nREFpzgfSS6YSsEujeDXp8T1DY2z5aGc8HVMg8XCFhRUaL2K85/Qxdx0UDuN9ZjAcmEOxa5vFGB3SvFnsPe7Fh9NGYZzw+WIGozLCBkyjS5kxx+GfR/HovM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KcVhjvN2; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05AD4C4AF61; Thu, 2 May 2024 06:00:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714629615; bh=bBO0Iqelj8fza63egsoXJuy9RT4wZZVSdAOcjGFLV54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KcVhjvN2Q/IIksoC2T2K7yei0Za/gHqV7wMwhTWBGaCBSyeoaG57Ii30mBmJ9WbwV Y4Y16Sazd9ilTIic/WJW3Gyfxoc3iU4pnXI8R4WRVDMkXwVUQpRw456ILHTP2PsL/S 3L4I5LA3SmBEJF+aC+ifJZUsUArPtf3Nia4Ye8ITNgvvJ0T/UsuQnWWS1+kVkTtz96 T6Pvq5XBxjDzCYombLd5K6dzK2Gklq45Ah7JhUV0uZ3pfT91/2tB8RGv6QQEfzMuBK n+HbjKb6VbbkMgO8PoFiN5vE4q/G0MMmu4rEm4ELFRd/yULipOt3soCKtmYsVhjM6Y TveN+kZdfXZuA== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH 5/6] perf annotate-data: Handle multi regs in find_data_type_block() Date: Wed, 1 May 2024 23:00:10 -0700 Message-ID: <20240502060011.1838090-6-namhyung@kernel.org> X-Mailer: git-send-email 2.45.0.rc1.225.g2a3ae87e7f-goog In-Reply-To: <20240502060011.1838090-1-namhyung@kernel.org> References: <20240502060011.1838090-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The instruction tracking should be the same for the both registers. Just do it once and compare the result with multi regs as with the previous patches. Then we don't need to call find_data_type_block() separately for each reg. Let's remove the 'reg' argument from the relevant functions. Signed-off-by: Namhyung Kim --- tools/perf/util/annotate-data.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c index 245e3ef3e2ff..68fe7999f033 100644 --- a/tools/perf/util/annotate-data.c +++ b/tools/perf/util/annotate-data.c @@ -1258,11 +1258,12 @@ static void setup_stack_canary(struct data_loc_info *dloc) * are similar to global variables and no additional info is needed. */ static int check_matching_type(struct type_state *state, - struct data_loc_info *dloc, int reg, + struct data_loc_info *dloc, Dwarf_Die *cu_die, Dwarf_Die *type_die) { Dwarf_Word size; u32 insn_offset = dloc->ip - dloc->ms->sym->start; + int reg = dloc->op->reg1; pr_debug_dtp("chk [%x] reg%d offset=%#x ok=%d kind=%d", insn_offset, reg, dloc->op->offset, @@ -1448,7 +1449,7 @@ static int check_matching_type(struct type_state *state, } /* Iterate instructions in basic blocks and update type table */ -static int find_data_type_insn(struct data_loc_info *dloc, int reg, +static int find_data_type_insn(struct data_loc_info *dloc, struct list_head *basic_blocks, struct die_var_type *var_types, Dwarf_Die *cu_die, Dwarf_Die *type_die) @@ -1481,7 +1482,7 @@ static int find_data_type_insn(struct data_loc_info *dloc, int reg, update_var_state(&state, dloc, addr, dl->al.offset, var_types); if (this_ip == dloc->ip) { - ret = check_matching_type(&state, dloc, reg, + ret = check_matching_type(&state, dloc, cu_die, type_die); goto out; } @@ -1502,7 +1503,7 @@ static int find_data_type_insn(struct data_loc_info *dloc, int reg, * Construct a list of basic blocks for each scope with variables and try to find * the data type by updating a type state table through instructions. */ -static int find_data_type_block(struct data_loc_info *dloc, int reg, +static int find_data_type_block(struct data_loc_info *dloc, Dwarf_Die *cu_die, Dwarf_Die *scopes, int nr_scopes, Dwarf_Die *type_die) { @@ -1550,7 +1551,7 @@ static int find_data_type_block(struct data_loc_info *dloc, int reg, fixup_var_address(var_types, start); /* Find from start of this scope to the target instruction */ - found = find_data_type_insn(dloc, reg, &basic_blocks, var_types, + found = find_data_type_insn(dloc, &basic_blocks, var_types, cu_die, type_die); if (found > 0) { char buf[64]; @@ -1716,8 +1717,13 @@ static int find_data_type_die(struct data_loc_info *dloc, Dwarf_Die *type_die) goto out; } + if (loc->multi_regs && reg == loc->reg1 && loc->reg1 != loc->reg2) { + reg = loc->reg2; + goto retry; + } + if (reg != DWARF_REG_PC) { - ret = find_data_type_block(dloc, reg, &cu_die, scopes, + ret = find_data_type_block(dloc, &cu_die, scopes, nr_scopes, type_die); if (ret == 0) { ann_data_stat.insn_track++; @@ -1725,11 +1731,6 @@ static int find_data_type_die(struct data_loc_info *dloc, Dwarf_Die *type_die) } } - if (loc->multi_regs && reg == loc->reg1 && loc->reg1 != loc->reg2) { - reg = loc->reg2; - goto retry; - } - if (ret < 0) { pr_debug_dtp("no variable found\n"); ann_data_stat.no_var++; -- 2.45.0.rc1.225.g2a3ae87e7f-goog