Skip to contentSkip to conversation

x86: Drop redundant memory-block sizing code

PATCH In review Daniel J Blueman 2 participants 8 messages Nov 6, 2014 – Nov 10, 2014 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 x86: Drop redundant memory-block sizing code

Drop the unused code from selecting a fixed memory block size of 2GB on large-memory x86-64 systems.

---
 arch/x86/mm/init_64.c | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)
arch/x86/mm/init_64.c +1 -17
index ebca30f..09c0567 100644
@@ -1243,28 +1243,12 @@ int in_gate_area_no_mm(unsigned long addr)
 
 static unsigned long probe_memory_block_size(void)
 {
-	/* start from 2g */
-	unsigned long bz = 1UL<<31;
-
 	if (totalram_pages >= (64ULL << (30 - PAGE_SHIFT))) {
 		pr_info("Using 2GB memory block size for large-memory system\n");
 		return 2UL * 1024 * 1024 * 1024;
 	}
 
-	/* less than 64g installed */
-	if ((max_pfn << PAGE_SHIFT) < (16UL << 32))
-		return MIN_MEMORY_BLOCK_SIZE;
-
-	/* get the tail size */
-	while (bz > MIN_MEMORY_BLOCK_SIZE) {
-		if (!((max_pfn << PAGE_SHIFT) & (bz - 1)))
-			break;
-		bz >>= 1;
-	}
-
-	printk(KERN_DEBUG "memory block size : %ldMB\n", bz >> 20);
-
-	return bz;
+	return MIN_MEMORY_BLOCK_SIZE;
 }
 
 static unsigned long memory_block_size_probed;
Signature · 1 line
1.9.1
maintainer
#2 lore raw
Quoted 4 lines · Daniel J Blueman

Drop the unused code from selecting a fixed memory block size of 2GB on large-memory x86-64 systems.

This commit message is seriously lacking an explanation why? Why is it unused, why is it ok on systems with mem < 64g, what is the problem it solves, ...

Just ask yourself this when you write commit messages: would anyone else be able to understand what this commit was improving when anyone reads that commit message months, maybe years from now.

Thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#3 lore raw
Quoted 6 lines · Borislav Petkov
Quoted 4 lines · Daniel J Blueman

Drop the unused code from selecting a fixed memory block size of 2GB on large-memory x86-64 systems.

Quoted 7 lines

This commit message is seriously lacking an explanation why? Why is it unused, why is it ok on systems with mem < 64g, what is the problem it solves, ...

Just ask yourself this when you write commit messages: would anyone else be able to understand what this commit was improving when anyone reads that commit message months, maybe years from now.

Yes, true. I am incorrectly assuming that someone is looking at the patch in-context, but perhaps better to write assuming the code isn't seen (or at least understood).

How is this?

As the first check for 64GB or larger memory returns a 2GB memory block size in that case, the following check for less than 64GB will always evaluate true, leading to unreachable code.

Remove the second and unnecessary condition and the code in the remainder of the function, as it therefore can't be reached.

Thanks,
Daniel

Signature · 2 lines
Daniel J Blueman
Principal Software Engineer, Numascale
maintainer
#4 lore raw
Quoted 3 lines · Daniel J Blueman

As the first check for 64GB or larger memory returns a 2GB memory block size in that case, the following check for less than 64GB will always evaluate true, leading to unreachable code.

I'm reading this as this code is never running on systems < 64GB. Why is that so?

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#5 lore raw
Quoted 7 lines · Borislav Petkov
Quoted 3 lines · Daniel J Blueman

As the first check for 64GB or larger memory returns a 2GB memory block size in that case, the following check for less than 64GB will always evaluate true, leading to unreachable code.

I'm reading this as this code is never running on systems < 64GB. Why is that so?

Let me clarify that "Leading to" didn't mean "executing":

"As the first check for 64GB or larger memory returns a 2GB memory block size in that case, the following check for less than 64GB will always evaluate true and return MIN_MEMORY_BLOCK_SIZE, leading to unreachable code.

Remove the second and unnecessary condition and the code in the remainder of the function, as it therefore can't be reached."

Sheesh. Even Shakespeare would have trouble writing a exemplary changelog.

Thanks,
Daniel

Signature · 2 lines
Daniel J Blueman
Principal Software Engineer, Numascale
maintainer
#6 lore raw
Quoted 3 lines · Daniel J Blueman

"As the first check for 64GB or larger memory returns a 2GB memory block size in that case, the following check for less than 64GB will always

Right, but why isn't there a simple else? Instead, the >64GB case is looking at totalram_pages but the so-called else case is looking at max_pfn. Why, what's the difference?

My purely hypothetical suspicion is this thing used to handle some special case with memory holes where totalram_pages was still < 64GB but max_pfn was above. I'm looking at this memory block size approximation downwards which supposedly used to do something at some point, right?

Now, when you remove this, it doesn't do so anymore, potentially breaking some machines.

Or is this simply unfortunate coding and totalram_pages and max_pfn are equivalent?

Questions over questions... Maybe it is time for some git log archeology...

:-)

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#7 lore raw
Quoted 14 lines · Borislav Petkov
Quoted 3 lines · Daniel J Blueman

"As the first check for 64GB or larger memory returns a 2GB memory block size in that case, the following check for less than 64GB will always

Right, but why isn't there a simple else? Instead, the >64GB case is looking at totalram_pages but the so-called else case is looking at max_pfn. Why, what's the difference?

My purely hypothetical suspicion is this thing used to handle some special case with memory holes where totalram_pages was still < 64GB but max_pfn was above. I'm looking at this memory block size approximation downwards which supposedly used to do something at some point, right?

Quoted 8 lines

Now, when you remove this, it doesn't do so anymore, potentially breaking some machines.

Or is this simply unfortunate coding and totalram_pages and max_pfn are equivalent?

Questions over questions... Maybe it is time for some git log archeology...

Yes, totalram_pages doesn't count the MMIO hole, whereas max_pfn does.

I've made NumaConnect firmware changes that will guarantee max_pfn is always aligned to at least 2GB, so bdee237c0343a5d1a6cf72c7ea68e88338b26e08 "x86: mm: Use 2GB memory block size on large-memory x86-64 systems" can be dropped and Yinghai's approach will give 2GB memory blocks on our systems.

Thanks,
Daniel

Signature · 2 lines
Daniel J Blueman
Principal Software Engineer, Numascale
maintainer
#8 lore raw
Quoted 6 lines · Daniel J Blueman

Yes, totalram_pages doesn't count the MMIO hole, whereas max_pfn does.

I've made NumaConnect firmware changes that will guarantee max_pfn is always aligned to at least 2GB, so bdee237c0343a5d1a6cf72c7ea68e88338b26e08 "x86:
mm: Use 2GB memory block size on large-memory x86-64 systems" can be dropped and Yinghai's approach will give 2GB memory blocks on our systems.

What about the rest of the systems? I.e., the !numascale ones. This is generic code which needs to support all, not only your flavour.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--