From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7093DC001DD for ; Mon, 3 Jul 2023 18:32:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231260AbjGCScp (ORCPT ); Mon, 3 Jul 2023 14:32:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231292AbjGCScl (ORCPT ); Mon, 3 Jul 2023 14:32:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 941E910CE for ; Mon, 3 Jul 2023 11:32:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2892160FFB for ; Mon, 3 Jul 2023 18:32:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EA77C433C7; Mon, 3 Jul 2023 18:32:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1688409154; bh=biAe+KgJdd4IMVjrQugbzTh6QabpKTXIPhNVezqwWGQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lUxsisnPmglbuQQa7POTo4w+XFzxwmJ5PxJs5lWoQpZfzAhi5XR7XuZJd8W8H0Yrb KRebXnmNmTVUEA0geAkuUqgC6ibjrYyEDThYxe1Fsw7tk/4aSYhBUukqjv/TkPtyuq QTPALA6wXWJRs92E12k0eLkNhna9vzu9OW+Z2yU4= Date: Mon, 3 Jul 2023 20:32:32 +0200 From: Greg KH To: Krister Johansen Cc: stable@vger.kernel.org, Arnaldo Carvalho de Melo , Adrian Hunter , Alexander Shishkin , David Reaver , Ian Rogers , Jiri Olsa , Mark Rutland , Michael Petlan , Namhyung Kim , Peter Zijlstra Subject: Re: [PATCH 5.15.y] perf symbols: Symbol lookup with kcore can fail if multiple segments match stext Message-ID: <2023070314-unblock-nursery-52be@gregkh> References: <20230628230435.GD1918@templeofstupid.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230628230435.GD1918@templeofstupid.com> Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Wed, Jun 28, 2023 at 04:04:35PM -0700, Krister Johansen wrote: > commit 1c249565426e3a9940102c0ba9f63914f7cda73d upstream. > > This problem was encountered on an arm64 system with a lot of memory. > Without kernel debug symbols installed, and with both kcore and kallsyms > available, perf managed to get confused and returned "unknown" for all > of the kernel symbols that it tried to look up. > > On this system, stext fell within the vmalloc segment. The kcore symbol > matching code tries to find the first segment that contains stext and > uses that to replace the segment generated from just the kallsyms > information. In this case, however, there were two: a very large > vmalloc segment, and the text segment. This caused perf to get confused > because multiple overlapping segments were inserted into the RB tree > that holds the discovered segments. However, that alone wasn't > sufficient to cause the problem. Even when we could find the segment, > the offsets were adjusted in such a way that the newly generated symbols > didn't line up with the instruction addresses in the trace. The most > obvious solution would be to consult which segment type is text from > kcore, but this information is not exposed to users. > > Instead, select the smallest matching segment that contains stext > instead of the first matching segment. This allows us to match the text > segment instead of vmalloc, if one is contained within the other. > > Reviewed-by: Adrian Hunter > Signed-off-by: Krister Johansen > Cc: Alexander Shishkin > Cc: David Reaver > Cc: Ian Rogers > Cc: Jiri Olsa > Cc: Mark Rutland > Cc: Michael Petlan > Cc: Namhyung Kim > Cc: Peter Zijlstra > Link: http://lore.kernel.org/lkml/20230125183418.GD1963@templeofstupid.com > Signed-off-by: Arnaldo Carvalho de Melo > Signed-off-by: Krister Johansen > --- > tools/perf/util/symbol.c | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) > Both now queued up, thanks. greg k-h