Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5617199rdb; Wed, 13 Dec 2023 14:14:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHQEaN/lUgYkTwpyiV/kGVM7T0ipLkkbMd/9RwOJNn7n4ETJgGlb8L9w/Wbkt92yG2fOjt9 X-Received: by 2002:a17:902:e80a:b0:1d0:6ffd:6e6c with SMTP id u10-20020a170902e80a00b001d06ffd6e6cmr5213496plg.100.1702505672054; Wed, 13 Dec 2023 14:14:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702505672; cv=none; d=google.com; s=arc-20160816; b=zZmBLJeZzcE32yWeSBU+vHWLEEpnbbxF0mprE2YxU2qkx/tlef3XeiF4V8Rfsg764o dlqBCGzE9YzGPJ8cr9sDaql4suMdyFdKzM32VX5rnb0xpbupCaUtIWWqiDuBG9vzF4uW y0YKv/u0jVLJuWgR0o7WbayBdA5dL2rEv+1xSq8b0F8HyJiC8tfUmxsIspfohsHnABx+ m4s95XVSk+6NLpw/314Tg9lJ3MKLXXg9tGEI2CNOGo9S3Ge11AVxHcw+Czge2UbcB1us Yb5d+ocyAnompGsFixe1V+iXEMoB3V0Dt22odlWtQgRlnS7sSMooBBwG0ZXwUgb93zqc vJCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=r0FojoxdXNYT9JjFHz3EB96fEPLwfjPrY0GUWgxKwzg=; fh=vTIVAUmUELA/z6y3u9DHnvYOsRibpKXwWQvkguqaHuc=; b=QVfeBk+jb/jB4GDuHwkdlIBuHGpzBaK/V1cd00EkESsDPagrYXQMe8aRIiT4qyRipa M51x+VzFS2y7vkMd4CUQ+GW4yWPeZOvpDsr/YXK05MAJuEzJqSjAMy8BeUD02v+S/YpT QitHfYxpB2E/8w7zI8bOu9fjr+fZuCWmvXzUdJzjYbMoHtrQLPbPyydibpd+JAfx9Cxq oUuSJi9VUvAxeoR7ZMIEPjqgLYsFsiwlu6UBGhpcg41Wjv5PcOR85sgcHrobaGTbjpaf EnaVqR8MyHentq20BaJhllzQ68f/qSy8QVE4ac/TSXiViopFHj42y2EDAiAGgueIwq/c AxUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id k9-20020a170902c40900b001cff3536eb6si10366521plk.463.2023.12.13.14.14.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 14:14:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id D3C5682BB1A2; Wed, 13 Dec 2023 14:14:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233928AbjLMWOD convert rfc822-to-8bit (ORCPT + 99 others); Wed, 13 Dec 2023 17:14:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229929AbjLMWOB (ORCPT ); Wed, 13 Dec 2023 17:14:01 -0500 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 856A9AC; Wed, 13 Dec 2023 14:14:08 -0800 (PST) Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-28b0071ae32so547620a91.0; Wed, 13 Dec 2023 14:14:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702505648; x=1703110448; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PrPkyaX0AG7+dG5o0kCvLphBtxW3qZUWNIeyMgltZ2k=; b=tWatdAZAyUZqXvJ/JZ9Ieo0c6eQD2x8BxciznFEcQFU+9MYwP2VjuQFhRbTfJwdDVo HH62xrm9BDpIoDa1pcWnXMYMAs38ujNmpViGGLgvpzfP/t+nzrdc2mL9YQNNc+5oJaoh o1qn3HuT5x1BMxCZyqhxEUrygdUaqWhRHrHqSbvLrEp17QY+NW0HFN9v9rTmITbOlOZZ ol/Pa2gozDO9tpbhm9SyfncXcwz0D6/ikoXps1a0ln43667LEJ3tH75bGIJqEcvpTo7J D+pd+EQpawUL3+CbTg9z0Dnc+6LUKT4mZgLkINNpWl4M+Psh1F6k573ei6XBaPt0mrUe 5vzA== X-Gm-Message-State: AOJu0Yyd+aMpk5VTs/DuP72xfoDO776ndZUYpTFrdfDtiIYSPdVo118i SdSdtJFqlrE7avoZI3hH+oqjOjyvrBZVxRvzPlU= X-Received: by 2002:a17:90a:6d26:b0:28a:cf4f:dad9 with SMTP id z35-20020a17090a6d2600b0028acf4fdad9mr1520579pjj.28.1702505647865; Wed, 13 Dec 2023 14:14:07 -0800 (PST) MIME-Version: 1.0 References: <20231212070547.612536-1-namhyung@kernel.org> <20231212070547.612536-3-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Wed, 13 Dec 2023 14:13:57 -0800 Message-ID: Subject: Re: [PATCH 2/3] perf unwind-libdw: Handle JIT-generated DSOs properly To: Ian Rogers Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Milian Wolff , Pablo Galindo , Fangrui Song Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Dec 2023 14:14:28 -0800 (PST) On Tue, Dec 12, 2023 at 10:07 AM Ian Rogers wrote: > > On Mon, Dec 11, 2023 at 11:05 PM Namhyung Kim wrote: > > > > Usually DSOs are mapped from the beginning of the file, so the base > > address of the DSO can be calculated by map->start - map->pgoff. > > > > However, JIT DSOs which are generated by `perf inject -j`, are mapped > > only the code segment. This makes unwind-libdw code confusing and > > rejects processing unwinds in the JIT DSOs. It should use the map > > start address as base for them to fix the confusion. > > > > Fixes: 1fe627da3033 ("perf unwind: Take pgoff into account when reporting elf to libdwfl") > > Signed-off-by: Namhyung Kim > > --- > > tools/perf/util/unwind-libdw.c | 21 +++++++++++++++++---- > > 1 file changed, 17 insertions(+), 4 deletions(-) > > > > diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c > > index 8554db3fc0d7..6013335a8dae 100644 > > --- a/tools/perf/util/unwind-libdw.c > > +++ b/tools/perf/util/unwind-libdw.c > > @@ -46,6 +46,7 @@ static int __report_module(struct addr_location *al, u64 ip, > > { > > Dwfl_Module *mod; > > struct dso *dso = NULL; > > + Dwarf_Addr base; > > /* > > * Some callers will use al->sym, so we can't just use the > > * cheaper thread__find_map() here. > > @@ -58,13 +59,25 @@ static int __report_module(struct addr_location *al, u64 ip, > > if (!dso) > > return 0; > > > > + /* > > + * The generated JIT DSO files only map the code segment without > > + * ELF headers. Since JIT codes used to be packed in a memory > > + * segment, calculating the base address using pgoff falls into > > + * a different code in another DSO. So just use the map->start > > + * directly to pick the correct one. > > + */ > > + if (!strncmp(dso->long_name, "/tmp/jitted-", 12)) > > Perhaps it would be better to test: > dso->symtab_type == DSO_BINARY_TYPE__JAVA_JIT Well.. it's a little different. The JAVA_JIT type files have "/tmp/perf-" prefix and it's a plain text file (for symbols). While this is an ELF file generated by `perf inject -j`. Thanks, Namhyung