Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp926891lqm; Wed, 1 May 2024 23:01:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWBarhfqrrxGi2Rj7EF70CKtcFj9R+ymhivO/BrKB1q7iU+r/O+e9gsXcEGZqk0jBfwlhrHFXZIzWkiniiSHz/cIrD67NFAGrnYJbfYzw== X-Google-Smtp-Source: AGHT+IE1MPxcYAgpr3aZ/iNvswpJP3ekZebzaaVp/xa7DB65IRzMolka0KbOi5UdxB35L8fGYdJ3 X-Received: by 2002:a05:6359:410e:b0:18e:a0ce:a35c with SMTP id kh14-20020a056359410e00b0018ea0cea35cmr6166405rwc.14.1714629683803; Wed, 01 May 2024 23:01:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714629683; cv=pass; d=google.com; s=arc-20160816; b=Qv4DgL3smFYk+9wRMvtCCK0oS4TS2vW5/LWbgwFKP/ZUj1xXruXUYqlYMOcQaOgNqd AC1w/Sgnhq/C2u+wVrY1M8cVqoHlQH4seWMCmKkY3HBRAiPjVy+ofZMNgV5PhnC+HiEC o1kUJrGPhhzlf24Se5S+y5Zfhm8BxS/WQg391kgQv2T66J8MB0GcWkMSjVROBM7SlEtC s/+6UxW+XpHLF3CfHi1LxMIGJyn34E2Ez0W5HZmLr2o2RiOBsNrN/3hgykM7eDVOPEGR 0L91Ax9VoyJtf33l8gkTnZtjlI9hgR/COtEjondNmmSfSPGJQE/NByVQceRnLQlVRFxO A73w== 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=s7gCehxVxkNd2dmKvoaDhzVnupdXQ9o5SCx7dKN55g0=; fh=fHhbvXgCev/wpffLVpfaAi8pPyv7hrTyhVPgsZ7HNrs=; b=UIrx2rVxVYz9pLU6wt4rBsxSfI1y4QmE2dCNtykTqBPn2GelNX3cMBL1NO8GX8vR9o P1OCFcwNT/OhyFd4cGS97b6a7PNeXxHWHgP1VtxSiNmc0jQx4FZTE5RotBHIpsn+F2Hp Z1hHlxcjfHaoEjyHtP0s7WgZqHBQlX5RuRXoVrVHAccAPiXYUjvL+f55W50qy5P5++Yg liNIeSAr7m99I3yTrfS6KAMhL3JcXQI9YMDAbON6xT/ob+lwIrqxXWUM0yPXnmlELzUG zRvyrNYf58LrM0/bYhhYYTVSzoOdo96wwJeZoC7a27qMD/8HoTHCNV+pSqBOOfWJFCAi UW0A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Hs5/Y1gp"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165999-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165999-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j38-20020a635966000000b00604e40426c3si378831pgm.882.2024.05.01.23.01.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 23:01:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165999-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Hs5/Y1gp"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165999-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165999-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 55757283B5B for ; Thu, 2 May 2024 06:01:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 612F342071; 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="Hs5/Y1gp" 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 42A9C36AFE; 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=XRQywEQcnbZcTlY+BnwepoJZFxpt6qYd3qDwmI9zhmbn5A9N/nLQRTTwSooIlHHaPmKY6Q/paqEXQDcU5mT0RUt1DQ+YwRpTyjviuZojyhboKeMcXGhwXUBcUa4k6YszaNEOJ7qyWksGMLWM2MMHnZWRnHtVVesU5557Hw5KW+w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714629616; c=relaxed/simple; bh=wBhNx/ENJ3dtDGzKbOpBhB0k32mIboB/9iNKvY4VhfM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cM1Ow5beb7dNMbXmVOtzdWG+ju13aoggIW+wunG7cF2BPdj8ffHdcK7csp/mgs78mNHvm4uhOtj2460/VRhhvmGMsiEoDweV3+SfTugYaqtNyMQs95yr4ngMyv+OtOOiVp4nNQl8/roGzBw/4ehLOGdIDNl1WbjZP/PT0e7iyyU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Hs5/Y1gp; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E0E4C4AF51; Thu, 2 May 2024 06:00:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714629615; bh=wBhNx/ENJ3dtDGzKbOpBhB0k32mIboB/9iNKvY4VhfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hs5/Y1gpP3uEtaJBKNPkmeW54B0HZW29fmbLYQfgRdTIzAlU7pwW5SYG/ob3egHyH gXmEt7gK/0KqbWJZuWM5FFiglpXX4ajDpzzhlJI976gdpCh8LZGKxYCyu+3qFb53Ah GNCOSziTp/RR80ifewaD9o6rjkLPzZvr0UGYeUVus9lMv5jOSNowvgTwI9WDNgtIL8 OfU16zQwbIkxo0WpKdQ/W9axKErlQyoGuinKDK63TOyLLqgQArVx9UOpA8UXqJf1qy bkYuz4uSF9hfUBEjXKd5v0+18n6SQIkMFNaFud5kOXFGx/vk9aKHqQY9Hij/5Zols8 KFv90TiSXgUfg== 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 6/6] perf annotate-data: Check kind of stack variables Date: Wed, 1 May 2024 23:00:11 -0700 Message-ID: <20240502060011.1838090-7-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 I sometimes see ("unknown type") in the result and it was because it didn't check the type of stack variables properly during the instruction tracking. The stack can carry constant values (without type info) and if the target instruction is accessing the stack location, it resulted in the "unknown type". Maybe we could pick one of integer types for the constant, but it doesn't really mean anything useful. Let's just drop the stack slot if it doesn't have a valid type info. Here's an example how it got the unknown type. Note that 0xffffff48 = -0xb8. ----------------------------------------------------------- find data type for 0xffffff48(reg6) at ... CU for ... frame base: cfa=0 fbreg=6 scope: [2/2] (die:11cb97f) bb: [37 - 3a] var [37] reg15 type='int' size=0x4 (die:0x1180633) bb: [40 - 4b] mov [40] imm=0x1 -> reg13 var [45] reg8 type='sigset_t*' size=0x8 (die:0x11a39ee) mov [45] imm=0x1 -> reg2 <--- here reg2 has a constant bb: [215 - 237] mov [218] reg2 -> -0xb8(stack) constant <--- and save it to the stack mov [225] reg13 -> -0xc4(stack) constant call [22f] find_task_by_vgpid call [22f] return -> reg0 type='struct task_struct*' size=0x8 (die:0x11881e8) bb: [5c8 - 5cf] bb: [2fb - 302] mov [2fb] -0xc4(stack) -> reg13 constant bb: [13b - 14d] mov [143] 0xd50(reg3) -> reg5 type='struct task_struct*' size=0x8 (die:0xa31f3c) bb: [153 - 153] chk [153] reg6 offset=0xffffff48 ok=0 kind=0 fbreg <--- access here found by insn track: 0xffffff48(reg6) type-offset=0 type='G^KU' size=0 (die:0xffffffffffffffff) Signed-off-by: Namhyung Kim --- tools/perf/util/annotate-data.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c index 68fe7999f033..2c98813f95cd 100644 --- a/tools/perf/util/annotate-data.c +++ b/tools/perf/util/annotate-data.c @@ -1314,6 +1314,9 @@ static int check_matching_type(struct type_state *state, return -1; } + if (stack->kind != TSR_KIND_TYPE) + return 0; + *type_die = stack->type; /* Update the type offset from the start of slot */ dloc->type_offset -= stack->offset; @@ -1343,6 +1346,9 @@ static int check_matching_type(struct type_state *state, return -1; } + if (stack->kind != TSR_KIND_TYPE) + return 0; + *type_die = stack->type; /* Update the type offset from the start of slot */ dloc->type_offset -= fboff + stack->offset; -- 2.45.0.rc1.225.g2a3ae87e7f-goog