On 3/9/21 9:41 AM, Oscar Salvador wrote: > We can optimize in the case we are adding consecutive sections, so no > memset(PAGE_UNUSED) is needed. > In that case, let us keep track where the unused range of the previous > memory range begins, so we can compare it with start of the range to be > added. > If they are equal, we know sections are added consecutively. > > For that purpose, let us introduce 'unused_pmd_start', which always holds > the beginning of the unused memory range. > > In the case a section does not contiguously follow the previous one, we > know we can memset [unused_pmd_start, PMD_BOUNDARY) with PAGE_UNUSE. > > This patch is based on a similar patch by David Hildenbrand: > > https://lore.kernel.org/linux-mm/20200722094558.9828-10-david@xxxxxxxxxx/ > > Signed-off-by: Oscar Salvador <osalvador@xxxxxxx> This is much more clear now. Thanks! Acked-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>