public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Raghavendra K T <raghavendra.kt@amd.com>
To: <linux-kernel@vger.kernel.org>, <linux-cxl@vger.kernel.org>
Cc: <bharata@amd.com>, Raghavendra K T <raghavendra.kt@amd.com>,
	Huang Ying <ying.huang@intel.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Dan Williams" <dan.j.williams@intel.com>,
	David Hildenbrand <david@redhat.com>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Jonathan Cameron <jonathan.cameron@huawei.com>,
	Dave Jiang <dave.jiang@intel.com>,
	"Alison Schofield" <alison.schofield@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	Alistair Popple <apopple@nvidia.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Bjorn Helgaas <bhelgaas@google.com>, Baoquan He <bhe@redhat.com>,
	<ilpo.jarvinen@linux.intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Fontenot Nathan <Nathan.Fontenot@amd.com>,
	Wei Huang <wei.huang2@amd.com>
Subject: [RFC PATCH] resource: Fix CXL node not populated issue
Date: Mon, 2 Dec 2024 11:19:41 +0000	[thread overview]
Message-ID: <20241202111941.2636613-1-raghavendra.kt@amd.com> (raw)

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@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Jonathan Cameron <jonathan.cameron@huawei.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Alison Schofield <alison.schofield@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: <ilpo.jarvinen@linux.intel.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Fontenot Nathan <Nathan.Fontenot@amd.com>
Cc: Wei Huang <wei.huang2@amd.com>
Signed-off-by: Raghavendra K T <raghavendra.kt@amd.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


             reply	other threads:[~2024-12-02 11:20 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-02 11:19 Raghavendra K T [this message]
2024-12-02 15:34 ` [RFC PATCH] resource: Fix CXL node not populated issue Andy Shevchenko
2024-12-03  6:01   ` Raghavendra K T
2024-12-03  6:26 ` Huang, Ying
2024-12-03 13:41   ` Andy Shevchenko
     [not found]     ` <CAAt7c_piFt2UY_OSzdhhr3yFfgMZPgcw2ogtAoVRjgDFGaG_8Q@mail.gmail.com>
2024-12-03 22:07       ` Andy Shevchenko
2024-12-04  2:07     ` Huang, Ying
2024-12-04  3:01       ` Andy Shevchenko
2024-12-04  4:44         ` Raghavendra K T
2024-12-05  5:45           ` Raghavendra K T
2024-12-04  3:55 ` Dan Williams
2024-12-04  4:41   ` Raghavendra K T
2024-12-06  7:50     ` Dan Williams
2024-12-06  8:28       ` Raghavendra K T
2024-12-11  4:44         ` Dan Williams
2024-12-11  6:40           ` Bharata B Rao
2024-12-11  8:38             ` Dan Williams
2024-12-11 16:47               ` Bharata B Rao
2024-12-12  1:02                 ` Raghavendra K T

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241202111941.2636613-1-raghavendra.kt@amd.com \
    --to=raghavendra.kt@amd.com \
    --cc=Nathan.Fontenot@amd.com \
    --cc=akpm@linux-foundation.org \
    --cc=alison.schofield@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=apopple@nvidia.com \
    --cc=bharata@amd.com \
    --cc=bhe@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=david@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=ira.weiny@intel.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=vishal.l.verma@intel.com \
    --cc=wei.huang2@amd.com \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox