Skip to contentSkip to conversation

percpu: km: remove SMP check

PATCH In review Peng Fan 3 participants 13 messages Feb 24, 2019 – Mar 3, 2019

Subsystems (2)
lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH 1/2 percpu: km: remove SMP check

percpu-km could only be selected by NEED_PER_CPU_KM which depends on !SMP, so CONFIG_SMP will be false when choose percpu-km.

---
 mm/percpu-km.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/percpu-km.c +1 -1
index 0f643dc2dc65..66e5598be876 100644
@@ -27,7 +27,7 @@
  *   chunk size is not aligned.  percpu-km code will whine about it.
  */
 
-#if defined(CONFIG_SMP) && defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
+#if defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
 #error "contiguous percpu allocation is incompatible with paged first chunk"
 #endif
 
Signature · 1 line
2.16.4
author
#1 lore raw

PATCH 2/2 percpu: km: no need to consider pcpu_group_offsets[0]

percpu-km is used on UP systems which only has one group, so the group offset will be always 0, there is no need to subtract pcpu_group_offsets[0] when assigning chunk->base_addr

---
 mm/percpu-km.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/percpu-km.c +1 -1
index 66e5598be876..8872c21a487b 100644
@@ -67,7 +67,7 @@ static struct pcpu_chunk *pcpu_create_chunk(gfp_t gfp)
 		pcpu_set_page_chunk(nth_page(pages, i), chunk);
 
 	chunk->data = pages;
-	chunk->base_addr = page_address(pages) - pcpu_group_offsets[0];
+	chunk->base_addr = page_address(pages);
 
 	spin_lock_irqsave(&pcpu_lock, flags);
 	pcpu_chunk_populated(chunk, 0, nr_pages, false);
Signature · 1 line
2.16.4
#2 lore raw

Re: [PATCH 2/2] percpu: km: no need to consider pcpu_group_offsets[0]

Quoted 25 lines · Peng Fan

percpu-km is used on UP systems which only has one group, so the group offset will be always 0, there is no need to subtract pcpu_group_offsets[0] when assigning chunk->base_addr

---
 mm/percpu-km.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/percpu-km.c +1 -1
index 66e5598be876..8872c21a487b 100644
@@ -67,7 +67,7 @@ static struct pcpu_chunk *pcpu_create_chunk(gfp_t gfp)
 		pcpu_set_page_chunk(nth_page(pages, i), chunk);
 
 	chunk->data = pages;
-	chunk->base_addr = page_address(pages) - pcpu_group_offsets[0];
+	chunk->base_addr = page_address(pages);
 
 	spin_lock_irqsave(&pcpu_lock, flags);
 	pcpu_chunk_populated(chunk, 0, nr_pages, false);
Signature · 1 line
2.16.4

While I do think you're right, creating a chunk is not a part of the critical path and subtracting 0 is incredibly minor overhead. So I'd rather keep the code as is to maintain consistency between percpu-vm.c and percpu-km.c.

Thanks,
Dennis

author
#3 lore raw

RE: [PATCH 2/2] percpu: km: no need to consider pcpu_group_offsets[0]

Hi Dennis,

Quoted 31 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: 2019年2月25日 23:16
To: Peng Fan <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/2] percpu: km: no need to consider pcpu_group_offsets[0]

