* [PATCH] x86: mm: clean up probe_memory_block_size()
@ 2015-11-24 20:16 Seth Jennings
2015-11-26 9:12 ` Ingo Molnar
0 siblings, 1 reply; 3+ messages in thread
From: Seth Jennings @ 2015-11-24 20:16 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Seth Jennings, Ingo Molnar, Peter Anvin, Daniel J Blueman,
Yinghai Lu, x86, linux-kernel
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 <sjennings@variantweb.net>
---
arch/x86/mm/init_64.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index ec081fe..a83c470 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,26 +1195,15 @@ int kern_addr_valid(unsigned long addr)
static unsigned long probe_memory_block_size(void)
{
- /* start from 2g */
- unsigned long bz = 1UL<<31;
+ unsigned long bz = MIN_MEMORY_BLOCK_SIZE;
- 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;
+ bz = 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);
+ pr_debug("memory block size : %ldMB\n", bz >> 20);
return bz;
}
--
2.5.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] x86: mm: clean up probe_memory_block_size()
2015-11-24 20:16 [PATCH] x86: mm: clean up probe_memory_block_size() Seth Jennings
@ 2015-11-26 9:12 ` Ingo Molnar
2015-11-27 2:37 ` Seth Jennings
0 siblings, 1 reply; 3+ messages in thread
From: Ingo Molnar @ 2015-11-26 9:12 UTC (permalink / raw)
To: Seth Jennings
Cc: Thomas Gleixner, Ingo Molnar, Peter Anvin, Daniel J Blueman,
Yinghai Lu, x86, linux-kernel
* Seth Jennings <sjennings@variantweb.net> wrote:
> 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 <sjennings@variantweb.net>
> ---
> arch/x86/mm/init_64.c | 22 ++++++----------------
> 1 file changed, 6 insertions(+), 16 deletions(-)
>
> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index ec081fe..a83c470 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,26 +1195,15 @@ int kern_addr_valid(unsigned long addr)
>
> static unsigned long probe_memory_block_size(void)
> {
> + unsigned long bz = MIN_MEMORY_BLOCK_SIZE;
>
> + /* 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");
> + bz = 2UL << 30; /* 2GB */
> }
>
> + pr_debug("memory block size : %ldMB\n", bz >> 20);
>
> return bz;
> }
So why keep 'bz' at all? Just return with the right value and be done with it.
'bz' is just an unnecessary confusion factor.
Thanks,
Ingo
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] x86: mm: clean up probe_memory_block_size()
2015-11-26 9:12 ` Ingo Molnar
@ 2015-11-27 2:37 ` Seth Jennings
0 siblings, 0 replies; 3+ messages in thread
From: Seth Jennings @ 2015-11-27 2:37 UTC (permalink / raw)
To: Ingo Molnar
Cc: Thomas Gleixner, Ingo Molnar, Peter Anvin, Daniel J Blueman,
Yinghai Lu, x86, linux-kernel
On Thu, Nov 26, 2015 at 10:12:01AM +0100, Ingo Molnar wrote:
>
> * Seth Jennings <sjennings@variantweb.net> wrote:
>
> > 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 <sjennings@variantweb.net>
> > ---
> > arch/x86/mm/init_64.c | 22 ++++++----------------
> > 1 file changed, 6 insertions(+), 16 deletions(-)
> >
> > diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> > index ec081fe..a83c470 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,26 +1195,15 @@ int kern_addr_valid(unsigned long addr)
> >
> > static unsigned long probe_memory_block_size(void)
> > {
> > + unsigned long bz = MIN_MEMORY_BLOCK_SIZE;
> >
> > + /* 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");
> > + bz = 2UL << 30; /* 2GB */
> > }
> >
> > + pr_debug("memory block size : %ldMB\n", bz >> 20);
> >
> > return bz;
> > }
>
> So why keep 'bz' at all? Just return with the right value and be done with it.
> 'bz' is just an unnecessary confusion factor.
Good point. Just send out v2.
Thanks,
Seth
>
> Thanks,
>
> Ingo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-11-27 2:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-24 20:16 [PATCH] x86: mm: clean up probe_memory_block_size() Seth Jennings
2015-11-26 9:12 ` Ingo Molnar
2015-11-27 2:37 ` Seth Jennings
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox