Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp552483lqh; Tue, 7 May 2024 07:17:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV0d9gBkJ2O+tKEsJyMZlZUF3DnPAx1fl3mDBQ/0yFix7OxqN59F8k6xjsl61KVQZND134A553PIYKZkpaj4ta0L4TpczLIu4GViAbGhw== X-Google-Smtp-Source: AGHT+IFhXT5aU3G9Uysvxt3AgsAnoNu+d711F9edAvJsbD3Mj6Q7HBxtdbP6wFI+rM1xs3Cd97bX X-Received: by 2002:a05:620a:19a9:b0:790:ef5d:25c6 with SMTP id bm41-20020a05620a19a900b00790ef5d25c6mr16970818qkb.0.1715091432763; Tue, 07 May 2024 07:17:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715091432; cv=pass; d=google.com; s=arc-20160816; b=THglk0WvZ8pRIRo+82V3Dy59ipYTzeSajIuY2sDoPnGkrWTyG7JDUzCvl9aIW0n8VO ZaWvhh65e5KJjHpo+ukRqSrNFGwm71pwqegUnWuhY9jTaRkgi0U+hT+JSbdaeegesxDt T+Z02FMWUr86vFUJmvBuNDv4gR6tlmxdnBNbvm+StVgxccJOJI9ri4KooPziUtODeQoh tHvKeYxnTgsk1Dcq3hYf3FKTLltDfycJOaJzon0UJRaenj3zqxitxsqbrivR3ihH80uv 44Aac0buc+bkB7E8T1miIWDZEkeFeUfpgpqwMnvxwOK1Ax/N1RLipiot1ZvSSO69O3fL RyVw== 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; bh=0kf0bbkljhWN/rx+cEzkerP0GYjSlTvOBE6Y/rdrt14=; fh=z3/YlGhmWVGbDDVRrPyvN7QnpotMsOuIPt85/Od1vi8=; b=d6dUcymyXUrDW/UwW6m5mTeLglxA4KUpZb/hX3k3Sn4AZtzKRR8AcQvQRKQyKx110P eCSDwmv1mPdJukoBFFudClG9nAzUyrjzG3m0QXYEt7dLkByUpO3QJYG5m5N0TFBxpET3 kuSyvGqOsfzTGMFVn3LktO2VLJe4J/JR/1u/mwPbgFCqkNw64i/34+ix53rmpsg29EJi gMoG9km7ebEnk1PcfGxzJxixAbSsHtpPBOiExwdK5Rk5Pd8/Ttvnvi1GmeiwKnAkV13e AoIDs4rtSA1UK+lDiGcYK+mv8EwCHkYNJEqJ8MwX1ek88ojuBe3nlZmdBgNdP06Jodmw Jurw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-171534-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171534-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c6-20020a05620a268600b0078e5f1704desi12336141qkp.224.2024.05.07.07.17.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 07:17:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171534-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-171534-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171534-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 3BB891C2355D for ; Tue, 7 May 2024 14:17:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 082D516C87F; Tue, 7 May 2024 14:13:23 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2CB1516C451; Tue, 7 May 2024 14:12:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715091201; cv=none; b=tVq3Hd2lC+1mH/bEl69B4w1PgBgQvWUw4KW+R+33lFqFeRWszNTlgo+IDvClBBDUWEHXeJjz47cvZ0ylcLQ+Icayao8i9i9ccvMiuOp+LTlNqM/H3L5FoMteuWMyIdXW/Up4jkV01k5Gf3QPJD+8DSWQB28+r+jDUHljFj6PTXg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715091201; c=relaxed/simple; bh=FPYdBnC0kccxQTzIc3GnR8aqAfAzYDsn2eFN0I7vXyU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b36N5FPsx5JDmlFawbl3Ld800MlStSi9q7z+HH+xy8Cir/jjCXiWfKMTPgqRwH68YvKtQUqOKC6yBPbNYGaeQASVxhIqGHoMKvVwO1/zacN6dJ6zd5VvUj18j00EkhbNkYwJ4oKsToJ1hy4ffh5bKlwjv5Pv7apPhpCVRiQ5q3Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6E964106F; Tue, 7 May 2024 07:13:25 -0700 (PDT) Received: from e127643.broadband (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8CDB13F6A8; Tue, 7 May 2024 07:12:57 -0700 (PDT) From: James Clark To: linux-perf-users@vger.kernel.org, atrajeev@linux.vnet.ibm.com, irogers@google.com Cc: James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , linux-kernel@vger.kernel.org Subject: [PATCH 1/4] perf symbols: Remove map from list before updating addresses Date: Tue, 7 May 2024 15:12:05 +0100 Message-Id: <20240507141210.195939-2-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240507141210.195939-1-james.clark@arm.com> References: <20240507141210.195939-1-james.clark@arm.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 Make the order of operations remove, update, add. Updating addresses before the map is removed causes the ordering check to fail when the map is removed. This can be reproduced when running Perf on an Arm system with a static kernel and Perf uses kcore rather than other sources: $ perf record -- ls $ perf report util/maps.c:96: check_invariants: Assertion `map__end(prev) <= map__start(map) || map__start(prev) == map__start(map)' failed Fixes: 659ad3492b91 ("perf maps: Switch from rbtree to lazily sorted array for addresses") Signed-off-by: James Clark --- tools/perf/util/symbol.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 7772a4d3e66c..2d95f22d713d 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -1377,13 +1377,15 @@ static int dso__load_kcore(struct dso *dso, struct map *map, if (RC_CHK_EQUAL(new_map, replacement_map)) { struct map *map_ref; - map__set_start(map, map__start(new_map)); - map__set_end(map, map__end(new_map)); - map__set_pgoff(map, map__pgoff(new_map)); - map__set_mapping_type(map, map__mapping_type(new_map)); /* Ensure maps are correctly ordered */ map_ref = map__get(map); maps__remove(kmaps, map_ref); + + map__set_start(map_ref, map__start(new_map)); + map__set_end(map_ref, map__end(new_map)); + map__set_pgoff(map_ref, map__pgoff(new_map)); + map__set_mapping_type(map_ref, map__mapping_type(new_map)); + err = maps__insert(kmaps, map_ref); map__put(map_ref); map__put(new_map); -- 2.34.1