Received: by 10.213.65.68 with SMTP id h4csp1291804imn; Wed, 14 Mar 2018 15:54:37 -0700 (PDT) X-Google-Smtp-Source: AG47ELuJBDFdfzHShVN+JDe7Bxh+KQs65BOvTqzGXjlRY6sZOC1CYURcmdMBWDi8wvTtNo+gTSpt X-Received: by 10.99.122.28 with SMTP id v28mr5148214pgc.128.1521068077430; Wed, 14 Mar 2018 15:54:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521068077; cv=none; d=google.com; s=arc-20160816; b=xlMvGyWLMdq+59k7CxFnnOEdNVc34RanGmNpI5ey9xA4kMyJU3o3pZnvXM4Sc/mu8m WQ/zZFCg4lsqltFM5D69lxLzEutNn49e4PPZW6j7vlbdDTe35LkTS5dxm/R9ZcRCR3eQ mj66GbtGEqFtb9NT0Ro0X6pImtqv2qYg+NmjNJt/2w49D701SW3p+puehFrtJSXcExOP 7YzrLVToJ7RTE6YSARr/RGQ9/H5v9ZAV34QhfS/FGdw7iISnwbyUMCnDQASCxyQ46LOD AqbhEmojgz73Z6EEiH+WTpQ1zyCu2hPZn8+nZ5LF98PuBX4TMv4zXFnjWAXOSlbSDRfK fYhA== 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:from:references:cc:to:subject:reply-to:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=QI4OjNH2XftBMmAB/pRqV5Rt7eSq073+usT9Oeet9/w=; b=Y8Ur/iklzBtYZ/Z9Yl/PukAJa4DlcAVWsM2O+cifh3DMlKgaPY6w1CBuTFIet0xZf7 QkUDhvzvoZfFKJ/di0MFXYzHEjqsCoQsnWbMY86pdKx7WbpEPaFFiWKJUNkJLVY6VlXu Xaq8lr/CiL7fFX2LV/Ru1KidU2ZMesiVfrVd5GgN/DVOG/fwEhyNIIelJcmc0cwmgOfu L9qd85s02XMGhgcarjbgmFf0yWHXEP5/as+OqNaRN7IeRjulVdqFgoKbti0reIDXxugk WMZPF2y/pFWNZl4r1fdEiMlHlM+KmozNwXRTUKWCecZcuxlm1NeerjaS6UuPU06mXG2x W5UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=mbI0jOsg; dkim=pass header.i=@codeaurora.org header.s=default header.b=QJKyDNSs; 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 x7si2564272pgo.122.2018.03.14.15.54.23; Wed, 14 Mar 2018 15:54:37 -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=@codeaurora.org header.s=default header.b=mbI0jOsg; dkim=pass header.i=@codeaurora.org header.s=default header.b=QJKyDNSs; 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 S1751526AbeCNWx3 (ORCPT + 99 others); Wed, 14 Mar 2018 18:53:29 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:33740 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750779AbeCNWx2 (ORCPT ); Wed, 14 Mar 2018 18:53:28 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 041B86081A; Wed, 14 Mar 2018 22:53:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521068008; bh=QcyStOqbNauPBr1watfBpEZDJNHQ5tD+QW9TA3j0Ups=; h=Reply-To:Subject:To:Cc:References:From:Date:In-Reply-To:From; b=mbI0jOsgWx/vtsQA822XgCmRGr4K7+IIiWPDpIpY6gjGrmzGrWD2v9l5TO+WUPewV Prkx6Z6eEeiySbyAtcGbcYG9+LuMP8wwCEC37mgzAsth6mp/o3UKW+goY7K9IqwQpH +E7692ToOGhdsLdCsozG4YwJbuzdWjChkyWIyfWo= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [10.0.2.15] (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: shankerd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2330E603AF; Wed, 14 Mar 2018 22:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521067986; bh=QcyStOqbNauPBr1watfBpEZDJNHQ5tD+QW9TA3j0Ups=; h=Reply-To:Subject:To:Cc:References:From:Date:In-Reply-To:From; b=QJKyDNSsRSowG3TIxCj7BpS5voWB4foI/7+NuA7ahmjavY5E7bwaYqIpsA8RzXlwm W0lxrAewak+Z05z10OiSi9rxyfAvKYKeWl7v44iNntwxFCkQmJWQ3T0sFH8xjoq8X+ p9c480g8qouffXiBHjoqHTRNgOreVphFa32RXJ9g= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2330E603AF Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=shankerd@codeaurora.org Reply-To: shankerd@codeaurora.org Subject: Re: [PATCH v2] Revert "mm/page_alloc: fix memmap_init_zone pageblock alignment" To: Jan Glauber , Ard Biesheuvel Cc: mark.rutland@arm.com, Michal Hocko , Mel Gorman , Paul Burton , marc.zyngier@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, Pavel Tatashin , Vlastimil Babka , Andrew Morton , Linus Torvalds , Daniel Vacek , linux-arm-kernel@lists.infradead.org References: <20180314192937.12888-1-ard.biesheuvel@linaro.org> <20180314222530.GA6300@wintermute> From: Shanker Donthineni Message-ID: <4c31c5ed-9f68-10c3-c73f-5b6f34dd82c9@codeaurora.org> Date: Wed, 14 Mar 2018 17:53:03 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20180314222530.GA6300@wintermute> 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 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. >> 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 > -- Shanker Donthineni Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.