Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1599694 > unrolled thread

Re: [PATCH] x86/mm: trivial code cleanup for memory_map_top_doown()

Started byBorislav Petkov <bp@alien8.de>
First post2017-03-13 20:00 +0100
Last post2017-03-20 03:30 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] x86/mm: trivial code cleanup for memory_map_top_doown() Borislav Petkov <bp@alien8.de> - 2017-03-13 20:00 +0100
    Re: [PATCH] x86/mm: trivial code cleanup for memory_map_top_doown() Wei Yang <richard.weiyang@gmail.com> - 2017-03-14 05:00 +0100
      Re: [PATCH] x86/mm: trivial code cleanup for memory_map_top_doown() Wei Yang <richard.weiyang@gmail.com> - 2017-03-20 03:30 +0100

#1599694 — Re: [PATCH] x86/mm: trivial code cleanup for memory_map_top_doown()

FromBorislav Petkov <bp@alien8.de>
Date2017-03-13 20:00 +0100
SubjectRe: [PATCH] x86/mm: trivial code cleanup for memory_map_top_doown()
Message-ID<tkDmh-4GD-9@gated-at.bofh.it>
On Fri, Feb 17, 2017 at 10:30:33PM +0800, Wei Yang wrote:
> In case (last_start <= step_size), start is for sure to be 0. So, it is

Well, lemme see:

[    0.000000] memory_map_top_down: entry, [0x100000:0x7ffdf000)
[    0.000000] memory_map_top_down: addr: 0x7fc00000, real_end: 0x7fe00000
[    0.000000] memory_map_top_down: last_start: 0x40000000 <= step_size: 0x2000000000, start: 0x40000000
											      ^^^^^^^^^^
It doesn't look like 0 to me.

---
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 2193799ca800..d3b02a416df3 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -506,10 +506,14 @@ static void __init memory_map_top_down(unsigned long map_start,
 	unsigned long addr;
 	unsigned long mapped_ram_size = 0;
 
+	pr_info("%s: entry, [0x%lx:0x%lx)\n", __func__, map_start, map_end);
+
 	/* xen has big range in reserved near end of ram, skip it at first.*/
 	addr = memblock_find_in_range(map_start, map_end, PMD_SIZE, PMD_SIZE);
 	real_end = addr + PMD_SIZE;
 
+	pr_info("%s: addr: 0x%lx, real_end: 0x%lx\n", __func__, addr, real_end);
+
 	/* step_size need to be small so pgt_buf from BRK could cover it */
 	step_size = PMD_SIZE;
 	max_pfn_mapped = 0; /* will get exact value next */
@@ -527,8 +531,13 @@ static void __init memory_map_top_down(unsigned long map_start,
 			start = round_down(last_start - 1, step_size);
 			if (start < map_start)
 				start = map_start;
-		} else
+		} else {
+			pr_info("%s: last_start: 0x%lx <= step_size: 0x%lx, start: 0x%lx\n",
+				__func__, last_start, step_size, start);
+
 			start = map_start;
+		}
+
 		mapped_ram_size += init_range_memory_mapping(start,
 							last_start);
 		last_start = start;

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

[toc] | [next] | [standalone]


#1600021

FromWei Yang <richard.weiyang@gmail.com>
Date2017-03-14 05:00 +0100
Message-ID<tkLMR-2GV-1@gated-at.bofh.it>
In reply to#1599694

[Multipart message — attachments visible in raw view] — view raw

On Mon, Mar 13, 2017 at 07:50:21PM +0100, Borislav Petkov wrote:
>On Fri, Feb 17, 2017 at 10:30:33PM +0800, Wei Yang wrote:
>> In case (last_start <= step_size), start is for sure to be 0. So, it is
>

Hmm, I may write it more specific:

"start" is for sure to be set to 0 with round_down(last_start - 1, step_size).

>Well, lemme see:
>
>[    0.000000] memory_map_top_down: entry, [0x100000:0x7ffdf000)
>[    0.000000] memory_map_top_down: addr: 0x7fc00000, real_end: 0x7fe00000
>[    0.000000] memory_map_top_down: last_start: 0x40000000 <= step_size: 0x2000000000, start: 0x40000000
>											      ^^^^^^^^^^
>It doesn't look like 0 to me.
>
>---
>diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
>index 2193799ca800..d3b02a416df3 100644
>--- a/arch/x86/mm/init.c
>+++ b/arch/x86/mm/init.c
>@@ -527,8 +531,13 @@ static void __init memory_map_top_down(unsigned long map_start,
> 			start = round_down(last_start - 1, step_size);
> 			if (start < map_start)
> 				start = map_start;
>-		} else
>+		} else {
>+			pr_info("%s: last_start: 0x%lx <= step_size: 0x%lx, start: 0x%lx\n",
>+				__func__, last_start, step_size, start);
>+

If you change this log with the following

			pr_err("%s: last_start: 0x%lx <= step_size: 0x%lx, start: 0x%lx\n",
				__func__, last_start, step_size,
				round_down(last_start - 1, step_size));

You could see after calculation, start is 0 when (last_start <= step_size).

-- 
Wei Yang
Help you, Help me

[toc] | [prev] | [next] | [standalone]


#1604147

FromWei Yang <richard.weiyang@gmail.com>
Date2017-03-20 03:30 +0100
Message-ID<tmVf4-6oi-11@gated-at.bofh.it>
In reply to#1600021

[Multipart message — attachments visible in raw view] — view raw

Hi, Borislav

Do you still have some concern on this change?

On Tue, Mar 14, 2017 at 11:56:39AM +0800, Wei Yang wrote:
>On Mon, Mar 13, 2017 at 07:50:21PM +0100, Borislav Petkov wrote:
>>On Fri, Feb 17, 2017 at 10:30:33PM +0800, Wei Yang wrote:
>>> In case (last_start <= step_size), start is for sure to be 0. So, it is
>>
>
>Hmm, I may write it more specific:
>
>"start" is for sure to be set to 0 with round_down(last_start - 1, step_size).
>
>>Well, lemme see:
>>
>>[    0.000000] memory_map_top_down: entry, [0x100000:0x7ffdf000)
>>[    0.000000] memory_map_top_down: addr: 0x7fc00000, real_end: 0x7fe00000
>>[    0.000000] memory_map_top_down: last_start: 0x40000000 <= step_size: 0x2000000000, start: 0x40000000
>>											      ^^^^^^^^^^
>>It doesn't look like 0 to me.
>>
>>---
>>diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
>>index 2193799ca800..d3b02a416df3 100644
>>--- a/arch/x86/mm/init.c
>>+++ b/arch/x86/mm/init.c
>>@@ -527,8 +531,13 @@ static void __init memory_map_top_down(unsigned long map_start,
>> 			start = round_down(last_start - 1, step_size);
>> 			if (start < map_start)
>> 				start = map_start;
>>-		} else
>>+		} else {
>>+			pr_info("%s: last_start: 0x%lx <= step_size: 0x%lx, start: 0x%lx\n",
>>+				__func__, last_start, step_size, start);
>>+
>
>If you change this log with the following
>
>			pr_err("%s: last_start: 0x%lx <= step_size: 0x%lx, start: 0x%lx\n",
>				__func__, last_start, step_size,
>				round_down(last_start - 1, step_size));
>
>You could see after calculation, start is 0 when (last_start <= step_size).
>
>-- 
>Wei Yang
>Help you, Help me



-- 
Wei Yang
Help you, Help me

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web