Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp964107lqs; Fri, 14 Jun 2024 10:27:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVbueFGzdBqcL5ePe3o1opuEYce50/w9GQhx/4/jpu4Or98s0t6lhuH70moPlA9t4NyqpXuKVDPePE14TdIc3jkxnDCyblG/8Ti3mJuZg== X-Google-Smtp-Source: AGHT+IHKS9eXT1nfwJj/jZWqyesAUKJIqr0GyPmehrT3wugO9bK7ILe7wj35k9QizF+aK0Sex7dQ X-Received: by 2002:aa7:c3d0:0:b0:57c:c694:d4b7 with SMTP id 4fb4d7f45d1cf-57cc694d54dmr1275791a12.16.1718386039682; Fri, 14 Jun 2024 10:27:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718386039; cv=pass; d=google.com; s=arc-20160816; b=VvDa7GfsVwzI9JWI+xnHjpyhpJFd4SkaCuHJtUkw4hSke9dwwK3n3rhk16Ne0IW7gi nwk3C3+j12TyACbyI3Z60K1xnp5YgysAC9xN/OVVcttw738uDfSbbs3Yl/q7FxGlT4Df qouy/bZo8zGosJUEH7sTmKcYdx1pNrbH4IRaz0SdhfFOisInUcVDgIfjbgNEjwS0ZrLq Rkhl7VDYDZHn0CVbsED3AAGcOsMMjQcdkP9RVlqWa6PC3SogZZ9mLNo9IE0oKPSjRcuz 15+2pi7QNxC2pCfkyBZXnyn6aEK2TvLPN2xCLqgA0SZwPzDH8wl521ZK75VycgjLG+pz 6ykg== 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=co57nuNrHPYEE66TT44hKD3LaG//aQrqYGNHuVsyeuY=; fh=0PTwb2dctJdgxxdpEHLw2xTRIlYCAL+sOxDjzSKR2y4=; b=Zqc/iCJj2obOmzUdfX+iYsFM7iB51zQ5BEN/d3QzE2nA8WZqvWwqvQjAWpOGKuX6+r nMvsRRFo3KIahCODf19wMafEyoP2LzcsHHcZrFSRAPPIB3R1aqiIY0cVXCfyUwEEEVH/ THS2aD3lt1E7X3PiDhwEPrTzJOMq0u244jiZHhIPF2pGz0TTed3+TevDvyNEHRFD+w/q QXn6s85Wtf6WsskrcGEEuCmcbpzGlcePibHQNGwxMQwdkZzWUd+EE+3kmVC4JiZcbTrP fpUcPupjo/miQyD1TIwZ+vZTJon8GCa9Ecr0W2zuG0f+LwBWa4VMbZN5/tZRMsPMgH3f dQgQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=HLV12VmY; arc=pass (i=1 dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.vnet.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-215338-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215338-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57cbef298dcsi997169a12.490.2024.06.14.10.27.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 10:27:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215338-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=HLV12VmY; arc=pass (i=1 dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.vnet.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-215338-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215338-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id A2A4D1F21C77 for ; Fri, 14 Jun 2024 17:27:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8071B19D09C; Fri, 14 Jun 2024 17:27:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="HLV12VmY" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 B2B0C9441; Fri, 14 Jun 2024 17:27:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718386027; cv=none; b=BuuIdKXCqFRZ/SdUOtP2SUsutvzM9ZtVhu2ionogF737beTdOeSCIegDG2XGGeDrljSZFzTOlPX8uPXi0KqirGYv4scMdtAImDKLrIJd5k7vz/Gk/7KX8mtMlyIefu95IvtDxe7jP92V7SH0zaXOuN98b/b+tW2KeCK5fRXWDHU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718386027; c=relaxed/simple; bh=T1z7IECuKP+etDpZmtJwL6v9sd6XGtj1+Jyyq7XS2gE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MRb3bSMgbkvEBPYmDty9oY4OFW0U9femD4GZaVjUeeHfdpjJTklk20OqERUm2lerdeTrTLHgNYHcCsjNxtIeOyoOiZ65yKtABWgvqrJSIwxblJPquzaEnJYLtopLtFsJp+2iriC+n6OIVThDT5Ns+yVx6GrZAsKbB6tjenKSOi8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.vnet.ibm.com; spf=none smtp.mailfrom=linux.vnet.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=HLV12VmY; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.vnet.ibm.com Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45EGcJie010803; Fri, 14 Jun 2024 17:26:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=co57nuNrHPYEE 66TT44hKD3LaG//aQrqYGNHuVsyeuY=; b=HLV12VmYsrfWJd1ExrQiGO+/A1uz6 L6ihSadu0clIsJw1ADki2PQXH6N9eZ2Oz00xlNdAA1WiUZWD/wlW7CnzdDeSJjLr 9CBRLrvzZ/dLdUaeUw5nTTM7wN2jzSvawqViS3Xuk8Tj2M8adYvzyl2BqeQhTCK6 34Tq5yBvoHiJl0BOkQoiHpPUSSo4/ZqPfwCC9yEB7pLodE4SY5CDCpER0uJTk11g 0fpt4s9o06b/hE2BLcLr4plQspWpiMpFJD9UHMJ72vHp9z0E02XEqH1IZDb4zskl JQBEDyi6j0ZT26wqkDn4zsZvAbpJkywjRSWBrAEuRcDbq/frpJQZHbE7Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yrsja85en-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 14 Jun 2024 17:26:51 +0000 (GMT) Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45EHQoXF025347; Fri, 14 Jun 2024 17:26:50 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yrsja85ek-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 14 Jun 2024 17:26:50 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45EGGQcR027246; Fri, 14 Jun 2024 17:26:50 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yn211kkwc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 14 Jun 2024 17:26:50 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45EHQiTG44761564 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jun 2024 17:26:46 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 385E720040; Fri, 14 Jun 2024 17:26:44 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5D44420043; Fri, 14 Jun 2024 17:26:41 +0000 (GMT) Received: from localhost.localdomain (unknown [9.43.82.18]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 14 Jun 2024 17:26:41 +0000 (GMT) From: Athira Rajeev To: acme@kernel.org, jolsa@kernel.org, adrian.hunter@intel.com, irogers@google.com, namhyung@kernel.org, segher@kernel.crashing.org, christophe.leroy@csgroup.eu Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, akanksha@linux.ibm.com, maddy@linux.ibm.com, atrajeev@linux.vnet.ibm.com, kjain@linux.ibm.com, disgoel@linux.vnet.ibm.com Subject: [V4 01/16] tools/perf: Move the data structures related to register type to header file Date: Fri, 14 Jun 2024 22:56:16 +0530 Message-Id: <20240614172631.56803-2-atrajeev@linux.vnet.ibm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20240614172631.56803-1-atrajeev@linux.vnet.ibm.com> References: <20240614172631.56803-1-atrajeev@linux.vnet.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Tvpa_wW7tyV71PHvIjkvWyrZIoMo3Nbb X-Proofpoint-GUID: HNOsJHHA5Qd4NzxTP-6t7ZJkVXE-r85L X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-14_15,2024-06-14_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 lowpriorityscore=0 mlxscore=0 adultscore=0 clxscore=1015 suspectscore=0 spamscore=0 mlxlogscore=999 impostorscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406140119 Data type profiling uses instruction tracking by checking each instruction and updating the register type state in some data structures. This is useful to find the data type in cases when the register state gets transferred from one reg to another. Example, in x86, "mov" instruction and in powerpc, "mr" instruction. Currently these structures are defined in annotate-data.c and instruction tracking is implemented only for x86. Move these data structures to "annotate-data.h" header file so that other arch implementations can use it in arch specific files as well. Signed-off-by: Athira Rajeev --- tools/perf/util/annotate-data.c | 53 +------------------------------ tools/perf/util/annotate-data.h | 55 +++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 52 deletions(-) diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c index 965da6c0b542..a4c7f98a75e3 100644 --- a/tools/perf/util/annotate-data.c +++ b/tools/perf/util/annotate-data.c @@ -31,15 +31,6 @@ static void delete_var_types(struct die_var_type *var_types); -enum type_state_kind { - TSR_KIND_INVALID = 0, - TSR_KIND_TYPE, - TSR_KIND_PERCPU_BASE, - TSR_KIND_CONST, - TSR_KIND_POINTER, - TSR_KIND_CANARY, -}; - #define pr_debug_dtp(fmt, ...) \ do { \ if (debug_type_profile) \ @@ -140,49 +131,7 @@ static void pr_debug_location(Dwarf_Die *die, u64 pc, int reg) } } -/* - * Type information in a register, valid when @ok is true. - * The @caller_saved registers are invalidated after a function call. - */ -struct type_state_reg { - Dwarf_Die type; - u32 imm_value; - bool ok; - bool caller_saved; - u8 kind; -}; - -/* Type information in a stack location, dynamically allocated */ -struct type_state_stack { - struct list_head list; - Dwarf_Die type; - int offset; - int size; - bool compound; - u8 kind; -}; - -/* FIXME: This should be arch-dependent */ -#define TYPE_STATE_MAX_REGS 16 - -/* - * State table to maintain type info in each register and stack location. - * It'll be updated when new variable is allocated or type info is moved - * to a new location (register or stack). As it'd be used with the - * shortest path of basic blocks, it only maintains a single table. - */ -struct type_state { - /* state of general purpose registers */ - struct type_state_reg regs[TYPE_STATE_MAX_REGS]; - /* state of stack location */ - struct list_head stack_vars; - /* return value register */ - int ret_reg; - /* stack pointer register */ - int stack_reg; -}; - -static bool has_reg_type(struct type_state *state, int reg) +bool has_reg_type(struct type_state *state, int reg) { return (unsigned)reg < ARRAY_SIZE(state->regs); } diff --git a/tools/perf/util/annotate-data.h b/tools/perf/util/annotate-data.h index 0a57d9f5ee78..ef235b1b15e1 100644 --- a/tools/perf/util/annotate-data.h +++ b/tools/perf/util/annotate-data.h @@ -6,6 +6,9 @@ #include #include #include +#include "dwarf-aux.h" +#include "annotate.h" +#include "debuginfo.h" struct annotated_op_loc; struct debuginfo; @@ -15,6 +18,15 @@ struct hist_entry; struct map_symbol; struct thread; +enum type_state_kind { + TSR_KIND_INVALID = 0, + TSR_KIND_TYPE, + TSR_KIND_PERCPU_BASE, + TSR_KIND_CONST, + TSR_KIND_POINTER, + TSR_KIND_CANARY, +}; + /** * struct annotated_member - Type of member field * @node: List entry in the parent list @@ -142,6 +154,48 @@ struct annotated_data_stat { }; extern struct annotated_data_stat ann_data_stat; +/* + * Type information in a register, valid when @ok is true. + * The @caller_saved registers are invalidated after a function call. + */ +struct type_state_reg { + Dwarf_Die type; + u32 imm_value; + bool ok; + bool caller_saved; + u8 kind; +}; + +/* Type information in a stack location, dynamically allocated */ +struct type_state_stack { + struct list_head list; + Dwarf_Die type; + int offset; + int size; + bool compound; + u8 kind; +}; + +/* FIXME: This should be arch-dependent */ +#define TYPE_STATE_MAX_REGS 32 + +/* + * State table to maintain type info in each register and stack location. + * It'll be updated when new variable is allocated or type info is moved + * to a new location (register or stack). As it'd be used with the + * shortest path of basic blocks, it only maintains a single table. + */ +struct type_state { + /* state of general purpose registers */ + struct type_state_reg regs[TYPE_STATE_MAX_REGS]; + /* state of stack location */ + struct list_head stack_vars; + /* return value register */ + int ret_reg; + /* stack pointer register */ + int stack_reg; +}; + #ifdef HAVE_DWARF_SUPPORT /* Returns data type at the location (ip, reg, offset) */ @@ -160,6 +214,7 @@ void global_var_type__tree_delete(struct rb_root *root); int hist_entry__annotate_data_tty(struct hist_entry *he, struct evsel *evsel); +bool has_reg_type(struct type_state *state, int reg); #else /* HAVE_DWARF_SUPPORT */ static inline struct annotated_data_type * -- 2.43.0