Skip to contentSkip to conversation

resource, kunit: add dependency on SPARSEMEM

PATCH In review Guenter Roeck 4 participants 19 messages Sep 22, 2024 – Oct 12, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 resource, kunit: add dependency on SPARSEMEM

Building allmodconfig images on systems with SPARSEMEM=n results in the following message.

WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]

and the build ultimately fails.

GET_FREE_REGION depends on SPARSEMEM, so any configuration selecting it also depends on SPARSEMEM. Add the missing dependency.

Effectively that means that RESOURCE_KUNIT_TEST is now restricted to systems with SPARSEMEM=y, but that can not be helped.

Fixes 99185c10d5d9 ("resource, kunit: add test case for region_intersects()")
Cc Huang Ying <[email protected]>
Cc Andrew Morton <[email protected]>
---
 lib/Kconfig.debug | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/Kconfig.debug +1 -1
index bc8faa4509e1..52184c51b6dc 100644
@@ -2635,7 +2635,7 @@ config HASH_KUNIT_TEST
 
 config RESOURCE_KUNIT_TEST
 	tristate "KUnit test for resource API" if !KUNIT_ALL_TESTS
-	depends on KUNIT
+	depends on KUNIT && SPARSEMEM
 	default KUNIT_ALL_TESTS
 	select GET_FREE_REGION
 	help
Signature · 1 line
2.45.2
Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines · Guenter Roeck

Building allmodconfig images on systems with SPARSEMEM=n results in the following message.

WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]

and the build ultimately fails.

GET_FREE_REGION depends on SPARSEMEM, so any configuration selecting it also depends on SPARSEMEM. Add the missing dependency.

Quoted 7 lines

Effectively that means that RESOURCE_KUNIT_TEST is now restricted to systems with SPARSEMEM=y, but that can not be helped.

Fixes 99185c10d5d9 ("resource, kunit: add test case for region_intersects()")
Cc Huang Ying <[email protected]>
Cc Andrew Morton <[email protected]>

Thanks for fixing. It's better to fix this via remove dependency of SPARSEMEM from GET_FREE_REGION. However, we need to sort out some merge conflict before that. So, I think this patch is good as a quick fix.

Quoted 17 lines
---
 lib/Kconfig.debug | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/Kconfig.debug +1 -1
index bc8faa4509e1..52184c51b6dc 100644
@@ -2635,7 +2635,7 @@ config HASH_KUNIT_TEST
 
 config RESOURCE_KUNIT_TEST
 	tristate "KUnit test for resource API" if !KUNIT_ALL_TESTS
-	depends on KUNIT
+	depends on KUNIT && SPARSEMEM
 	default KUNIT_ALL_TESTS
 	select GET_FREE_REGION
 	help
#2 lore raw
In reply to Guenter Roeck

Hi Günter,

Quoted 9 lines · Guenter Roeck

Building allmodconfig images on systems with SPARSEMEM=n results in the following message.

WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]

and the build ultimately fails.

Really? What's the build error?
It does build for me on m68k, after fixing:

--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -101,7 +101,7 @@ extern int mmap_rnd_compat_bits __read_mostly;
# ifdef MAX_PHYSMEM_BITS
# define PHYSMEM_END ((1ULL << MAX_PHYSMEM_BITS) - 1)
# else
-# define PHYSMEM_END (-1ULL)
+# define PHYSMEM_END ((phys_addr_t)-1)

     # endif
     #endif
Quoted 5 lines

GET_FREE_REGION depends on SPARSEMEM, so any configuration selecting it also depends on SPARSEMEM. Add the missing dependency.

Effectively that means that RESOURCE_KUNIT_TEST is now restricted to systems with SPARSEMEM=y, but that can not be helped.

Perhaps the individual test(s) that do depend on GET_FREE_REGION should be protected by #ifdef CONFIG_GET_FREE_REGION instead? However, I have no idea which parts depend on that, as apparently all tests succeed on m68k/ARAnyM, with CONFIG_SPARSEMEM=n:

KTAP version 1
1..1
KTAP version 1
# Subtest: resource
# module: resource_kunit
1..3
ok 1 resource_test_union
ok 2 resource_test_intersection
ok 3 resource_test_region_intersects
# resource: pass:3 fail:0 skip:0 total:3
# Totals: pass:3 fail:0 skip:0 total:3
ok 1 resource

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#3 lore raw
Quoted 6 lines · Geert Uytterhoeven

