> Uhmf, I have to confess that this whole thing about kernelcore and movablecore > makes me head spin. > I agree that clamping the range to the node's start_pfn/end_pfn is the right > thing to do. > On the other hand, I cannot figure out why these two statements from > zone_spanned_pages_in_node() do not help in setting the right values. > *zone_end_pfn = min(*zone_end_pfn, node_end_pfn); > *zone_start_pfn = max(*zone_start_pfn, node_start_pfn); > If I take one of your examples: > Node 0: > node_start_pfn=1 node_end_pfn=2822144 > DMA zone_low=1 zone_high=4096 > DMA32 zone_low=4096 zone_high=1048576 > Normal zone_low=1048576 zone_high=7942144 > Movable zone_low=0 zone_high=0 > *zone_end_pfn should be set to 2822144, and so zone_end_pfn - zone_start_pfn > should return the right value? > Or is it because we have the wrong values before calling > adjust_zone_range_for_zone_movable() and the whole thing gets messed up there? > Please, note that the patch looks correct to me, I just want to understand > why those two statements do not help here. Of course, the following statements have similar functions as clamp * zone_end_pfn = min (* zone_end_pfn, node_end_pfn); * zone_start_pfn = max (* zone_start_pfn, node_start_pfn); > Or is it because we have the wrong values before calling > adjust_zone_range_for_zone_movable() and the whole thing gets messed up there? Yes, we have the wrong values before calling adjust_zone_range_for_zone_movable() and the whole thing gets messed up there Let's focus on the process of adjust_zone_range_for_zone_movable, in the last conditional statement: /* Check if this whole range is within ZONE_MOVABLE*/ } Other if (* zone_start_pfn >= zone_movable_pfn [nid]) * zone_start_pfn = zone_end_pfn; For node 1, when zone_type is ZONE_NORMAL, if there is no clamp when entering adjustment_zone_range_for_zone_movable, then *zone_start_pfn does not satisfy the condition and will not be corrected, this is the root cause of BUG. This fix only considers the minimum risk changes of this point without affecting the results of other values, such as spanned pages, present pages and absent pages of every node. Perhaps, a series of optimizations can also be made. Thank you for your review.