From nobody Mon Feb 9 07:21:52 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D38DD7E77B; Tue, 9 Apr 2024 08:48:11 +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=1712652493; cv=none; b=VCNLKQY+dmAMj6P3g9auLbsVZxIr4eHBaKNthInmrjeEG4lUrEVV0TkJarRliETL47x2dwsqsIZst9gTCOxIUhBUKkFYbVPlkDD//CPjFkWzICsI0HbT131dMN7lsm5yL5942oMhkv7cL717qq4VG7uhI8iK7KpK80WYw9xHM6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712652493; c=relaxed/simple; bh=ypMirJBQln4cahP5+iyf5ns4VS6WkKkpnbUKpCIXRMM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MOQilDrE4205mzrevI5M6Nv/7ll5FtTW76F2UXbn9eWIjm8X/tyF2ybQc5ASDLevKs+M1c46Oxz+3+uYD3rHcCVGw4sl9rvWHgFYm0K0UPiXsOclC+IEO/hLk+e/2SNN4fzHiMpYIc99+NX+jd93SO9NseQFHU/Z7IMGSCK7upY= 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 9DD8D12FC; Tue, 9 Apr 2024 01:48:41 -0700 (PDT) Received: from e127643.broadband (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2201C3F6C4; Tue, 9 Apr 2024 01:48:09 -0700 (PDT) From: James Clark To: linux-perf-users@vger.kernel.org, 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" , Athira Rajeev , Leo Yan , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] perf map: Remove kernel map before updating start and end addresses Date: Tue, 9 Apr 2024 09:47:38 +0100 Message-Id: <20240409084741.405433-3-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409084741.405433-1-james.clark@arm.com> References: <20240409084741.405433-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: quoted-printable Content-Type: text/plain; charset="utf-8" In a debug build there is validation that mmap lists are sorted when taking a lock. In machine__update_kernel_mmap() the start and end addresses are updated resulting in an unsorted list before the map is removed from the list. When the map is removed, the lock is taken which triggers the validation and the failure: $ perf test "object code reading" --- start --- perf: util/maps.c:88: check_invariants: Assertion `map__start(prev) <=3D = map__start(map)' failed. Aborted Fix it by updating the addresses after removal, but before insertion. The bug depends on the ordering and type of debug info on the system and doesn't reproduce everywhere. Fixes: 659ad3492b91 ("perf maps: Switch from rbtree to lazily sorted array = for addresses") Signed-off-by: James Clark --- tools/perf/util/machine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 5eb9044bc223..a26c8bea58d0 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -1549,8 +1549,8 @@ static int machine__update_kernel_mmap(struct machine= *machine, updated =3D map__get(orig); =20 machine->vmlinux_map =3D updated; - machine__set_kernel_mmap(machine, start, end); maps__remove(machine__kernel_maps(machine), orig); + machine__set_kernel_mmap(machine, start, end); err =3D maps__insert(machine__kernel_maps(machine), updated); map__put(orig); =20 --=20 2.34.1