mm/percpu-km.c static struct pcpu_chunk *pcpu_create_chunk(gfp_t

Quoted 14 lines · Peng Fan

percpu-km is used on UP systems which only has one group, so the group offset will be always 0, there is no need to subtract pcpu_group_offsets[0] when assigning chunk->base_addr

---
 mm/percpu-km.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/percpu-km.c index renamed from mm/percpu-km.c +0 -0

66e5598be876..8872c21a487b 100644

mm/percpu-km.c +0 -0
@@ -67,7 +67,7 @@ static struct pcpu_chunk *pcpu_create_chunk(gfp_t

gfp)

Quoted 6 lines
mm/percpu-km.c +1 -1
 		pcpu_set_page_chunk(nth_page(pages, i), chunk);
 
 	chunk->data = pages;
-	chunk->base_addr = page_address(pages) - pcpu_group_offsets[0];
+	chunk->base_addr = page_address(pages);
 
Quoted 10 lines
Quoted 5 lines
mm/percpu-km.c +0 -1
 	spin_lock_irqsave(&pcpu_lock, flags);
 	pcpu_chunk_populated(chunk, 0, nr_pages, false);
--

2.16.4

While I do think you're right, creating a chunk is not a part of the critical path and subtracting 0 is incredibly minor overhead. So I'd rather keep the code as is to maintain consistency between percpu-vm.c and percpu-km.c.

That's ok to keep consistency, since you prefer that.

Thanks,
Peng.

Quoted 3 lines

Thanks,
Dennis

#4 lore raw

Re: [PATCH 2/2] percpu: km: no need to consider pcpu_group_offsets[0]

In reply to [email protected]
Quoted 7 lines · On Mon, 25 Feb 2019, [email protected] wrote:
Quoted 7 lines
mm/percpu-km.c +1 -1
@@ -67,7 +67,7 @@ static struct pcpu_chunk *pcpu_create_chunk(gfp_t gfp)
 		pcpu_set_page_chunk(nth_page(pages, i), chunk);
 
 	chunk->data = pages;
-	chunk->base_addr = page_address(pages) - pcpu_group_offsets[0];
+	chunk->base_addr = page_address(pages);
 
Quoted 10 lines
Quoted 5 lines
mm/percpu-km.c +0 -1
 	spin_lock_irqsave(&pcpu_lock, flags);
 	pcpu_chunk_populated(chunk, 0, nr_pages, false);
--

2.16.4

While I do think you're right, creating a chunk is not a part of the critical path and subtracting 0 is incredibly minor overhead. So I'd rather keep the code as is to maintain consistency between percpu-vm.c and percpu-km.c.

Well it is confusing if there the expression is there but never used. It is clearer with the patch.

maintainer
#5 lore raw

Re: [PATCH 2/2] percpu: km: no need to consider pcpu_group_offsets[0]

Quoted 20 lines · Christopher Lameter
Quoted 7 lines · On Mon, 25 Feb 2019, [email protected] wrote:
Quoted 7 lines
mm/percpu-km.c +1 -1
@@ -67,7 +67,7 @@ static struct pcpu_chunk *pcpu_create_chunk(gfp_t gfp)
 		pcpu_set_page_chunk(nth_page(pages, i), chunk);
 
 	chunk->data = pages;
-	chunk->base_addr = page_address(pages) - pcpu_group_offsets[0];
+	chunk->base_addr = page_address(pages);
 
Quoted 10 lines
Quoted 5 lines
mm/percpu-km.c +0 -1
 	spin_lock_irqsave(&pcpu_lock, flags);
 	pcpu_chunk_populated(chunk, 0, nr_pages, false);
--

2.16.4

While I do think you're right, creating a chunk is not a part of the critical path and subtracting 0 is incredibly minor overhead. So I'd rather keep the code as is to maintain consistency between percpu-vm.c and percpu-km.c.

Quoted 3 lines

Well it is confusing if there the expression is there but never used. It is clearer with the patch.

Okay. I'll apply it with your ack if that's fine.

Thanks,
Dennis

maintainer
#6 lore raw
In reply to Peng Fan
Quoted 24 lines · Peng Fan

percpu-km could only be selected by NEED_PER_CPU_KM which depends on !SMP, so CONFIG_SMP will be false when choose percpu-km.

---
 mm/percpu-km.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/percpu-km.c +1 -1
index 0f643dc2dc65..66e5598be876 100644
@@ -27,7 +27,7 @@
  *   chunk size is not aligned.  percpu-km code will whine about it.
  */
 
-#if defined(CONFIG_SMP) && defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
+#if defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
 #error "contiguous percpu allocation is incompatible with paged first chunk"
 #endif
 
Signature · 1 line
2.16.4

Hi,

I think keeping CONFIG_SMP makes this easier to remember dependencies rather than having to dig into the config. So this is a NACK from me.

Thanks,
Dennis

author
#7 lore raw

Hi Dennis,

Quoted 33 lines

-----Original Message-----
From: Dennis Zhou [mailto:[email protected]]
Sent: 2019年2月25日 23:14
To: Peng Fan <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/2] percpu: km: remove SMP check

