lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241202111941.2636613-1-raghavendra.kt@amd.com>
Date: Mon, 2 Dec 2024 11:19:41 +0000
From: Raghavendra K T <raghavendra.kt@....com>
To: <linux-kernel@...r.kernel.org>, <linux-cxl@...r.kernel.org>
CC: <bharata@....com>, Raghavendra K T <raghavendra.kt@....com>, Huang Ying
	<ying.huang@...el.com>, Andrew Morton <akpm@...ux-foundation.org>, "Dan
 Williams" <dan.j.williams@...el.com>, David Hildenbrand <david@...hat.com>,
	Davidlohr Bueso <dave@...olabs.net>, Jonathan Cameron
	<jonathan.cameron@...wei.com>, Dave Jiang <dave.jiang@...el.com>, "Alison
 Schofield" <alison.schofield@...el.com>, Vishal Verma
	<vishal.l.verma@...el.com>, Ira Weiny <ira.weiny@...el.com>, Alistair Popple
	<apopple@...dia.com>, Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
	Bjorn Helgaas <bhelgaas@...gle.com>, Baoquan He <bhe@...hat.com>,
	<ilpo.jarvinen@...ux.intel.com>, Mika Westerberg
	<mika.westerberg@...ux.intel.com>, Fontenot Nathan <Nathan.Fontenot@....com>,
	Wei Huang <wei.huang2@....com>
Subject: [RFC PATCH] resource: Fix CXL node not populated issue

Before:
~]$ numastat -m
...
                          Node 0          Node 1           Total
                 --------------- --------------- ---------------
MemTotal               128096.18       128838.48       256934.65

After:
$ numastat -m
.....
                          Node 0          Node 1          Node 2           Total
                 --------------- --------------- --------------- ---------------
MemTotal               128054.16       128880.51       129024.00       385958.67

Current patch reverts the effect of first commit where the issue is seen.

git bisect had led to below commit
Fixes: b4afe4183ec7 ("resource: fix region_intersects() vs add_memory_driver_managed()")
Cc: Huang Ying <ying.huang@...el.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Dan Williams <dan.j.williams@...el.com>
Cc: David Hildenbrand <david@...hat.com>
Cc: Davidlohr Bueso <dave@...olabs.net>
Cc: Jonathan Cameron <jonathan.cameron@...wei.com>
Cc: Dave Jiang <dave.jiang@...el.com>
Cc: Alison Schofield <alison.schofield@...el.com>
Cc: Vishal Verma <vishal.l.verma@...el.com>
Cc: Ira Weiny <ira.weiny@...el.com>
Cc: Alistair Popple <apopple@...dia.com>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Bjorn Helgaas <bhelgaas@...gle.com>
Cc: Baoquan He <bhe@...hat.com>
Cc: <ilpo.jarvinen@...ux.intel.com>
Cc: Mika Westerberg <mika.westerberg@...ux.intel.com>
Cc: Fontenot Nathan <Nathan.Fontenot@....com>
Cc: Wei Huang <wei.huang2@....com>
Signed-off-by: Raghavendra K T <raghavendra.kt@....com>
---
 kernel/resource.c | 51 ++++++++---------------------------------------
 1 file changed, 8 insertions(+), 43 deletions(-)

Note: Posting the fix that works for me. But looks like an exact fix
might be different. Since I am not much familiar with the below code,
I will have to go back and look into more details.

Please let me know if more detail is needed. sorry if I had missed something
obvious.

Git bisec log looked like this:

# good: [f7feea289f9ae3a8fb56e9daa3832949bf742c53] mm: numa_memblks: use memblock_{start,end}_of_DRAM() when sanitizing meminfo
git bisect good f7feea289f9ae3a8fb56e9daa3832949bf742c53
# bad: [9852d85ec9d492ebef56dc5f229416c925758edc] Linux 6.12-rc1
git bisect bad 9852d85ec9d492ebef56dc5f229416c925758edc
# good: [a65b3c3ed49a3b8068c002e98c90f8594927ff25] Merge tag 'hid-for-linus-2024091602' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
git bisect good a65b3c3ed49a3b8068c002e98c90f8594927ff25
# bad: [486fd58af7ac1098b68370b1d4d9f94a2a1c7124] zram: don't free statically defined names
git bisect bad 486fd58af7ac1098b68370b1d4d9f94a2a1c7124
# bad: [7856a565416e0cf091f825b0e25c7a1b7abb650e] Merge tag 'mm-nonmm-stable-2024-09-21-07-52' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
git bisect bad 7856a565416e0cf091f825b0e25c7a1b7abb650e
# bad: [1868f9d0260e9afaf7c6436d14923ae12eaea465] Merge tag 'for-linux-6.12-ofs1' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux
git bisect bad 1868f9d0260e9afaf7c6436d14923ae12eaea465
# good: [e55ef65510a401862b902dc979441ea10ae25c61] Merge tag 'amd-drm-next-6.12-2024-08-26' of https://gitlab.freedesktop.org/agd5f/linux into drm-next
git bisect good e55ef65510a401862b902dc979441ea10ae25c61
# good: [f1a4dceeb2bd4b4478e4f0c77dac55569d153fb3] drm/xe: Fix missing conversion to xe_display_pm_runtime_resume
git bisect good f1a4dceeb2bd4b4478e4f0c77dac55569d153fb3
# bad: [839c4f596f898edc424070dc8b517381572f8502] Merge tag 'mm-hotfixes-stable-2024-09-19-00-31' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
git bisect bad 839c4f596f898edc424070dc8b517381572f8502
# good: [726e2d0cf2bbc14e3bf38491cddda1a56fe18663] Merge tag 'dma-mapping-6.12-2024-09-19' of git://git.infradead.org/users/hch/dma-mapping
git bisect good 726e2d0cf2bbc14e3bf38491cddda1a56fe18663
# good: [992f9884626a0e6ab73a98ca4eb166d17675cae6] Merge patch series "NCR5380: Bug fixes and other improvements"
git bisect good 992f9884626a0e6ab73a98ca4eb166d17675cae6
# good: [adedd0f46c923f8d63aeb42d504c82431febed31] scsi: bnx2i: Remove unused declarations
git bisect good adedd0f46c923f8d63aeb42d504c82431febed31
# good: [a1d1eb2f57501b2e7e2076ce89b3f3a666ddbfdd] Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
git bisect good a1d1eb2f57501b2e7e2076ce89b3f3a666ddbfdd
# good: [fb497d6db7c19c797cbd694b52d1af87c4eebcc6] mm/damon/vaddr: protect vma traversal in __damon_va_thre_regions() with rcu read lock
git bisect good fb497d6db7c19c797cbd694b52d1af87c4eebcc6
# bad: [2a058ab3286d6475b2082b90c2d2182d2fea4b39] mm: change vmf_anon_prepare() to __vmf_anon_prepare()
git bisect bad 2a058ab3286d6475b2082b90c2d2182d2fea4b39
# bad: [b4afe4183ec77f230851ea139d91e5cf2644c68b] resource: fix region_intersects() vs add_memory_driver_managed()
git bisect bad b4afe4183ec77f230851ea139d91e5cf2644c68b
# good: [6040f650c56862a4ac40b00c37ef6ab1ddfcebb5] zsmalloc: use unique zsmalloc caches names
git bisect good 6040f650c56862a4ac40b00c37ef6ab1ddfcebb5
# first bad commit: [b4afe4183ec77f230851ea139d91e5cf2644c68b] resource: fix region_intersects() vs add_memory_driver_managed()
#
#
#  git bisect good
b4afe4183ec77f230851ea139d91e5cf2644c68b is the first bad commit
commit b4afe4183ec77f230851ea139d91e5cf2644c68b

diff --git a/kernel/resource.c b/kernel/resource.c
index c9fd26c06345..d4dcaa1831cd 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -556,55 +556,20 @@ static int __region_intersects(struct resource *parent, resource_size_t start,
 			       size_t size, unsigned long flags,
 			       unsigned long desc)
 {
+	struct resource res;
 	int type = 0; int other = 0;
-	struct resource *p, *dp;
-	struct resource res, o;
-	bool covered;
+	struct resource *p;
 
 	res.start = start;
 	res.end = start + size - 1;
 
 	for (p = parent->child; p ; p = p->sibling) {
-		if (!resource_intersection(p, &res, &o))
-			continue;
-		if (is_type_match(p, flags, desc)) {
-			type++;
-			continue;
-		}
-		/*
-		 * Continue to search in descendant resources as if the
-		 * matched descendant resources cover some ranges of 'p'.
-		 *
-		 * |------------- "CXL Window 0" ------------|
-		 * |-- "System RAM" --|
-		 *
-		 * will behave similar as the following fake resource
-		 * tree when searching "System RAM".
-		 *
-		 * |-- "System RAM" --||-- "CXL Window 0a" --|
-		 */
-		covered = false;
-		for_each_resource(p, dp, false) {
-			if (!resource_overlaps(dp, &res))
-				continue;
-			if (is_type_match(dp, flags, desc)) {
-				type++;
-				/*
-				 * Range from 'o.start' to 'dp->start'
-				 * isn't covered by matched resource.
-				 */
-				if (dp->start > o.start)
-					break;
-				if (dp->end >= o.end) {
-					covered = true;
-					break;
-				}
-				/* Remove covered range */
-				o.start = max(o.start, dp->end + 1);
-			}
-		}
-		if (!covered)
-			other++;
+		bool is_type = (((p->flags & flags) == flags) &&
+				((desc == IORES_DESC_NONE) ||
+				 (desc == p->desc)));
+
+		if (resource_overlaps(p, &res))
+			is_type ? type++ : other++;
 	}
 
 	if (type == 0)

base-commit: e70140ba0d2b1a30467d4af6bcfe761327b9ec95
-- 
2.39.3


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