Hi Günter,

Quoted 3 lines · Guenter Roeck

Building allmodconfig images on systems with SPARSEMEM=n results in the following message.

Quoted 8 lines
Quoted 6 lines

WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]

and the build ultimately fails.

Really? What's the build error?

I saw it on hexagon, and I didn't bother writing down the actual build error message. But it turns out you are correct, the m68k machine does build with CONFIG_RESOURCE_KUNIT_TEST=y even though SPARSEMEM and with it GET_FREE_REGION are not set. Never mind, I don't really want or have time to argue. I'll just disable CONFIG_RESOURCE_KUNIT_TEST when building hexagon images and wherever else I see the problem.

Quoted 24 lines

It does build for me on m68k, after fixing:

     --- a/include/linux/mm.h
     +++ b/include/linux/mm.h
     @@ -101,7 +101,7 @@ extern int mmap_rnd_compat_bits __read_mostly;
      # ifdef MAX_PHYSMEM_BITS
      # define PHYSMEM_END   ((1ULL << MAX_PHYSMEM_BITS) - 1)
      # else
     -# define PHYSMEM_END   (-1ULL)
    +# define PHYSMEM_END   ((phys_addr_t)-1)
      # endif
      #endif
Quoted 5 lines

GET_FREE_REGION depends on SPARSEMEM, so any configuration selecting it also depends on SPARSEMEM. Add the missing dependency.

Effectively that means that RESOURCE_KUNIT_TEST is now restricted to systems with SPARSEMEM=y, but that can not be helped.

Perhaps the individual test(s) that do depend on GET_FREE_REGION should be protected by #ifdef CONFIG_GET_FREE_REGION instead? However, I have no idea which parts depend on that, as apparently all tests succeed on m68k/ARAnyM, with CONFIG_SPARSEMEM=n:

Quoted 13 lines

KTAP version 1
1..1
KTAP version 1
# Subtest: resource
# module: resource_kunit
1..3
ok 1 resource_test_union
ok 2 resource_test_intersection
ok 3 resource_test_region_intersects
# resource: pass:3 fail:0 skip:0 total:3
# Totals: pass:3 fail:0 skip:0 total:3
ok 1 resource

Interesting that you get that to boot. The q800 machine crashes for me when trying to boot it in qemu with the latest upstream kernel, in function __pte_offset_map_lock(). It bisects to commit 394290cba966 ("mm: turn USE_SPLIT_PTE_PTLOCKS / USE_SPLIT_PTE_PTLOCKS into Kconfig options"). Reverting that patch fixes the crash for me. I guess you are not seeing that ?

Thanks,
Guenter

#4 lore raw

Hi Günter,

Quoted 5 lines · Guenter Roeck

Interesting that you get that to boot. The q800 machine crashes for me when trying to boot it in qemu with the latest upstream kernel, in function __pte_offset_map_lock(). It bisects to commit 394290cba966 ("mm: turn USE_SPLIT_PTE_PTLOCKS / USE_SPLIT_PTE_PTLOCKS into Kconfig options"). Reverting that patch fixes the crash for me. I guess you are not seeing that ?

I never used qemu -M q800.
I have just verified that -M virt boots fine?

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#5 lore raw
Quoted 12 lines · Geert Uytterhoeven

Hi Günter,

Quoted 5 lines · Guenter Roeck

Interesting that you get that to boot. The q800 machine crashes for me when trying to boot it in qemu with the latest upstream kernel, in function __pte_offset_map_lock(). It bisects to commit 394290cba966 ("mm: turn USE_SPLIT_PTE_PTLOCKS / USE_SPLIT_PTE_PTLOCKS into Kconfig options"). Reverting that patch fixes the crash for me. I guess you are not seeing that ?

I never used qemu -M q800.
I have just verified that -M virt boots fine?

m68k doesn't define a NR_CPUs configuration option. The new "config SPLIT_PTE_PTLOCKS" depends on "NR_CPUS >= 4" but for some reason that evaluates to true if there is no NR_CPUS configuration option.

It is interesting that this does not affect the 'virt' machine.

Guenter

#6 lore raw
In reply to Geert Uytterhoeven
Quoted 12 lines · Geert Uytterhoeven

Hi Günter,

Quoted 5 lines · Guenter Roeck