Quoted 1 line · Peng Fan

percpu-km could only be selected by NEED_PER_CPU_KM which depends

on

Quoted 12 lines

!SMP, so CONFIG_SMP will be false when choose percpu-km.

---
 mm/percpu-km.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/percpu-km.c index renamed from mm/percpu-km.c +0 -0

0f643dc2dc65..66e5598be876 100644

mm/percpu-km.c line 32

Quoted 7 lines
mm/percpu-km.c +1 -1
@@ -27,7 +27,7 @@
  *   chunk size is not aligned.  percpu-km code will whine about it.
  */
 
-#if defined(CONFIG_SMP) &&
 defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
+#if defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
 #error "contiguous percpu allocation is incompatible with paged first

chunk"

Quoted 2 lines
mm/percpu-km.c +0 -0
 #endif
Quoted 8 lines
Quoted 3 lines

--
2.16.4

Hi,

I think keeping CONFIG_SMP makes this easier to remember dependencies rather than having to dig into the config. So this is a NACK from me.

You might be wrong here.
In mm/Kconfig, NEED_PER_CPU_KM default y depends on !SMP. So if CONFIG_SMP is not defined, NEED_PER_CPU_KM will be true. If we also define CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK, the #error will have no chance to be detected because CONFIG_SMP already be false.
That means CONFIG_SMP will always be false if percpu-km is used. So need to drop the CONFIG_SMP check here.

Thanks,
Peng.

Quoted 3 lines

Thanks,
Dennis

#8 lore raw
In reply to Dennis Zhou
Quoted 9 lines · Dennis Zhou
Quoted 9 lines
mm/percpu-km.c +1 -1
@@ -27,7 +27,7 @@
  *   chunk size is not aligned.  percpu-km code will whine about it.
  */
 
-#if defined(CONFIG_SMP) && defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
+#if defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
 #error "contiguous percpu allocation is incompatible with paged first chunk"
 #endif
 
Quoted 8 lines
Quoted 3 lines

--
2.16.4

Hi,

I think keeping CONFIG_SMP makes this easier to remember dependencies rather than having to dig into the config. So this is a NACK from me.

But it simplifies the code and makes it easier to read.

maintainer
#9 lore raw
Quoted 17 lines · Christopher Lameter
Quoted 15 lines · Dennis Zhou
Quoted 10 lines
(quoted diff) +1 -2
@@ -27,7 +27,7 @@
  *   chunk size is not aligned.  percpu-km code will whine about it.
  */
 
-#if defined(CONFIG_SMP) && defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
+#if defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
 #error "contiguous percpu allocation is incompatible with paged first chunk"
 #endif
 
--
Quoted 2 lines

2.16.4

Hi,

Quoted 6 lines
Quoted 2 lines

I think keeping CONFIG_SMP makes this easier to remember dependencies rather than having to dig into the config. So this is a NACK from me.

But it simplifies the code and makes it easier to read.

I think the check isn't quite right after looking at it a little longer. Looking at x86, I believe you can compile it with !SMP and CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK will still be set. This should still work because x86 has an MMU.

I think more correctly it would be something like below, but I don't have the time to fully verify it right now.

Thanks,
Dennis

---

mm/percpu-km.c +1 -1
index 0f643dc2dc65..69ccad7d9807 100644
@@ -27,7 +27,7 @@
  *   chunk size is not aligned.  percpu-km code will whine about it.
  */
 
-#if defined(CONFIG_SMP) && defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
+#if !defined(CONFIG_MMU) && defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
 #error "contiguous percpu allocation is incompatible with paged first chunk"
 #endif
 
author Acked-by
#10 lore raw

Hi Dennis

Quoted 32 lines

-----Original Message-----
From: Dennis Zhou [mailto:[email protected]]
Sent: 2019年2月27日 1:04
To: Christopher Lameter <[email protected]>
Cc: Peng Fan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/2] percpu: km: remove SMP check

