Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1264008ybk; Thu, 21 May 2020 02:40:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWIaCQtaJ2UcUo/o6DfvIymr3IZDhqwhTpAiY/U5fHR6qvco3p2mHMFX+TG1cKsd/RGwZd X-Received: by 2002:a17:906:31d7:: with SMTP id f23mr2608900ejf.59.1590054019755; Thu, 21 May 2020 02:40:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590054019; cv=none; d=google.com; s=arc-20160816; b=P3+9q0VjU83RpiAwVJK5nQZZJcIC5hUAGvPVQnz0LwidMgt0V5V4z6Ftt9X8g7+rdU tR43c8UC/kSEJ2bam29yOa+ahN+Y9d5IKmW7G3yqUYmI53b6L2ULP0LdSnMi4btKV8/S ZC8fbxz7T2NLIJlLkg5HVlhL+dZQzIbJyoM2ns5l77zyktzlBGEC+gloETVvP5rezyHz ZYTOvLZpwTBPelsMzN41Op/1+G3YM6Q3DjhWByTrMkd0AiSJv8PQcOwW8Oe+DuPo6u+N sS4voHFEvIqWk4vc/jXZIaC+KSJpA1CP34vPFGX4/+Ae9yNeaiYoTBzxrpFmg+fyDScq i9lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=+f2rdAAfzN+nNoK0svptGRM8Acd3LzcEEpB/g9YyhrM=; b=0vrk3WOLfvQFGh+eSyqu2E+WMIJaO7uMwIoTvKxUyoDkRSNZW3rmb7AoIH4H3RShW3 Wk+SrdZAab6j84U4+kzbBfvKrEtlWj9jlOpOVDMiSDJGVJZmCvUTRmUOPL8ROVh4EjAc 155ZBVGe1l8mKJnm09qajaNTWpbGSfVuDWx9QwjaajlLyF90V5c87mfItNyt34u2XIXk XYjJFn8B0PhH0/+GOlw5u2gmnJ5rVnA5wPDTX5PmQWACz4xb7ZTKoZjQ2cbu06PsTsxC +mdlgX5lmiK6pMJsTRzMWJUu++y03IwzFhUCplM9WsspH9LA+2tMq3KgCgh/e/KYE92r elBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u14si3130534ejx.342.2020.05.21.02.39.56; Thu, 21 May 2020 02:40:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729002AbgEUJgM (ORCPT + 99 others); Thu, 21 May 2020 05:36:12 -0400 Received: from mx2.suse.de ([195.135.220.15]:36876 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728720AbgEUJgL (ORCPT ); Thu, 21 May 2020 05:36:11 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 08C3FABE4; Thu, 21 May 2020 09:36:12 +0000 (UTC) Date: Thu, 21 May 2020 10:36:06 +0100 From: Mel Gorman To: Baoquan He Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, cai@lca.pw, mhocko@kernel.org, rppt@linux.ibm.com Subject: Re: [PATCH] mm/compaction: Fix the incorrect hole in fast_isolate_freepages() Message-ID: <20200521093606.GA7110@suse.de> References: <20200521014407.29690-1-bhe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20200521014407.29690-1-bhe@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 21, 2020 at 09:44:07AM +0800, Baoquan He wrote: > After investigation, it turns out that this is introduced by commit of > linux-next: commit f6edbdb71877 ("mm: memmap_init: iterate over memblock > regions rather that check each PFN"). > > After investigation, it turns out that this is introduced by commit of > linux-next, the patch subject is: > "mm: memmap_init: iterate over memblock regions rather that check each PFN". > Some repetition here. I assume it's because the commit ID is not stable because it's in linux-next. > Qian added debugging code. The debugging log shows that the fault page is > 0x2a800000. From the system e820 map which is pasted at bottom, the page > is in e820 reserved range: > BIOS-e820: [mem 0x0000000029ffe000-0x000000002a80afff] reserved > And it's in section [0x28000000, 0x2fffffff]. In that secion, there are > several usable ranges and some e820 reserved ranges. > > For this kind of e820 reserved range, it won't be added to memblock allocator. > However, init_unavailable_mem() will initialize to add them into node 0, > zone 0. Why is it appropriate for init_unavailable_mem to add a e820 reserved range to the zone at all? The bug being triggered indicates there is a mismatch between the zone of a struct page and the PFN passed in. > Before that commit, later, memmap_init() will add e820 reserved > ranges into the zone where they are contained, because it can pass > the checking of early_pfn_valid() and early_pfn_in_nid(). In this case, > the e820 reserved range where fault page 0x2a800000 is located is added > into DMA32 zone. After that commit, the e820 reserved rgions are kept > in node 0, zone 0, since we iterate over memblock regions to iniatialize > in memmap_init() instead, their node and zone won't be changed. > This implies that we have struct pages that should never be used (e820 reserved) but exist somehow in a zone range but with broken linkages to their node and zone. > Reported-by: Qian Cai > Signed-off-by: Baoquan He > --- > mm/compaction.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/mm/compaction.c b/mm/compaction.c > index 67fd317f78db..9ce4cff4d407 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -1418,7 +1418,9 @@ fast_isolate_freepages(struct compact_control *cc) > cc->free_pfn = highest; > } else { > if (cc->direct_compaction && pfn_valid(min_pfn)) { > - page = pfn_to_page(min_pfn); > + page = pageblock_pfn_to_page(min_pfn, > + pageblock_end_pfn(min_pfn), > + cc->zone); > cc->free_pfn = min_pfn; > } > } Why is the correct fix not to avoid creating struct pages for e820 ranges and make sure that struct pages that are reachable have proper node and zone linkages? -- Mel Gorman SUSE Labs