Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp910059imu; Mon, 5 Nov 2018 10:36:42 -0800 (PST) X-Google-Smtp-Source: AJdET5dZRBkQrX+rR4+alet+oVrOtO63GaiBKvN9wRI3peIylSAmJ3BshwQIuRiW7FwB9lrchsZi X-Received: by 2002:a63:4f5e:: with SMTP id p30mr14193433pgl.71.1541443001920; Mon, 05 Nov 2018 10:36:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541443001; cv=none; d=google.com; s=arc-20160816; b=YycWQyKplZdYUb9yEXNzFUQOlwrqYcmgTAhWouEfqxsLAxG/yqsQTKnfvtr86xU1az jmkJZTOxTJxLNGIAji+mUMrWVBhOtVg/Ju2mdyfTHFplH5CH0MIPPPtGXaWO+UKnizrJ CSuVbS1DAW/ljxGgUN3A9RHuJZDUrw8nk+XLJiNXXgpvCpIIj9YChbqMKk46/+M1gQ7J bLFmZBMdtpJNo58iylxSXuVwEzelUaMrcJadzKTCnW9hrHfUY/lo/ZZIXGlt48t7fjj3 GHg78NM3pR9RfUZwzfP1bR8D7AUgq5OE7cS3+sDcL6LvmGGZGwinRSMT/q4y/ajzWutm a9Ew== 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:from:date; bh=uu93beo+DeGaNqlnXgc1lZ0pN1J2Yq6ibHTH2jNL7Ys=; b=EphsOf7kb95KJOaQwGYDdVuI0+0hZl7jeifCsLUQRjXgYhepZVKEYXKjP6hUTY40uM hWo2eR4vynpZAInWU1i+84vD1yWTyDoMpobRsBHpxuQovaL6BK2JGfM8RZkZjXwX2pmL nY21k7vffucigg2FWLO2l+RCAqyaazFhbrzJOJ9d/vGXQAl1LoKSwIiO1adrOh/FY7r3 7mkM+RPvgtStpf9/tYNW836blm6eVhl80Hw+UTkK+EOk+y8PjCOBo3I75SjEsTXz/UGl UdLEZvmsi6hg0dX7GM/++fvJ9UMDossuEXV10VjT+wX/ekXkFQ59H9bFp0Nq0K50lCXe pILA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7si7157721pgl.303.2018.11.05.10.36.26; Mon, 05 Nov 2018 10:36:41 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387862AbeKFD4f (ORCPT + 99 others); Mon, 5 Nov 2018 22:56:35 -0500 Received: from mx2.suse.de ([195.135.220.15]:46358 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387702AbeKFD4f (ORCPT ); Mon, 5 Nov 2018 22:56:35 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 65E72B0D2; Mon, 5 Nov 2018 18:35:36 +0000 (UTC) Date: Mon, 5 Nov 2018 19:35:33 +0100 From: Michal Hocko To: Mikhail Zaslonko Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Pavel.Tatashin@microsoft.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, gerald.schaefer@de.ibm.com Subject: Re: [PATCH v2 0/1] memory_hotplug: fix the panic when memory end is not Message-ID: <20181105183533.GQ4361@dhcp22.suse.cz> References: <20181105150401.97287-1-zaslonko@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181105150401.97287-1-zaslonko@linux.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 05-11-18 16:04:00, Mikhail Zaslonko wrote: [...] > Another approach was to fix memmap_init() and initialize struct pages > beyond the end. Yes I still do not want to give up at least this option. We do have struct pages for the full section. Leaving som of them uninitialized is just asking for problems. And adding special cases to some hotplug paths just makes the code harder to follow and maintain. So > Since struct pages are allocated section-wise we can try to > round the size parameter passed to the memmap_init() function up to the > section boundary thus forcing the mapping initialization for the entire > section. But then it leads to another VM_BUG_ON panic due to > zone_spans_pfn() sanity check triggered for the first page of each page > block from set_pageblock_migratetype() function: > page dumped because: VM_BUG_ON_PAGE(!zone_spans_pfn(page_zone(page), pfn)) > Call Trace: > ([<00000000003013f8>] set_pfnblock_flags_mask+0xe8/0x140) > [<00000000003014aa>] set_pageblock_migratetype+0x5a/0x70 > [<0000000000bef706>] memmap_init_zone+0x25e/0x2e0 > [<00000000010fc3d8>] free_area_init_node+0x530/0x558 > [<00000000010fcf02>] free_area_init_nodes+0x81a/0x8f0 > [<00000000010e7fdc>] paging_init+0x124/0x130 > [<00000000010e4dfa>] setup_arch+0xbf2/0xcc8 > [<00000000010de9e6>] start_kernel+0x7e/0x588 > [<000000000010007c>] startup_continue+0x7c/0x300 > Last Breaking-Event-Address: > [<00000000003013f8>] set_pfnblock_flags_mask+0xe8/0x1401 > We might ignore this check for the struct pages beyond the "end" but I'm not > sure about further implications. find out all these implictions or do something like below (untested) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a919ba5cb3c8..a3f9ad8e40ee 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5544,6 +5544,21 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, cond_resched(); } } + +#ifdef CONFIG_SPARSEMEM + /* + * If we do not have a zone which doesn't span the rest of the + * section then we should at least initialize those pages. We + * could blow up on a poisoned page in some paths which depend + * on full pageblocks being allocated (e.g. memory hotplug). + */ + while (end_pfn % PAGES_PER_SECTION) { + __init_single_page(pfn_to_page(end_pfn), end_pfn, zone, nid); + end_pfn++ + } + +#endif + } #ifdef CONFIG_ZONE_DEVICE -- Michal Hocko SUSE Labs