Quoted 10 lines · Christopher Lameter
Quoted 8 lines · Dennis Zhou

Review line 32

Quoted 8 lines
(quoted diff) +1 -1
@@ -27,7 +27,7 @@
  *   chunk size is not aligned.  percpu-km code will whine about it.
  */
 
-#if defined(CONFIG_SMP) &&
 defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
+#if defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
 #error "contiguous percpu allocation is incompatible with paged first

chunk"

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
(quoted diff) +0 -1
 #endif
 
--

2.16.4

Hi,

I think keeping CONFIG_SMP makes this easier to remember dependencies rather than having to dig into the config. So this is a NACK

from me.

Quoted 1 line
Quoted 8 lines
Quoted 3 lines

But it simplifies the code and makes it easier to read.

I think the check isn't quite right after looking at it a little longer. Looking at x86, I believe you can compile it with !SMP and CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK will still be set. This should still work because x86 has an MMU.

You are right, x86 could boots up with NEED_PER_CPU_PAGE_FIRST_CHUNK =y and SMP=n. Tested with qemu, info as below:

/ # zcat /proc/config.gz | grep NEED_PER_CPU_KM CONFIG_NEED_PER_CPU_KM=y
/ # zcat /proc/config.gz | grep SMP CONFIG_BROKEN_ON_SMP=y
# CONFIG_SMP is not set CONFIG_GENERIC_SMP_IDLE_THREAD=y
/ # zcat /proc/config.gz | grep NEED_PER_CPU_PAGE_FIRST_CHUNK CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y
/ # cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 6
model : 6
model name : QEMU Virtual CPU version 2.5+
stepping : 3
cpu MHz : 3192.613
cache size : 512 KB
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm nopl cpuid pni cx16 hypervisor lahf_lm svm 3dnowprefetl
bugs : fxsave_leak sysret_ss_attrs spectre_v1 spectre_v2 spec_store_bypass
bogomips : 6385.22
TLB size : 1024 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 42 bits physical, 48 bits virtual
power management:

But from the comments in this file:
"
* - CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK must not be defined. It's
* not compatible with PER_CPU_KM. EMBED_FIRST_CHUNK should work
* fine.
"

I did not read into details why it is not allowed, but x86 could still work with KM and NEED_PER_CPU_PAGE_FIRST_CHUNK.

Quoted 14 lines

I think more correctly it would be something like below, but I don't have the time to fully verify it right now.

Thanks,
Dennis

---

mm/percpu-km.c index renamed from mm/percpu-km.c +0 -0

0f643dc2dc65..69ccad7d9807 100644

mm/percpu-km.c line 32

Quoted 9 lines
mm/percpu-km.c +2 -1
@@ -27,7 +27,7 @@
  *   chunk size is not aligned.  percpu-km code will whine about it.
  */
 
-#if defined(CONFIG_SMP) &&
 defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
+#if !defined(CONFIG_MMU) &&
+defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
 #error "contiguous percpu allocation is incompatible with paged first chunk"
 #endif

Thanks,
Peng

maintainer
#11 lore raw
Quoted 84 lines · Peng Fan

Hi Dennis

Quoted 32 lines

-----Original Message-----
From: Dennis Zhou [mailto:[email protected]]
Sent: 2019年2月27日 1:04
To: Christopher Lameter <[email protected]>
Cc: Peng Fan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/2] percpu: km: remove SMP check

Quoted 10 lines · Christopher Lameter
Quoted 8 lines · Dennis Zhou

Review line 32

Quoted 8 lines
(quoted diff) +1 -1
@@ -27,7 +27,7 @@
  *   chunk size is not aligned.  percpu-km code will whine about it.
  */
 
-#if defined(CONFIG_SMP) &&
 defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
+#if defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
 #error "contiguous percpu allocation is incompatible with paged first

chunk"

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
(quoted diff) +0 -1
 #endif
 
--

2.16.4

Hi,

I think keeping CONFIG_SMP makes this easier to remember dependencies rather than having to dig into the config. So this is a NACK

