From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86596ECE587 for ; Mon, 14 Oct 2019 09:32:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 69F1C21744 for ; Mon, 14 Oct 2019 09:32:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730976AbfJNJcS (ORCPT ); Mon, 14 Oct 2019 05:32:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49560 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730667AbfJNJcR (ORCPT ); Mon, 14 Oct 2019 05:32:17 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 13146A3CD7D; Mon, 14 Oct 2019 09:32:17 +0000 (UTC) Received: from [10.36.116.28] (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9106F600CD; Mon, 14 Oct 2019 09:32:14 +0000 (UTC) Subject: Re: [PATCH v6 04/10] mm/memory_hotplug: Don't access uninitialized memmaps in shrink_zone_span() To: linux-kernel@vger.kernel.org, Andrew Morton Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, x86@kernel.org, Oscar Salvador , Michal Hocko , Pavel Tatashin , Dan Williams , "Aneesh Kumar K . V" References: <20191006085646.5768-1-david@redhat.com> <20191006085646.5768-5-david@redhat.com> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: <5a4573de-bd8a-6cd3-55d0-86d503a236fd@redhat.com> Date: Mon, 14 Oct 2019 11:32:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: <20191006085646.5768-5-david@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Mon, 14 Oct 2019 09:32:17 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06.10.19 10:56, David Hildenbrand wrote: > Let's limit shrinking to !ZONE_DEVICE so we can fix the current code. We > should never try to touch the memmap of offline sections where we could > have uninitialized memmaps and could trigger BUGs when calling > page_to_nid() on poisoned pages. > > There is no reliable way to distinguish an uninitialized memmap from an > initialized memmap that belongs to ZONE_DEVICE, as we don't have > anything like SECTION_IS_ONLINE we can use similar to > pfn_to_online_section() for !ZONE_DEVICE memory. E.g., > set_zone_contiguous() similarly relies on pfn_to_online_section() and > will therefore never set a ZONE_DEVICE zone consecutive. Stopping to > shrink the ZONE_DEVICE therefore results in no observable changes, > besides /proc/zoneinfo indicating different boundaries - something we > can totally live with. > > Before commit d0dc12e86b31 ("mm/memory_hotplug: optimize memory > hotplug"), the memmap was initialized with 0 and the node with the > right value. So the zone might be wrong but not garbage. After that > commit, both the zone and the node will be garbage when touching > uninitialized memmaps. > > Cc: Andrew Morton > Cc: Oscar Salvador > Cc: David Hildenbrand > Cc: Michal Hocko > Cc: Pavel Tatashin > Cc: Dan Williams > Fixes: d0dc12e86b31 ("mm/memory_hotplug: optimize memory hotplug") @Andrew, can you convert that to Fixes: f1dd2cd13c4b ("mm, memory_hotplug: do not associate hotadded memory to zones until online") # visible after d0dc12e86b319 and add Cc: stable@vger.kernel.org # v4.13+ -- Thanks, David / dhildenb