Interesting that you get that to boot. The q800 machine crashes for me when trying to boot it in qemu with the latest upstream kernel, in function __pte_offset_map_lock(). It bisects to commit 394290cba966 ("mm: turn USE_SPLIT_PTE_PTLOCKS / USE_SPLIT_PTE_PTLOCKS into Kconfig options"). Reverting that patch fixes the crash for me. I guess you are not seeing that ?

I never used qemu -M q800.
I have just verified that -M virt boots fine?

Not for me :-(

Run /sbin/init as init process

Unable to handle kernel NULL pointer dereference at virtual address 00000014
Oops: 00000000
PC: [<000ca784>] __pte_offset_map_lock+0x36/0x7e

This is with virt_defconfig.

Guenter

#7 lore raw

Hi Günter.

Quoted 11 lines · Guenter Roeck
Quoted 9 lines · Geert Uytterhoeven
Quoted 5 lines · Guenter Roeck

Interesting that you get that to boot. The q800 machine crashes for me when trying to boot it in qemu with the latest upstream kernel, in function __pte_offset_map_lock(). It bisects to commit 394290cba966 ("mm: turn USE_SPLIT_PTE_PTLOCKS / USE_SPLIT_PTE_PTLOCKS into Kconfig options"). Reverting that patch fixes the crash for me. I guess you are not seeing that ?

I never used qemu -M q800.
I have just verified that -M virt boots fine?

Quoted 8 lines

Not for me :-(

Run /sbin/init as init process

Unable to handle kernel NULL pointer dereference at virtual address 00000014
Oops: 00000000
PC: [<000ca784>] __pte_offset_map_lock+0x36/0x7e

This is with virt_defconfig.

Before, I was using my current development tree, which has lots of local patches. So I retried with commit 394290cba966. Boots fine into Debian:

root@debian:~# cat /etc/issue
Debian GNU/Linux bullseye/sid \n \l
root@debian:~# uname -r
6.11.0-rc6-virt-00033-g394290cba966
root@debian:~#

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#8 lore raw
Quoted 21 lines · Geert Uytterhoeven

Hi Günter.

Quoted 18 lines · Guenter Roeck
Quoted 9 lines · Geert Uytterhoeven
Quoted 5 lines · Guenter Roeck

Interesting that you get that to boot. The q800 machine crashes for me when trying to boot it in qemu with the latest upstream kernel, in function __pte_offset_map_lock(). It bisects to commit 394290cba966 ("mm: turn USE_SPLIT_PTE_PTLOCKS / USE_SPLIT_PTE_PTLOCKS into Kconfig options"). Reverting that patch fixes the crash for me. I guess you are not seeing that ?

I never used qemu -M q800.
I have just verified that -M virt boots fine?

Not for me :-(

Run /sbin/init as init process

Unable to handle kernel NULL pointer dereference at virtual address 00000014
Oops: 00000000
PC: [<000ca784>] __pte_offset_map_lock+0x36/0x7e
Quoted 6 lines
Quoted 1 line

This is with virt_defconfig.

Before, I was using my current development tree, which has lots of local patches. So I retried with commit 394290cba966. Boots fine into Debian:

Interesting. I have a lot of debug and kunit test options enabled. Turns out I can boot cleanly with an unmodified virt_defconfig, but the crash is seen if I enable the various debug and test options. I attached the defconfig I used for reference.

Guenter

#9 lore raw
In reply to Guenter Roeck
Quoted 13 lines · Guenter Roeck
Quoted 12 lines · Geert Uytterhoeven

Hi Günter,

Quoted 9 lines · Guenter Roeck

Building allmodconfig images on systems with SPARSEMEM=n results in the following message.

WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]

and the build ultimately fails.

Quoted 20 lines
Quoted 1 line

Really? What's the build error?

I saw it on hexagon, and I didn't bother writing down the actual build error message. But it turns out you are correct, the m68k machine does build with CONFIG_RESOURCE_KUNIT_TEST=y even though SPARSEMEM and with it GET_FREE_REGION are not set. Never mind, I don't really want or have time to argue. I'll just disable CONFIG_RESOURCE_KUNIT_TEST when building hexagon images and wherever else I see the problem.

Quoted 11 lines

It does build for me on m68k, after fixing:

     --- a/include/linux/mm.h
     +++ b/include/linux/mm.h
     @@ -101,7 +101,7 @@ extern int mmap_rnd_compat_bits __read_mostly;
      # ifdef MAX_PHYSMEM_BITS
      # define PHYSMEM_END   ((1ULL << MAX_PHYSMEM_BITS) - 1)
      # else
     -# define PHYSMEM_END   (-1ULL)
    +# define PHYSMEM_END   ((phys_addr_t)-1)
      # endif
      #endif

After Linus' fix for PHYSMEM_END, GET_FREE_REGION doesn't need to depend on SPARSEMEM anymore. So, I think we can remove the dependency. Can you check whether the following patch work for you on top of latest upstream kernel (with Linus' fix).

------------------------8<-------------------------------
From ce1a930f74192a4a85c20564098470356f8c2ed4 Mon Sep 17 00:00:00 2001
From: Huang Ying <[email protected]>
Date: Mon, 23 Sep 2024 09:24:03 +0800
Subject: [PATCH] resource: Remove dependency on SPARSEMEM from GET_FREE_REGION

We want to use the functions configured via GET_FREE_REGION in resource kunit tests. However, GET_FREE_REGION depends on SPARSEMEM. This makes resource kunit tests cannot be built on some architectures lacking SPARSEMEM. In fact, these functions doesn't depend on SPARSEMEM now. So, remove dependency on SPARSEMEM from GET_FREE_REGION.

Cc Guenter Roeck <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Nathan Chancellor <[email protected]>
Cc Arnd Bergmann <[email protected]>
---
 mm/Kconfig | 1 -
 1 file changed, 1 deletion(-)
mm/Kconfig +0 -1
index b72e7d040f78..f287b0d1c5fc 100644
@@ -1060,7 +1060,6 @@ config HMM_MIRROR
 	depends on MMU
 
 config GET_FREE_REGION
-	depends on SPARSEMEM
 	bool
 
 config DEVICE_PRIVATE
Signature · 1 line
2.39.2
#10 lore raw
Quoted 36 lines · Ying
Quoted 13 lines · Guenter Roeck
Quoted 12 lines · Geert Uytterhoeven

Hi Günter,

Quoted 9 lines · Guenter Roeck

Building allmodconfig images on systems with SPARSEMEM=n results in the following message.

WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]

and the build ultimately fails.

Quoted 20 lines
Quoted 1 line

Really? What's the build error?

I saw it on hexagon, and I didn't bother writing down the actual build error message. But it turns out you are correct, the m68k machine does build with CONFIG_RESOURCE_KUNIT_TEST=y even though SPARSEMEM and with it GET_FREE_REGION are not set. Never mind, I don't really want or have time to argue. I'll just disable CONFIG_RESOURCE_KUNIT_TEST when building hexagon images and wherever else I see the problem.

Quoted 11 lines

It does build for me on m68k, after fixing:

      --- a/include/linux/mm.h
      +++ b/include/linux/mm.h
      @@ -101,7 +101,7 @@ extern int mmap_rnd_compat_bits __read_mostly;
       # ifdef MAX_PHYSMEM_BITS
       # define PHYSMEM_END   ((1ULL << MAX_PHYSMEM_BITS) - 1)
       # else
      -# define PHYSMEM_END   (-1ULL)
     +# define PHYSMEM_END   ((phys_addr_t)-1)
       # endif
       #endif
Quoted 5 lines

After Linus' fix for PHYSMEM_END, GET_FREE_REGION doesn't need to depend on SPARSEMEM anymore. So, I think we can remove the dependency. Can you check whether the following patch work for you on top of latest upstream kernel (with Linus' fix).

It works for m68k. I'll run a complete test on all architectures/platforms tonight.

Guenter

Quoted 34 lines

------------------------8<-------------------------------

Quoted 1 line

From ce1a930f74192a4a85c20564098470356f8c2ed4 Mon Sep 17 00:00:00 2001

From: Huang Ying <[email protected]>
Date: Mon, 23 Sep 2024 09:24:03 +0800
Subject: [PATCH] resource: Remove dependency on SPARSEMEM from GET_FREE_REGION

We want to use the functions configured via GET_FREE_REGION in resource kunit tests. However, GET_FREE_REGION depends on SPARSEMEM. This makes resource kunit tests cannot be built on some architectures lacking SPARSEMEM. In fact, these functions doesn't depend on SPARSEMEM now. So, remove dependency on SPARSEMEM from GET_FREE_REGION.

Cc Guenter Roeck <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Nathan Chancellor <[email protected]>
Cc Arnd Bergmann <[email protected]>
---
  mm/Kconfig | 1 -
  1 file changed, 1 deletion(-)
mm/Kconfig +0 -1
index b72e7d040f78..f287b0d1c5fc 100644
@@ -1060,7 +1060,6 @@ config HMM_MIRROR
  	depends on MMU
 
  config GET_FREE_REGION
-	depends on SPARSEMEM
  	bool
 
  config DEVICE_PRIVATE
#11 lore raw

Hi, Guenter,

Quoted 43 lines · Guenter Roeck
Quoted 35 lines · Ying
Quoted 13 lines · Guenter Roeck
Quoted 12 lines · Geert Uytterhoeven

Hi Günter,

Quoted 9 lines · Guenter Roeck

Building allmodconfig images on systems with SPARSEMEM=n results in the following message.

WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]

and the build ultimately fails.

Quoted 20 lines
Quoted 1 line

Really? What's the build error?

I saw it on hexagon, and I didn't bother writing down the actual build error message. But it turns out you are correct, the m68k machine does build with CONFIG_RESOURCE_KUNIT_TEST=y even though SPARSEMEM and with it GET_FREE_REGION are not set. Never mind, I don't really want or have time to argue. I'll just disable CONFIG_RESOURCE_KUNIT_TEST when building hexagon images and wherever else I see the problem.

Quoted 11 lines

It does build for me on m68k, after fixing:

      --- a/include/linux/mm.h
      +++ b/include/linux/mm.h
      @@ -101,7 +101,7 @@ extern int mmap_rnd_compat_bits __read_mostly;
       # ifdef MAX_PHYSMEM_BITS
       # define PHYSMEM_END   ((1ULL << MAX_PHYSMEM_BITS) - 1)
       # else
      -# define PHYSMEM_END   (-1ULL)
     +# define PHYSMEM_END   ((phys_addr_t)-1)
       # endif
       #endif
Quoted 6 lines

After Linus' fix for PHYSMEM_END, GET_FREE_REGION doesn't need to depend
on SPARSEMEM anymore. So, I think we can remove the dependency. Can you check whether the following patch work for you on top of latest upstream kernel (with Linus' fix).

Quoted 2 lines

It works for m68k. I'll run a complete test on all architectures/platforms tonight.

Does it work in the complete test?

--
Thanks,
Huang, Ying

Quoted 29 lines
Quoted 29 lines

------------------------8<-------------------------------

Quoted 1 line

From ce1a930f74192a4a85c20564098470356f8c2ed4 Mon Sep 17 00:00:00 2001

From: Huang Ying <[email protected]>
Date: Mon, 23 Sep 2024 09:24:03 +0800
Subject: [PATCH] resource: Remove dependency on SPARSEMEM from GET_FREE_REGION We want to use the functions configured via GET_FREE_REGION in resource kunit tests. However, GET_FREE_REGION depends on SPARSEMEM. This makes resource kunit tests cannot be built on some architectures lacking SPARSEMEM. In fact, these functions doesn't depend on SPARSEMEM now. So, remove dependency on SPARSEMEM from GET_FREE_REGION.

Cc Guenter Roeck <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Nathan Chancellor <[email protected]>
Cc Arnd Bergmann <[email protected]>
---
  mm/Kconfig | 1 -
  1 file changed, 1 deletion(-)
mm/Kconfig +0 -1
index b72e7d040f78..f287b0d1c5fc 100644
@@ -1060,7 +1060,6 @@ config HMM_MIRROR
  	depends on MMU
    config GET_FREE_REGION
-	depends on SPARSEMEM
  	bool
    config DEVICE_PRIVATE
#12 lore raw
Quoted 47 lines · Ying

Hi, Guenter,

Quoted 43 lines · Guenter Roeck
Quoted 41 lines · Ying
Quoted 13 lines · Guenter Roeck
Quoted 12 lines · Geert Uytterhoeven

Hi Günter,

Quoted 9 lines · Guenter Roeck

Building allmodconfig images on systems with SPARSEMEM=n results in the following message.

WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]

and the build ultimately fails.

Quoted 20 lines
Quoted 1 line

Really? What's the build error?

I saw it on hexagon, and I didn't bother writing down the actual build error message. But it turns out you are correct, the m68k machine does build with CONFIG_RESOURCE_KUNIT_TEST=y even though SPARSEMEM and with it GET_FREE_REGION are not set. Never mind, I don't really want or have time to argue. I'll just disable CONFIG_RESOURCE_KUNIT_TEST when building hexagon images and wherever else I see the problem.

Quoted 11 lines

It does build for me on m68k, after fixing:

       --- a/include/linux/mm.h
       +++ b/include/linux/mm.h
       @@ -101,7 +101,7 @@ extern int mmap_rnd_compat_bits __read_mostly;
        # ifdef MAX_PHYSMEM_BITS
        # define PHYSMEM_END   ((1ULL << MAX_PHYSMEM_BITS) - 1)
        # else
       -# define PHYSMEM_END   (-1ULL)
      +# define PHYSMEM_END   ((phys_addr_t)-1)
        # endif
        #endif

After Linus' fix for PHYSMEM_END, GET_FREE_REGION doesn't need to depend
on SPARSEMEM anymore. So, I think we can remove the dependency. Can you check whether the following patch work for you on top of latest upstream kernel (with Linus' fix).

Quoted 5 lines
Quoted 2 lines

It works for m68k. I'll run a complete test on all architectures/platforms tonight.

Does it work in the complete test?

Sorry, I dropped that one. Yes, it does.

Thanks,
Guenter

Quoted 33 lines

--
Thanks,
Huang, Ying

Quoted 29 lines
Quoted 29 lines

------------------------8<-------------------------------

Quoted 1 line

From ce1a930f74192a4a85c20564098470356f8c2ed4 Mon Sep 17 00:00:00 2001

From: Huang Ying <[email protected]>
Date: Mon, 23 Sep 2024 09:24:03 +0800
Subject: [PATCH] resource: Remove dependency on SPARSEMEM from GET_FREE_REGION We want to use the functions configured via GET_FREE_REGION in resource kunit tests. However, GET_FREE_REGION depends on SPARSEMEM. This makes resource kunit tests cannot be built on some architectures lacking SPARSEMEM. In fact, these functions doesn't depend on SPARSEMEM now. So, remove dependency on SPARSEMEM from GET_FREE_REGION.

Cc Guenter Roeck <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Nathan Chancellor <[email protected]>
Cc Arnd Bergmann <[email protected]>
---
   mm/Kconfig | 1 -
   1 file changed, 1 deletion(-)
mm/Kconfig +0 -1
index b72e7d040f78..f287b0d1c5fc 100644
@@ -1060,7 +1060,6 @@ config HMM_MIRROR
   	depends on MMU
     config GET_FREE_REGION
-	depends on SPARSEMEM
   	bool
     config DEVICE_PRIVATE
#13 lore raw
Quoted 47 lines · Guenter Roeck
Quoted 46 lines · Ying

Hi, Guenter,

Quoted 43 lines · Guenter Roeck
Quoted 41 lines · Ying
Quoted 13 lines · Guenter Roeck
Quoted 12 lines · Geert Uytterhoeven

Hi Günter,

Quoted 9 lines · Guenter Roeck

Building allmodconfig images on systems with SPARSEMEM=n results in the following message.

WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]

and the build ultimately fails.

Quoted 20 lines
Quoted 1 line

Really? What's the build error?

I saw it on hexagon, and I didn't bother writing down the actual build error message. But it turns out you are correct, the m68k machine does build with CONFIG_RESOURCE_KUNIT_TEST=y even though SPARSEMEM and with it GET_FREE_REGION are not set. Never mind, I don't really want or have time to argue. I'll just disable CONFIG_RESOURCE_KUNIT_TEST when building hexagon images and wherever else I see the problem.

Quoted 11 lines

It does build for me on m68k, after fixing:

       --- a/include/linux/mm.h
       +++ b/include/linux/mm.h
       @@ -101,7 +101,7 @@ extern int mmap_rnd_compat_bits __read_mostly;
        # ifdef MAX_PHYSMEM_BITS
        # define PHYSMEM_END   ((1ULL << MAX_PHYSMEM_BITS) - 1)
        # else
       -# define PHYSMEM_END   (-1ULL)
      +# define PHYSMEM_END   ((phys_addr_t)-1)
        # endif
        #endif

After Linus' fix for PHYSMEM_END, GET_FREE_REGION doesn't need to depend
on SPARSEMEM anymore. So, I think we can remove the dependency. Can you check whether the following patch work for you on top of latest upstream kernel (with Linus' fix).

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

It works for m68k. I'll run a complete test on all architectures/platforms tonight.

Does it work in the complete test?

Sorry, I dropped that one. Yes, it does.

Thanks a lot! Can I add your Tested-by in the formal version?

--
Best Regards,
Huang, Ying

author Tested-by
#14 lore raw
Quoted 51 lines · Ying
Quoted 49 lines · Guenter Roeck
Quoted 48 lines · Ying

Hi, Guenter,

Quoted 45 lines · Guenter Roeck
Quoted 35 lines · Ying
Quoted 13 lines · Guenter Roeck
Quoted 12 lines · Geert Uytterhoeven

Hi Günter,

Quoted 9 lines · Guenter Roeck

Building allmodconfig images on systems with SPARSEMEM=n results in the following message.

WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]

and the build ultimately fails.

Quoted 20 lines
Quoted 1 line

Really? What's the build error?

I saw it on hexagon, and I didn't bother writing down the actual build error message. But it turns out you are correct, the m68k machine does build with CONFIG_RESOURCE_KUNIT_TEST=y even though SPARSEMEM and with it GET_FREE_REGION are not set. Never mind, I don't really want or have time to argue. I'll just disable CONFIG_RESOURCE_KUNIT_TEST when building hexagon images and wherever else I see the problem.

Quoted 11 lines

It does build for me on m68k, after fixing:

        --- a/include/linux/mm.h
        +++ b/include/linux/mm.h
        @@ -101,7 +101,7 @@ extern int mmap_rnd_compat_bits __read_mostly;
         # ifdef MAX_PHYSMEM_BITS
         # define PHYSMEM_END   ((1ULL << MAX_PHYSMEM_BITS) - 1)
         # else
        -# define PHYSMEM_END   (-1ULL)
       +# define PHYSMEM_END   ((phys_addr_t)-1)
         # endif
         #endif
Quoted 6 lines

After Linus' fix for PHYSMEM_END, GET_FREE_REGION doesn't need to depend
on SPARSEMEM anymore. So, I think we can remove the dependency. Can you check whether the following patch work for you on top of latest upstream kernel (with Linus' fix).

It works for m68k. I'll run a complete test on all architectures/platforms tonight.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Does it work in the complete test?

Sorry, I dropped that one. Yes, it does.

Thanks a lot! Can I add your Tested-by in the formal version?

Sure, go ahead.

Guenter

#15 lore raw
In reply to Huang, Ying

Hi Huang,

Quoted 13 lines · Ying
Quoted 11 lines · Guenter Roeck
Quoted 10 lines · Geert Uytterhoeven

Hi Günter,

Quoted 7 lines · Guenter Roeck

Building allmodconfig images on systems with SPARSEMEM=n results in the following message.

WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]

Quoted 4 lines

After Linus' fix for PHYSMEM_END, GET_FREE_REGION doesn't need to depend on SPARSEMEM anymore. So, I think we can remove the dependency. Can you check whether the following patch work for you on top of latest upstream kernel (with Linus' fix).

Yes it does, thanks!

One remaining issue is that RESOURCE_KUNIT_TEST selects GET_FREE_REGION. IMHO merely enabling a test should not enable extra functionality in the kernel. Can the individual test(s) that do depend on GET_FREE_REGION be protected by #ifdef CONFIG_GET_FREE_REGION instead?

Thanks again!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#16 lore raw
Quoted 21 lines · Geert Uytterhoeven

Hi Huang,

Quoted 13 lines · Ying
Quoted 11 lines · Guenter Roeck
Quoted 10 lines · Geert Uytterhoeven

Hi Günter,

Quoted 7 lines · Guenter Roeck

Building allmodconfig images on systems with SPARSEMEM=n results in the following message.

WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]

Quoted 4 lines

After Linus' fix for PHYSMEM_END, GET_FREE_REGION doesn't need to depend on SPARSEMEM anymore. So, I think we can remove the dependency. Can you check whether the following patch work for you on top of latest upstream kernel (with Linus' fix).

Quoted 6 lines

Yes it does, thanks!

One remaining issue is that RESOURCE_KUNIT_TEST selects GET_FREE_REGION. IMHO merely enabling a test should not enable extra functionality in the kernel. Can the individual test(s) that do depend on GET_FREE_REGION be protected by #ifdef CONFIG_GET_FREE_REGION instead?

After checking GET_FREE_REGION, I don't think that it's a special functionality. I guess it's selectable because it depends on SPARSEMEM and to reduce code size.

Hi, Dan, please correct me if I'm wrong here.

So, to reduce #ifdef in .c file as much as possible and make code simpler, I prefer to select it for RESOURCE_KUNIT_TEST.

--
Best Regards,
Huang, Ying

#17 lore raw
Quoted 30 lines · Ying
Quoted 21 lines · Geert Uytterhoeven

Hi Huang,

Quoted 13 lines · Ying
Quoted 11 lines · Guenter Roeck
Quoted 10 lines · Geert Uytterhoeven

Hi Günter,

Quoted 7 lines · Guenter Roeck

Building allmodconfig images on systems with SPARSEMEM=n results in the following message.

WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]

Quoted 4 lines

After Linus' fix for PHYSMEM_END, GET_FREE_REGION doesn't need to depend on SPARSEMEM anymore. So, I think we can remove the dependency. Can you check whether the following patch work for you on top of latest upstream kernel (with Linus' fix).

Quoted 6 lines

Yes it does, thanks!

One remaining issue is that RESOURCE_KUNIT_TEST selects GET_FREE_REGION. IMHO merely enabling a test should not enable extra functionality in the kernel. Can the individual test(s) that do depend on GET_FREE_REGION be protected by #ifdef CONFIG_GET_FREE_REGION instead?

Quoted 5 lines

After checking GET_FREE_REGION, I don't think that it's a special functionality. I guess it's selectable because it depends on SPARSEMEM and to reduce code size.

Hi, Dan, please correct me if I'm wrong here.

Right, the only reason it is selectable is just to be mindful is micro-bloat in kernel/resource.c for the small number of drivers that need that call.

Quoted 2 lines

So, to reduce #ifdef in .c file as much as possible and make code simpler, I prefer to select it for RESOURCE_KUNIT_TEST.

I agree with the result, but for a different rationale.

RESOURCE_KUNIT_TEST is simply another "driver" that needs GET_FREE_REGION. So while I agree with the general idea that "enabling a test should not enable extra functionality", in this case the *test* is the extra functionality and GET_FREE_REGION comes along for the ride.

#18 lore raw
Quoted 35 lines · Dan Williams
Quoted 34 lines · Ying
Quoted 21 lines · Geert Uytterhoeven

Hi Huang,

Quoted 13 lines · Ying
Quoted 11 lines · Guenter Roeck
Quoted 10 lines · Geert Uytterhoeven

Hi Günter,

Quoted 7 lines · Guenter Roeck

Building allmodconfig images on systems with SPARSEMEM=n results in the following message.

WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]

Quoted 4 lines

After Linus' fix for PHYSMEM_END, GET_FREE_REGION doesn't need to depend on SPARSEMEM anymore. So, I think we can remove the dependency. Can you check whether the following patch work for you on top of latest upstream kernel (with Linus' fix).

Quoted 6 lines

Yes it does, thanks!

One remaining issue is that RESOURCE_KUNIT_TEST selects GET_FREE_REGION. IMHO merely enabling a test should not enable extra functionality in the kernel. Can the individual test(s) that do depend on GET_FREE_REGION be protected by #ifdef CONFIG_GET_FREE_REGION instead?

After checking GET_FREE_REGION, I don't think that it's a special functionality. I guess it's selectable because it depends on SPARSEMEM and to reduce code size.

Quoted 5 lines
Quoted 1 line

Hi, Dan, please correct me if I'm wrong here.

Right, the only reason it is selectable is just to be mindful is micro-bloat in kernel/resource.c for the small number of drivers that need that call.

Thanks for explanation.

Quoted 9 lines
Quoted 2 lines

So, to reduce #ifdef in .c file as much as possible and make code simpler, I prefer to select it for RESOURCE_KUNIT_TEST.

I agree with the result, but for a different rationale.

RESOURCE_KUNIT_TEST is simply another "driver" that needs GET_FREE_REGION. So while I agree with the general idea that "enabling a test should not enable extra functionality", in this case the *test* is the extra functionality and GET_FREE_REGION comes along for the ride.

Thanks, this sounds totally reasonable for me.

--
Best Regards,
Huang, Ying