from me.

Quoted 1 line
Quoted 8 lines
Quoted 3 lines

But it simplifies the code and makes it easier to read.

I think the check isn't quite right after looking at it a little longer. Looking at x86, I believe you can compile it with !SMP and CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK will still be set. This should still work because x86 has an MMU.

You are right, x86 could boots up with NEED_PER_CPU_PAGE_FIRST_CHUNK =y and SMP=n. Tested with qemu, info as below:

/ # zcat /proc/config.gz | grep NEED_PER_CPU_KM CONFIG_NEED_PER_CPU_KM=y
/ # zcat /proc/config.gz | grep SMP CONFIG_BROKEN_ON_SMP=y
# CONFIG_SMP is not set CONFIG_GENERIC_SMP_IDLE_THREAD=y
/ # zcat /proc/config.gz | grep NEED_PER_CPU_PAGE_FIRST_CHUNK CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y
/ # cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 6
model : 6
model name : QEMU Virtual CPU version 2.5+
stepping : 3
cpu MHz : 3192.613
cache size : 512 KB
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm nopl cpuid pni cx16 hypervisor lahf_lm svm 3dnowprefetl
bugs : fxsave_leak sysret_ss_attrs spectre_v1 spectre_v2 spec_store_bypass
bogomips : 6385.22
TLB size : 1024 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 42 bits physical, 48 bits virtual
power management:

But from the comments in this file:
"
* - CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK must not be defined. It's
* not compatible with PER_CPU_KM. EMBED_FIRST_CHUNK should work
* fine.
"

Quoted 3 lines

I did not read into details why it is not allowed, but x86 could still work with KM and NEED_PER_CPU_PAGE_FIRST_CHUNK.

The first chunk requires special handling on SMP to bring the static variables into the percpu address space. On UP, identity mapping makes static variables indistinguishable by aligning the percpu address space and the virtual adress space. The percpu-km allocator allocates full chunks at a time to deal with NOMMU archs. So the difference is if the virtual address space is the same as the physical.

Quoted 26 lines
Quoted 14 lines

I think more correctly it would be something like below, but I don't have the time to fully verify it right now.

Thanks,
Dennis

---

mm/percpu-km.c index renamed from mm/percpu-km.c +0 -0

0f643dc2dc65..69ccad7d9807 100644

mm/percpu-km.c line 32

Quoted 9 lines
mm/percpu-km.c +2 -1
@@ -27,7 +27,7 @@
  *   chunk size is not aligned.  percpu-km code will whine about it.
  */
 
-#if defined(CONFIG_SMP) &&
 defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
+#if !defined(CONFIG_MMU) &&
+defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
 #error "contiguous percpu allocation is incompatible with paged first chunk"
 #endif
Quoted 2 lines

Thanks,
Peng

While this change may seem right to me. Verification would be to double check other architectures too. x86 just happened to be a counter example I had in mind. Unless someone reports this as being an issue or someone takes the time to validate this more thoroughly than my cursory look. I think the risk of this outweighs the benefit. This may be something I fix in the future when I have more time. This would also involve making sure the comments are consistent.

Thanks,
Dennis

author
#12 lore raw
Quoted 108 lines

-----Original Message-----
From: Dennis Zhou [mailto:[email protected]]
Sent: 2019年2月28日 0:41
To: Peng Fan <[email protected]>
Cc: Dennis Zhou <[email protected]>; Christopher Lameter <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/2] percpu: km: remove SMP check

Quoted 10 lines · Peng Fan

Hi Dennis

Quoted 8 lines

-----Original Message-----
From: Dennis Zhou [mailto:[email protected]]
Sent: 2019年2月27日 1:04
To: Christopher Lameter <[email protected]>
Cc: Peng Fan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/2] percpu: km: remove SMP check

Quoted 5 lines
Quoted 5 lines · Christopher Lameter
Quoted 4 lines · Dennis Zhou
Quoted 3 lines

Review line 27

Quoted 3 lines
(quoted diff) +0 -0
@@ -27,7 +27,7 @@
  *   chunk size is not aligned.  percpu-km code will whine about

