Received: by 10.213.65.68 with SMTP id h4csp855454imn; Sun, 18 Mar 2018 05:05:49 -0700 (PDT) X-Google-Smtp-Source: AG47ELtkSAk2fdqRpV6VmsQyFQ9m9TPT4/43EP+06ipJqeySCuheaiJPr7vas6LR9XgJ0JmAG81j X-Received: by 2002:a17:902:b43:: with SMTP id 61-v6mr8692941plq.270.1521374749341; Sun, 18 Mar 2018 05:05:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521374749; cv=none; d=google.com; s=arc-20160816; b=wWHfoRpvxXofqS2Fg22XOYt5ON4msnisKTDAwm52iRJtBeAunVzhYz+Nk9xM2ezeRz w3Hjc1vQc2qIxUcT6YhhdRsxa9hwfiMzrSSwET8UjkV9GqekvumpMfw5w8mgRZ0FcMC7 TO+4k0vYhI7rtDsou7IO2mHPYhv5oVQgLoCw7iauUaKoOeH8y+aJyRzxdecxJ31P22og raz7y8J0TqaF/5y+kOtzmH9IbYGoN8VhjuxnlUrEHzEGF/MYrQloLv9kryPPgnPmph7I nxT2mzfb+SB2LV69bI+5ZULz3NNXv/Yfzfq3MiSsMiShKY4fhX/qdB9uvHaspintGeve ygTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature:arc-authentication-results; bh=1xRnERKFPg9UvVjYay2z4vSIzZbYG8C9F6hKumP0CXQ=; b=ErP0/RCvTKYPM6fLupVGN76B807vxrQELvUPy0OCL8jezaK2hIlwb2WJEdGuuEGkOI 7vlZb73s7P4RTlYVA3+AE2c7+eJQO8Q0q2JBNN9cN9Lz/XIgU4uXbewrsafknfdf+qXL 6Ao3W1CYjB+/4Mi1mWMS2R/Cu2Pob+JMR8km0bmr73rHgWzaOmTwJqkEtnp0kYJSFgOJ /NrHQh97knWo42milh14JeiUmyD0n238uBiOn0LfQPqsLHRHPKwemJpMc32YJoyrGLJE YshajO2SV5QbtfvDRHtDaqJp60NvIsPpqHXbKWwTFE1yHIVfq7wk1DD6mSZhqgs6i1h5 Yukg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=IO/P3hkx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u13si265753pgp.94.2018.03.18.05.05.34; Sun, 18 Mar 2018 05:05:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=IO/P3hkx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752052AbeCRMCr (ORCPT + 99 others); Sun, 18 Mar 2018 08:02:47 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:39093 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750766AbeCRMCp (ORCPT ); Sun, 18 Mar 2018 08:02:45 -0400 Received: by mail-wr0-f194.google.com with SMTP id c24so4013700wrc.6 for ; Sun, 18 Mar 2018 05:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:organization:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=1xRnERKFPg9UvVjYay2z4vSIzZbYG8C9F6hKumP0CXQ=; b=IO/P3hkxICwQIJsvF0NNIcooDOXRdKNRu5dEcNe7GIbIzt0weGnTCBBrnnMslFB/xx 08LMkmIZ0PDfxa6B5NYciTbAEYXdDebdANKqSz5WWXQgjzOaILxZgivoLOppjnRcGaMO fCJNOL60s8yyg0xK04iuspxwIwlB3apZP9sN0yYOCJG6y0sBR2WRRFB1eCtHe3PohrBc G9tkyvJAITopNiYkL9ifKzqn+dhQUgH+JHyXBtriZIjdWEvHcrSxDs6TfOf6jErtoQ78 HlYm9S+7EQ9uexa2GwzL1J4HCZKUmYuvUkfgPlkeJCyDQee7QPIQsbhLFutxFkTLRh5k BQMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=1xRnERKFPg9UvVjYay2z4vSIzZbYG8C9F6hKumP0CXQ=; b=qDZzQulzDxd/Jk8SoxVA1So4x3u19N/IHAuHUlTYBVmUF2sefZXieSWOQ2t3SUHA8Y vN25IQdbPtfqW8qBRuIC1QqHhdo9w9LSPvlyzDmSJjEH1lgbB/oKBQCPv31LHsNJ4EeS EiK5f4LJWXcKyNU2Lumu18CejXtENpQGjR2K2EYeoLj7D0EhFH4OY+kZgc8nx2mibtIt KPQs2bE1hui3+FBu32nJDZ3FrL0hGx0Jzt3q4YO5CgqBu3FDGLb9WiIJwbPwMnmkWWzm SH5ixIodiLrusLD/+Lb1SMBf0B7tgmZQfWJoFr2ohcVpNKdVE/po3lVyTFbZig4IUzf5 BVrQ== X-Gm-Message-State: AElRT7FJtmZSH3a3ytehxPMXzacGjLr0cWLcxhoHbEnFzJmDTv9GcrUn Hb/ImuSwWe5KseYF8eFM10Rx0Q== X-Received: by 10.223.179.9 with SMTP id j9mr3643768wrd.276.1521374564282; Sun, 18 Mar 2018 05:02:44 -0700 (PDT) Received: from ?IPv6:2a01:cb1d:4ce:ea00:b8f8:49eb:fd78:a0b9? ([2a01:cb1d:4ce:ea00:b8f8:49eb:fd78:a0b9]) by smtp.gmail.com with ESMTPSA id q81sm2814312wmg.8.2018.03.18.05.02.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Mar 2018 05:02:43 -0700 (PDT) Subject: Re: [PATCH v2] Revert "mm/page_alloc: fix memmap_init_zone pageblock alignment" To: shankerd@codeaurora.org, Jan Glauber , Ard Biesheuvel Cc: mark.rutland@arm.com, Michal Hocko , Paul Burton , marc.zyngier@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, Pavel Tatashin , Linus Torvalds , linux-arm-kernel@lists.infradead.org, Andrew Morton , Mel Gorman , Daniel Vacek , Vlastimil Babka References: <20180314192937.12888-1-ard.biesheuvel@linaro.org> <20180314222530.GA6300@wintermute> <4c31c5ed-9f68-10c3-c73f-5b6f34dd82c9@codeaurora.org> From: Neil Armstrong Organization: Baylibre Message-ID: <72c94b30-f837-91ac-ac3a-86d7846dfb23@baylibre.com> Date: Sun, 18 Mar 2018 13:02:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <4c31c5ed-9f68-10c3-c73f-5b6f34dd82c9@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/03/2018 23:53, Shanker Donthineni wrote: > > Hi Ard, > > On 03/14/2018 05:25 PM, Jan Glauber wrote: >> On Wed, Mar 14, 2018 at 07:29:37PM +0000, Ard Biesheuvel wrote: >>> This reverts commit 864b75f9d6b0100bb24fdd9a20d156e7cda9b5ae. >> >> FWIW, the revert fixes the boot hang I'm seeing on ThunderX1. >> >> --Jan >> > > Thanks for this patch, it fixes the boot hang on QDF2400 platform. For the record, this also fixes boot on Amlogic S905X (and for the whole GX family I presume). Thanks, Neil > > >>> Commit 864b75f9d6b0 ("mm/page_alloc: fix memmap_init_zone pageblock >>> alignment") modified the logic in memmap_init_zone() to initialize >>> struct pages associated with invalid PFNs, to appease a VM_BUG_ON() >>> in move_freepages(), which is redundant by its own admission, and >>> dereferences struct page fields to obtain the zone without checking >>> whether the struct pages in question are valid to begin with. >>> >>> Commit 864b75f9d6b0 only makes it worse, since the rounding it does >>> may cause pfn assume the same value it had in a prior iteration of >>> the loop, resulting in an infinite loop and a hang very early in the >>> boot. Also, since it doesn't perform the same rounding on start_pfn >>> itself but only on intermediate values following an invalid PFN, we >>> may still hit the same VM_BUG_ON() as before. >>> >>> So instead, let's fix this at the core, and ensure that the BUG >>> check doesn't dereference struct page fields of invalid pages. >>> >>> Fixes: 864b75f9d6b0 ("mm/page_alloc: fix memmap_init_zone pageblock alignment") >>> Cc: Daniel Vacek >>> Cc: Mel Gorman >>> Cc: Michal Hocko >>> Cc: Paul Burton >>> Cc: Pavel Tatashin >>> Cc: Vlastimil Babka >>> Cc: Andrew Morton >>> Cc: Linus Torvalds >>> Signed-off-by: Ard Biesheuvel >>> --- >>> mm/page_alloc.c | 13 +++++-------- >>> 1 file changed, 5 insertions(+), 8 deletions(-) >>> >>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c >>> index 3d974cb2a1a1..635d7dd29d7f 100644 >>> --- a/mm/page_alloc.c >>> +++ b/mm/page_alloc.c >>> @@ -1910,7 +1910,9 @@ static int move_freepages(struct zone *zone, >>> * Remove at a later date when no bug reports exist related to >>> * grouping pages by mobility >>> */ >>> - VM_BUG_ON(page_zone(start_page) != page_zone(end_page)); >>> + VM_BUG_ON(pfn_valid(page_to_pfn(start_page)) && >>> + pfn_valid(page_to_pfn(end_page)) && >>> + page_zone(start_page) != page_zone(end_page)); >>> #endif >>> >>> if (num_movable) >>> @@ -5359,14 +5361,9 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, >>> /* >>> * Skip to the pfn preceding the next valid one (or >>> * end_pfn), such that we hit a valid pfn (or end_pfn) >>> - * on our next iteration of the loop. Note that it needs >>> - * to be pageblock aligned even when the region itself >>> - * is not. move_freepages_block() can shift ahead of >>> - * the valid region but still depends on correct page >>> - * metadata. >>> + * on our next iteration of the loop. >>> */ >>> - pfn = (memblock_next_valid_pfn(pfn, end_pfn) & >>> - ~(pageblock_nr_pages-1)) - 1; >>> + pfn = memblock_next_valid_pfn(pfn, end_pfn) - 1; >>> #endif >>> continue; >>> } >>> -- >>> 2.15.1 >>> >>> >>> _______________________________________________ >>> linux-arm-kernel mailing list >>> linux-arm-kernel@lists.infradead.org >>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel >> >> _______________________________________________ >> linux-arm-kernel mailing list >> linux-arm-kernel@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel >> >