v2:
remove local bz variable (Ingo) and debug message since, if
the 2GB message doesn't print, there is only one possible
block size.
The cumulative effect of bdee237c and 982792c7 is some pretty convoluted
code. This commit has no (intended) functional change; just seeks to
simplify and make the code more understandable.
The whole section with the "tail size" doesn't seem to be reachable,
since both the >= 64GB and < 64GB case return, so it was removed.
This commit also adds code back for the UV case since it seemed to just
go away without reason in bdee237c and might lead to unexpected change
in behavior.
Signed-off-by: Seth Jennings <[email protected]>
---
arch/x86/mm/init_64.c | 24 +++++-------------------
1 file changed, 5 insertions(+), 19 deletions(-)
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index ec081fe..b05df4f 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -52,6 +52,7 @@
#include <asm/numa.h>
#include <asm/cacheflush.h>
#include <asm/init.h>
+#include <asm/uv/uv.h>
#include <asm/setup.h>
#include "mm_internal.h"
@@ -1194,28 +1195,13 @@ int kern_addr_valid(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))) {
+ /* if system is UV or has 64GB of RAM or more, use large blocks */
+ if (is_uv_system() || ((max_pfn << PAGE_SHIFT) >= (64UL << 30))) {
pr_info("Using 2GB memory block size for large-memory system\n");
- return 2UL * 1024 * 1024 * 1024;
+ return 2UL << 30; /* 2GB */
}
- /* 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;
--
2.5.0
* Seth Jennings <[email protected]> wrote:
> v2:
> remove local bz variable (Ingo) and debug message since, if
> the 2GB message doesn't print, there is only one possible
> block size.
I'd not remove the info message, it would print the memory block size regardless
of memory size. Yes, one could decode the 'no message' case as 'the kernel used
the default value' - but that's very version dependent and obscure in any case.
Please keep the debug message in both code paths, like the original code had it.
But, on a second thought, I'd definitely harmonize the messages, instead of:
> pr_info("Using 2GB memory block size for large-memory system\n");
> printk(KERN_DEBUG "memory block size : %ldMB\n", bz >> 20);
I'd print:
> pr_info("x86/mm: Memory block size: 2GB, large-memory system\n");
> pr_info("x86/mm: Memory block size: %ldMB\n", bz >> 20);
Also note how I changed both printouts to pr_info(), so that we have the memory
block size information printed unconditionally.
(And btw., doing this printout means that we should keep the 'bz' local variable.)
Thanks,
Ingo
On Fri, Nov 27, 2015 at 08:39:32AM +0100, Ingo Molnar wrote:
>
> * Seth Jennings <[email protected]> wrote:
>
> > v2:
> > remove local bz variable (Ingo) and debug message since, if
> > the 2GB message doesn't print, there is only one possible
> > block size.
>
> I'd not remove the info message, it would print the memory block size regardless
> of memory size. Yes, one could decode the 'no message' case as 'the kernel used
> the default value' - but that's very version dependent and obscure in any case.
> Please keep the debug message in both code paths, like the original code had it.
>
> But, on a second thought, I'd definitely harmonize the messages, instead of:
>
> > pr_info("Using 2GB memory block size for large-memory system\n");
> > printk(KERN_DEBUG "memory block size : %ldMB\n", bz >> 20);
>
> I'd print:
>
> > pr_info("x86/mm: Memory block size: 2GB, large-memory system\n");
> > pr_info("x86/mm: Memory block size: %ldMB\n", bz >> 20);
>
> Also note how I changed both printouts to pr_info(), so that we have the memory
> block size information printed unconditionally.
>
> (And btw., doing this printout means that we should keep the 'bz' local variable.)
Just sent out v3.
Thanks,
Seth
>
> Thanks,
>
> Ingo