it.

Quoted 21 lines
Quoted 21 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
(quoted diff) +1 -1
  */
 
-#if defined(CONFIG_SMP) &&
 defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
+#if defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
 #error "contiguous percpu allocation is incompatible with

paged first

chunk"

Quoted 11 lines
Quoted 11 lines
Quoted 5 lines

#endif

--
2.16.4

Hi,

I think keeping CONFIG_SMP makes this easier to remember dependencies rather than having to dig into the config. So this is a NACK

from me.

Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

But it simplifies the code and makes it easier to read.

I think the check isn't quite right after looking at it a little longer. Looking at x86, I believe you can compile it with !SMP and CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK will still be set. This

should

Quoted 3 lines
Quoted 1 line

still work because x86 has an MMU.

You are right, x86 could boots up with

NEED_PER_CPU_PAGE_FIRST_CHUNK

Quoted 7 lines

=y and SMP=n. Tested with qemu, info as below:

/ # zcat /proc/config.gz | grep NEED_PER_CPU_KM CONFIG_NEED_PER_CPU_KM=y / # zcat /proc/config.gz | grep SMP CONFIG_BROKEN_ON_SMP=y # CONFIG_SMP is not set CONFIG_GENERIC_SMP_IDLE_THREAD=y / # zcat /proc/config.gz | grep NEED_PER_CPU_PAGE_FIRST_CHUNK

CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y

Quoted 6 lines

/ # cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 6
model : 6
model name : QEMU Virtual CPU version 2.5+

Quoted 8 lines

stepping : 3
cpu MHz : 3192.613
cache size : 512 KB
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca

cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm nopl cpuid pni cx16 hypervisor lahf_lm svm 3dnowprefetl

Quoted 1 line

bugs : fxsave_leak sysret_ss_attrs spectre_v1 spectre_v2

spec_store_bypass

Quoted 11 lines

bogomips : 6385.22
TLB size : 1024 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 42 bits physical, 48 bits virtual
power management:

But from the comments in this file:
"
* - CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK must not be defined.

It's

Quoted 1 line

* not compatible with PER_CPU_KM. EMBED_FIRST_CHUNK should

work

Quoted 6 lines

* fine.
"

I did not read into details why it is not allowed, but x86 could still work with KM and NEED_PER_CPU_PAGE_FIRST_CHUNK.

Quoted 6 lines

The first chunk requires special handling on SMP to bring the static variables into the percpu address space. On UP, identity mapping makes static variables indistinguishable by aligning the percpu address space and the virtual adress space. The percpu-km allocator allocates full chunks at a time to deal with NOMMU archs. So the difference is if the virtual address space is the same as the physical.

Thanks for clarification.

Quoted 31 lines
Quoted 17 lines
Quoted 17 lines

I think more correctly it would be something like below, but I don't have the time to fully verify it right now.

Thanks,
Dennis

---

mm/percpu-km.c index renamed from mm/percpu-km.c +0 -0

0f643dc2dc65..69ccad7d9807 100644

mm/percpu-km.c +0 -0
@@ -27,7 +27,7 @@
  *   chunk size is not aligned.  percpu-km code will whine about it.
  */
 
Quoted 5 lines

mm/percpu-km.c line 33

Quoted 5 lines
mm/percpu-km.c +2 -1
-#if defined(CONFIG_SMP) &&
 defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
+#if !defined(CONFIG_MMU) &&
+defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK)
 #error "contiguous percpu allocation is incompatible with paged first

chunk"

Quoted 7 lines
Quoted 2 lines

#endif

Thanks,
Peng

Quoted 7 lines

While this change may seem right to me. Verification would be to double check other architectures too. x86 just happened to be a counter example I had in mind. Unless someone reports this as being an issue or someone takes the time to validate this more thoroughly than my cursory look.
I think the risk of this outweighs the benefit. This may be something I fix in the future when I have more time. This would also involve making sure the comments are consistent.

I am not able to check other architectures now. So just leave the code as is.

Thanks,
Peng.

Quoted 3 lines

Thanks,
Dennis