Received: by 10.213.65.68 with SMTP id h4csp1279834imn; Wed, 14 Mar 2018 15:26:43 -0700 (PDT) X-Google-Smtp-Source: AG47ELs+b1ffmMLcF5oupsgQkQFKGYQTNv0cmirbwLOG9eX7vulKxoxaYlXZX3Vr/GXj4NA/uLeT X-Received: by 2002:a17:902:a58c:: with SMTP id az12-v6mr5443056plb.156.1521066403741; Wed, 14 Mar 2018 15:26:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521066403; cv=none; d=google.com; s=arc-20160816; b=GeZm9gvWMgWRJMTlqnrDFEXLSadFYvioNuhob9qJDXMNa6xB2FFAMPReuBHaKiIf1d WE9Wa/7+MUt3BwL5Gyut8wvs+ZB4iqbZhBDqHUPUZyQ5x0ADVFRYbj1DbEjNpvFRFF/9 mZogF3VYx9rsW2MgUcN2cTtoTM6ZYZhUEspLoys3A6qhzmJ1R3GrCKcrMgx8oqNK7EsO V1H4LtIPyiHlits8q3QnQwL3scPolj5IFnI248mOg2f8jDU0aVLmoGp29E9vv2YA9d55 HbF3c7hPPfZMvaNICDdypvRVdC5dMmpWnPpkIN5b6twtQ6uw1XDRG7ulU4Qx73d9p9+4 EdRg== 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:date:from:dkim-signature:arc-authentication-results; bh=9tXf8AGGC5uPoBdu4UIcTrXB956FBTS28l6KLo2XhgM=; b=LwCkUnnZyJBt7UVgZbGu/0yNYE14GkizbJimX6DBTh5B55Fr+VLBl+RyCPD88wsANf rG6y6Prdd8OV4ghizPyBeVi9E75ZGMYRV5XDAmdBLwQjWURsjDTarojTLaCcvoTpzUB4 8y3V5p3vFfCQ5nt4z0jDeOkhUfC/fa3tOWZe0+PCG4SzLyS0uHbi/hKL+Hp1ASgeHYYU meTSZokPK96ukOQzlO3v8V3wzvkwHW37w8OeSgUt+w5Mngm1DNZfS2xQXE3XYF0vnjd0 MBEeKfAEj/9T+MbAnuHcFObWtPYQES4dzYVI+js8wGShVI8hPnvCFsopI3WZxubuHM0x fs1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=FeUVwrEL; 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 a13si2437522pgt.344.2018.03.14.15.26.28; Wed, 14 Mar 2018 15:26:43 -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=fail header.i=@gmail.com header.s=20161025 header.b=FeUVwrEL; 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 S1751571AbeCNWZf (ORCPT + 99 others); Wed, 14 Mar 2018 18:25:35 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:37806 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751314AbeCNWZd (ORCPT ); Wed, 14 Mar 2018 18:25:33 -0400 Received: by mail-wr0-f196.google.com with SMTP id z12so6356429wrg.4 for ; Wed, 14 Mar 2018 15:25:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=9tXf8AGGC5uPoBdu4UIcTrXB956FBTS28l6KLo2XhgM=; b=FeUVwrELXdytrmgdCYpWoJ9/BGNGeU49hLz6SK4GLKVaSaA/ezxx9Kqqrk2uKEJiMR 8s3MeS4G+UKbk9uhPllJfaVv1X4/hpOq5wswr4a7blhYq8X83L10WOyn6xLdOeoA9AaX D3nCG0S1RQpUfyCjZ3ZCFNLDdIHPzJWZdKmlWfqywutEgNoIU3LSW/Yy4sDobiwaRDUS MgRWtRdW4USdw+c8kQYCgdmfWk6ZfElycekNNyeFuiXv4euyEAneILeZ5+FadJh3joCD o/D9PNKbmfynq/GBkGDqi7mW5XP2qr1/PLwKBZYVT82CBRAIpkTAs40GIKEbA80pjJe/ Ce3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=9tXf8AGGC5uPoBdu4UIcTrXB956FBTS28l6KLo2XhgM=; b=S5g9kkTJIgpCpJNGL3heB2Tm9h61z3JZKizQLvpu9j8UAvBUcHFIx4pX3/covGQ4mk /lMvXB5WsSnUXeXSFakOZbNglC5m0Hxg2+mCo9leCxH2mTBo4A5w6sAPF2eE46h/0x2D S5Z9m77+TUOz6wvMgpStKfjsietrsu9raG6jlDauB9W56zgMV0tDwHSQycrjxVLRWObW sR6rk97BBbBvq//q2wxifZn7EDcGDXupTJ/qmU9EpZiodZQPS12W9ykpa5GLWD3Bp+kh YjMlowKSCvJEvOI9h0Tzpphp+4Vb9Hv3AkVpYGsNH+qfjV7gWrjUjkB1Va6lgAOPMo9a C2Uw== X-Gm-Message-State: AElRT7GF5qSZLl3PSkJ3j0Paz7axAg5t0nUKwNnNKqqvCd8tDtz1e0AH yE6dHgqBLJ8I6PWie9mXh5I= X-Received: by 10.223.155.219 with SMTP id e27mr2800094wrc.159.1521066332204; Wed, 14 Mar 2018 15:25:32 -0700 (PDT) Received: from wintermute (HSI-KBW-082-212-013-031.hsi.kabelbw.de. [82.212.13.31]) by smtp.gmail.com with ESMTPSA id 74sm2562617wmf.26.2018.03.14.15.25.31 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 15:25:31 -0700 (PDT) From: Jan Glauber X-Google-Original-From: Jan Glauber Date: Wed, 14 Mar 2018 23:25:30 +0100 To: Ard Biesheuvel Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mark.rutland@arm.com, Michal Hocko , Paul Burton , marc.zyngier@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, Pavel Tatashin , Linus Torvalds , Andrew Morton , Mel Gorman , Daniel Vacek , Vlastimil Babka Subject: Re: [PATCH v2] Revert "mm/page_alloc: fix memmap_init_zone pageblock alignment" Message-ID: <20180314222530.GA6300@wintermute> References: <20180314192937.12888-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180314192937.12888-1-ard.biesheuvel@linaro.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > 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