From nobody Fri Dec 19 04:58:53 2025 Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 940921A0AF3 for ; Thu, 27 Jun 2024 21:36:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719524197; cv=none; b=WyVR+PnnPs4onKAExPoBzYeTi+SoOUsC+p63oFJyALfyOiGbjsrhNqrr4boFgEcvIDFs2FtIoCtm76bKXJ/xWNKiS4xUq00G4XXz9RD/hUqgvarheRbgL0D3nFADxPqldVoFZ0RW/WPWFzlPG/Pm9KoswSq5jrjQqBJa9bJHs3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719524197; c=relaxed/simple; bh=tm2qAtOdQNlYTO2ywaWXoSUkB30rmOEo3aw7bmaE1ts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Mw0Ygu/cgNfoJAsCJMu81sBvuNEfP6p4dSPN9+/MIqzJdkcXM6/KaBAiPWlgZZE0pcbxiaBskauqIWMHKbr5Y0fFZwL8a+zU607uuFdDiG9/XcKQltE9acH+9VUO/f8NTY+QEpcum7DetWQZXnujycA9/4+JbpMBkwewtq95qP4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=O7DTMkp5; arc=none smtp.client-ip=209.85.128.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="O7DTMkp5" Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-64546605546so53861457b3.1 for ; Thu, 27 Jun 2024 14:36:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1719524194; x=1720128994; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PnK5YLt2JhGzU6G905phwSviqODE09Ru0vlDtgkEIeo=; b=O7DTMkp5e00NNdSS6GRhyhvPvvDwY680qt4qfL7O3IqLKsm97Gloe24qRPZhDzBIgE js5UtTVXGerdOAPJ+lW3Tqd8HusfGIU4tbKlrhCE0KMj9h6auVVyeKz2awx7ayiLWso5 ZIwzV139m1JjkvlgVzgWnWCqYx8F/FYLYgJdsJbbMKqeJ4dBgvtixm9KpKvelG0cjl0f E4FhEN/oVVPqwKe6tndyBCv0GqqNjdug54pHVlMNfqi6aA+0bX6wATrb7NV1eQtG/2OG rXtcth+a9BGGZV+xFeBoeAJRwDlIWX33zMwiqrwNDo0NoLpKVMtA5B851mu51DahmdG3 p2Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719524194; x=1720128994; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PnK5YLt2JhGzU6G905phwSviqODE09Ru0vlDtgkEIeo=; b=U1hchgbWHaelL/2HH0eJZZSEl9QYqXu4MAeTG6hTJ+bndLaN1N8hL4UaYzz7gd6PYq nq7MK1q5FD5f+mauBxoBYLxN5fsP6ZwxLCSBpYUU0M3zW3FkMkd+vF6mRV6flmWLPUoB kaHfgZcTns8emas2qLlWSmGEJ4VeiRpQdKRR6yYDQ0qW8irXTSrnlKwIH3dOmlKywvhF Qz2lAQIO8R4oU05djJfcw2qUv+hdB/7KLSt72XDnhr2T3jAtgYUKx1ivxyJWLGw+Bozi jifXaYfVPJ2+e1P2+jrZNNaUce2PLfilaiWJidmCdoDI+LU5mXvMxQU6eCZq6nLTDIGl tj0A== X-Forwarded-Encrypted: i=1; AJvYcCXsMei478q0kti2io5NXbIOFvA+yu5LoKSAwGO8RyqVWE7cCtHUEpeESzk5+5pfYiZxqBoYVftAd8rA85h/vhLne3G5byl9XBwA+9tX X-Gm-Message-State: AOJu0YxEjH2vJKJGYr04+RZKkhnObxMJ+e9YtvLH28EoJC5BsA+Eu8R1 n37D5rRSd7EhP54clPqE3hZ9KcIriHe3cw8kxlbOs79+gcyV8VJTXOUkBRUMxbnhJ1+Ey/d8HtW eHjwdsiSp X-Google-Smtp-Source: AGHT+IEuHN7zsF1XXO6VCBRTmR+6vJjmyw3Sp+6MqTkwLAVF40y8EHrgfZrF/9bW/Ig+bhdzIqk9kQ== X-Received: by 2002:a81:7182:0:b0:631:259b:fcac with SMTP id 00721157ae682-643ab74031fmr143144307b3.31.1719524194527; Thu, 27 Jun 2024 14:36:34 -0700 (PDT) Received: from dev-cachen.dev.purestorage.com ([208.88.159.129]) by smtp.googlemail.com with ESMTPSA id 00721157ae682-64a99c717c0sm1009467b3.2.2024.06.27.14.36.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 14:36:34 -0700 (PDT) From: Casey Chen To: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: yzhong@purestorage.com, Casey Chen Subject: [PATCH] perf probe: fix missing references to maps and map in thread__find_map Date: Thu, 27 Jun 2024 15:36:18 -0600 Message-ID: <20240627213619.718-2-cachen@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627213619.718-1-cachen@purestorage.com> References: <20240627213619.718-1-cachen@purestorage.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" With 0dd5041c9a0e ("perf addr_location: Add init/exit/copy functions"), thread__find_map() would return with al->maps being NULL when cpumode is 3 (macro PERF_RECORD_MISC_HYPERVISOR), later dereferencing on it would crash. Fix is to add back the reference to maps and map. --- tools/perf/util/event.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index f32f9abf6344..259cb137e5bb 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -638,6 +638,8 @@ struct map *thread__find_map(struct thread *thread, u8 = cpumode, u64 addr, !perf_host) al->filtered |=3D (1 << HIST_FILTER__HOST); =20 + al->maps =3D maps__get(maps); + al->map =3D maps__find(maps, al->addr); return NULL; } al->maps =3D maps__get(maps); --=20 2.45.2 From nobody Fri Dec 19 04:58:53 2025 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75BAD249F9 for ; Thu, 27 Jun 2024 21:36:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719524198; cv=none; b=CJ05BfGOnm1X9AKwih6MMYG39dLkidYeDHGzrwOku5W04xibJFFCk1S4wfjeSzcfXOD4Mr861ItuHKJ2Ch4Bn1l+arp8Da0ofeISl0v0suF20F+YntXbWnNCUE2MyGLV3PGvYmET3x/Lhrj0cq3+Mh6PFkUp1lcYA3y/MahJC6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719524198; c=relaxed/simple; bh=6psedXWiVhgGXMWXvYNxOstdCMvuxEuuwfA7iWcmcGU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xe6wd6qz6nz/9M7b5I9aGm/ndGw1clItRxH1/d9zGmGRC2O5nhISBroViJBm0WU6/68knh+Ywq4n+hdNBr3wgAaTt2l/rOyzT1DvYtJFxqQCs492KZJ5VIAriTN911b2x4UaGoEEI3QEkc5QqAsqd5ngiAJDgL04Vs7deYAa8vk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=Q6qzWSJR; arc=none smtp.client-ip=209.85.128.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="Q6qzWSJR" Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-648b16e5e47so20226147b3.1 for ; Thu, 27 Jun 2024 14:36:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1719524195; x=1720128995; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qPQjFOQJrmmumJb1CUQeupQXr/aSCBOnaBJ4NRUg9Dk=; b=Q6qzWSJRSwfycBa32Af/82mcnzbvZg+2T570aJTpYnEM+yrJY/1+sUZAgzU2AGnR2e 9j4E367Kjpm288sjJW/L1wWce7z8Ka/4qmW6h16a49Cd9nAvZ3jF6b8wK9+ep91BjQm7 6HBhUaZ8ubpSY9IVu2xaoiu1gwvXJRQS6y6Mup2x97NTRasHq0iS3GkLVxwOB44aZ/vm XiAnL4I8GFsBrjVtjK1XCcQY8fXY6pfOJ6drAnXXzOXmiyFnTIy4ExkvILky0wKEBLQo Yc1upd7rXQNSYLx5R1MkCAxU3mHQh+L/oorgcNG27wcvBb4Joxmd7mhs/Tfjw7YJxa7v s3tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719524195; x=1720128995; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qPQjFOQJrmmumJb1CUQeupQXr/aSCBOnaBJ4NRUg9Dk=; b=FPhjgTxnT0GSFYdq9l/DUPySI4lrPlMfeJM9okqimjFJczQW+Wgdx5jYL10tmCdI46 D+QPsUEej9RLQFAaDiRhkRDQvGgRKkwODRHYUbFRsk8l+WGPU7FJdJ9rg29bwZItmek7 phIv61Ugf4k65O1pLDqxM5ePtN6vlBe+vFsfksa0RCGs3NUr+1diyRrZHFx///bGdj42 kMa8fM/pT8kik2PGFtEFmbtThstMEc20jKBc4oNsKqnMd+WJMitble4geoX1vsGM8V7Z cxOhMPAjk2oEdT2juTlzIU8rHvqF/Yjml8bGs89tWPDqW+TU/s4iKZYq/mAD7lDVdlke b5HQ== X-Forwarded-Encrypted: i=1; AJvYcCWjfuJatvvhmH+0RE5zW9raLLNc6O7Pddw+WroPxTHHHmdWPv4MvqToy96HhzLNj4S2BTW3kY41XvnPtXr/SqJ4+Xl0huh2drfG9JuA X-Gm-Message-State: AOJu0Yz2F4/bru9eDN80PXJGDTB2szGwY4KGnpIBIn+TNb0bN5uEd8Ao ogSOR9SM3fsqRdwMNJ0UNbiZcmL9pBupLwbeYTNAM/PfwmQvFREnJUOi3xSqg70= X-Google-Smtp-Source: AGHT+IFHmTkHBvgSC5eiv2wrJhRLko87Wrv6Oi9W77kxorbvatmvGPjjNZmZ7JeLAJnsUivsaJqVQA== X-Received: by 2002:a81:5b8a:0:b0:630:8fe1:b626 with SMTP id 00721157ae682-64341d1aaf1mr143077457b3.48.1719524195466; Thu, 27 Jun 2024 14:36:35 -0700 (PDT) Received: from dev-cachen.dev.purestorage.com ([208.88.159.129]) by smtp.googlemail.com with ESMTPSA id 00721157ae682-64a99c717c0sm1009467b3.2.2024.06.27.14.36.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 14:36:35 -0700 (PDT) From: Casey Chen To: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: yzhong@purestorage.com, Casey Chen Subject: [PATCH] debug patch for perf report segfault Date: Thu, 27 Jun 2024 15:36:19 -0600 Message-ID: <20240627213619.718-3-cachen@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627213619.718-1-cachen@purestorage.com> References: <20240627213619.718-1-cachen@purestorage.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Debug patch to apply on 0dd5041c9a0e ("perf addr_location: Add init/exit/copy functions") --- tools/perf/util/callchain.c | 4 ++++ tools/perf/util/callchain.h | 9 +++++++++ tools/perf/util/machine.c | 8 ++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index b0dafc758173..2c1d9b8ff8d9 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -1067,6 +1067,10 @@ int callchain_cursor_append(struct callchain_cursor = *cursor, node->ip =3D ip; map__zput(node->ms.map); node->ms =3D *ms; + if (ms && !ms->maps) { + pr_info("%s addr of node->ms %p ms %p has no maps map %p symbol %p= \n", + __func__, &node->ms, ms, ms->map, ms->sym); + } node->ms.map =3D map__get(node->ms.map); node->branch =3D branch; node->nr_loop_iter =3D nr_loop_iter; diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h index d95615daed73..8bba51be33a9 100644 --- a/tools/perf/util/callchain.h +++ b/tools/perf/util/callchain.h @@ -6,6 +6,7 @@ #include #include "map_symbol.h" #include "branch.h" +#include "debug.h" =20 struct addr_location; struct evsel; @@ -213,6 +214,14 @@ static inline void callchain_cursor_commit(struct call= chain_cursor *cursor) { cursor->curr =3D cursor->first; cursor->pos =3D 0; + if (cursor->curr) { + struct callchain_cursor_node *curr =3D cursor->curr; + struct map_symbol *ms =3D &curr->ms; + if (ms && !ms->maps) { + pr_info("%s: cursor %p curr %p ms %p\n", __func__, cursor, cur= r, ms); + dump_stack(); + } + } } =20 /* Cursor reading iteration helpers */ diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 9fcf357a4d53..e6c90bb6b842 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -2357,6 +2357,10 @@ static int add_callchain_ip(struct thread *thread, goto out; } thread__find_symbol(thread, *cpumode, ip, &al); + if (!al.maps) { + pr_info("%s: i'm here! al.map %p al.sym %p ip >=3D PERF_CONTEX= T_MAX: %d cpumode %d ip 0x%lx\n", + __func__, al.map, al.sym, ip >=3D PERF_CONTEXT_MAX, *c= pumode, ip); + } } =20 if (al.sym !=3D NULL) { @@ -2384,8 +2388,8 @@ static int add_callchain_ip(struct thread *thread, ms.map =3D map__get(al.map); ms.sym =3D al.sym; =20 - if (!branch && append_inlines(cursor, &ms, ip) =3D=3D 0) - goto out; +// if (!branch && append_inlines(cursor, &ms, ip) =3D=3D 0) +// goto out; =20 srcline =3D callchain_srcline(&ms, al.addr); err =3D callchain_cursor_append(cursor, ip, &ms, --=20 2.34.1