Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp90353ybl; Tue, 13 Aug 2019 16:32:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqsaU9nH+XNly9NMrjcPIpvpE7yXeYAFG/9IhEYc6nkgv5tQL5IHiq1yLZZqzI8VscSbE1 X-Received: by 2002:a63:f13:: with SMTP id e19mr36577039pgl.132.1565739154724; Tue, 13 Aug 2019 16:32:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565739154; cv=none; d=google.com; s=arc-20160816; b=RG0NiGYh16wWkjnj8VtiZRRjcmVTao/uTP8AC0cY5CA0g87Qe+59KNyeE/UN9m5VT9 lLMAUJnEddPGhKmlqsN4x4fp/4vrjkaTVehQm024/Aq5gDnanEIJSqkYI3fid7a/m60v lnnSGSeFNmeqSwC00rgfWelT6pk8OzewQhjR3id7lVaYkU/bWcids+YjxtYfithzD4nE /La8LQVi5acpiXf4liqxS793YygbLwfD9NIRW9QsM1+8vKCTJK0lQoXeROT48aGOJ772 OkBU9qMcI+lWWzwjWrj925D6zjFqt/v1ap9MBBtU7w7EF2ZzUqWIp/Km7JMw9jH9Ikfy DLAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=D76e59tgTT4fezI865GZqOOIIhHiE8Pz1mvIdiTRYog=; b=Mw97PBYidEFqhD9W+/KIIieRjlqqwILhogSymhPY16RYI7U3uKU+V0jOvExyE0o64D In2zCb6aBUqQ0RcipHvNCBoLln0UxbMNY76ikIhZ7dkCRAe86TGHRfqMJzDDqbNbeBUg vFpZKxmJqgTsbUXcmBC7KL4e9WjA2/8D1i39KVxP/rTGA3uye8KY3BgchQJJlDXgaWPq 3oPfuTh7VnY8Ei6uIemfv12SjbC4bU2aVR3yFERbqFSxVSTQYwMbc7gsiitPMiwuxf0J MoO/Zm9Tz9bGKXMF4sBhD9NXSQRINYVttfLQa1KDSKkjbNYk9OgtgofQicCjUvcVs+Hm lfxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=QlqMQuV+; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e14si58745145pgg.442.2019.08.13.16.32.17; Tue, 13 Aug 2019 16:32:34 -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=@google.com header.s=20161025 header.b=QlqMQuV+; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726512AbfHMXbi (ORCPT + 99 others); Tue, 13 Aug 2019 19:31:38 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36783 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726116AbfHMXbi (ORCPT ); Tue, 13 Aug 2019 19:31:38 -0400 Received: by mail-pl1-f195.google.com with SMTP id g4so3427529plo.3 for ; Tue, 13 Aug 2019 16:31:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=D76e59tgTT4fezI865GZqOOIIhHiE8Pz1mvIdiTRYog=; b=QlqMQuV+hLDHY43nxqRuLY882x3N3q7FhzRdnEtDOkbYGGrf8gIuaIMb9Dy/XVkrSC QKfMtfAs3gYKOFmSMG4UESwnRiRKC1D8JpHMPFtxjjx3ke8KjRQnOEWCNs3yAwFUM+gN S4OEUPPh1H+2HFvBBiTIctOOU69HwlxYQ2LaE3axijBsYzFAgcufRlU5lYnWzXK/7k8v 3mDs7onMy+HIZSEGXATbroj9J2Tq3JY4jRKQW+XEsGaZjJ5se4c+81n++TQQaQumrpHT qXOQHKEu28o8IpP8J3WuEco5Ba7RZIA31/U7FUzgNubTGu7xmsk3ZJs839mLPOXwxQBx 6UBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=D76e59tgTT4fezI865GZqOOIIhHiE8Pz1mvIdiTRYog=; b=bwh2PIlXtCvFQrm6kQRcDB3ory/olGi9MGka26jtsekDipwJqAxWc2PAkiXf/Fz0KK /yQnFeG7bfehBY6eFcaahPnM3IJfLgZaLyfy+eBR3WuBd2zgR8GWIkeyBFpHH89Xj0pM 6U+Np74OcR+hOOV4nTUAov491d3XBh1FaSvjaFW1EcTb1nEn7CaKJSZv2qUB9/y2IejY 9t65QzUcPd7w7mKsn/WS5NG9TTBRdx0BvMNhw/5bOr26kUVt8DosAeoAKzu5wndy8Cej K9R9+VTSYKz2q0tBEUMxQWi5u+0/1XnycVyjRcbITIYK2GtZwgU947XSYFtp5szeVRoU wJCg== X-Gm-Message-State: APjAAAWySeWxJBY9C9FLzVlUvjNQtpxdOYNqvnC4X0t1fJXQDHz3oY34 QpUAizp+Tcr4XEIyjqnpCp5sQBmpHVA= X-Received: by 2002:a17:902:2f43:: with SMTP id s61mr5825768plb.238.1565739096913; Tue, 13 Aug 2019 16:31:36 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id u7sm109745096pfm.96.2019.08.13.16.31.35 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 13 Aug 2019 16:31:36 -0700 (PDT) Date: Tue, 13 Aug 2019 16:31:35 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Andrew Morton cc: Vlastimil Babka , Naoya Horiguchi , Mel Gorman , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [patch] mm, page_alloc: move_freepages should not examine struct page of reserved memory In-Reply-To: <20190813141630.bd8cee48e6a83ca77eead6ad@linux-foundation.org> Message-ID: References: <20190813141630.bd8cee48e6a83ca77eead6ad@linux-foundation.org> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 13 Aug 2019, Andrew Morton wrote: > > After commit 907ec5fca3dc ("mm: zero remaining unavailable struct pages"), > > struct page of reserved memory is zeroed. This causes page->flags to be 0 > > and fixes issues related to reading /proc/kpageflags, for example, of > > reserved memory. > > > > The VM_BUG_ON() in move_freepages_block(), however, assumes that > > page_zone() is meaningful even for reserved memory. That assumption is no > > longer true after the aforementioned commit. > > > > There's no reason why move_freepages_block() should be testing the > > legitimacy of page_zone() for reserved memory; its scope is limited only > > to pages on the zone's freelist. > > > > Note that pfn_valid() can be true for reserved memory: there is a backing > > struct page. The check for page_to_nid(page) is also buggy but reserved > > memory normally only appears on node 0 so the zeroing doesn't affect this. > > > > Move the debug checks to after verifying PageBuddy is true. This isolates > > the scope of the checks to only be for buddy pages which are on the zone's > > freelist which move_freepages_block() is operating on. In this case, an > > incorrect node or zone is a bug worthy of being warned about (and the > > examination of struct page is acceptable bcause this memory is not > > reserved). > > I'm thinking Fixes:907ec5fca3dc and Cc:stable? But 907ec5fca3dc is > almost a year old, so you were doing something special to trigger this? > We noticed it almost immediately after bringing 907ec5fca3dc in on CONFIG_DEBUG_VM builds. It depends on finding specific free pages in the per-zone free area where the math in move_freepages() will bring the start or end pfn into reserved memory and wanting to claim that entire pageblock as a new migratetype. So the path will be rare, require CONFIG_DEBUG_VM, and require fallback to a different migratetype. Some struct pages were already zeroed from reserve pages before 907ec5fca3c so it theoretically could trigger before this commit. I think it's rare enough under a config option that most people don't run that others may not have noticed. I wouldn't argue against a stable tag and the backport should be easy enough, but probably wouldn't single out a commit that this is fixing.