Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp505009imm; Wed, 6 Jun 2018 01:05:09 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJJoBzNJTbLCkackFxTMLLICNWOhNUhe+vjqXPOzXihqMX38dsztqz8S1DvngA9aDeS+NB3 X-Received: by 2002:a65:49cb:: with SMTP id t11-v6mr1722791pgs.218.1528272309810; Wed, 06 Jun 2018 01:05:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528272309; cv=none; d=google.com; s=arc-20160816; b=OBzl7PbIE/DOmVFrdp7UBzRY6Sz6zMleRwdfSMXDsieYRPQcxyVV96nTwOEYc1c6f1 VAHN1aCdVLPadp4En8zDWK/zVh/xZnBLZUmohpk7YUQFqqX+/niUfYkX5Sgd9t2dSDyQ lFa7h/9JrJ7UVgcskRZisk6PKg6sIUvB4pqANkfMRLhGC33h/Zgzik+6KlJks/PpPOSo V8Nz0BplZkkzgm5usEANMe7JkCrbpwGlHuf15GZz++Kpc+PzKxf+YU20tsHAEUBqDgOA 6emZneO98xjmKdyS98/A7mOJV4QRgJX9MbEJX/+KiKASZJ3mNYp0seG2ISalw86Vn0AW uJ3g== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=d4mJPCqZm4P9wzDuoWWwASC0GgsNC3nZd2Z9CTHNfjg=; b=Q7XkgA2TLgI3rovR27wBX5dyDuDh82/snKcnPKyL1uMcQuoOlWuMVanejujfLpWOf/ 6Tc3R67A+N4YO40Btu0od9ON3oPZsccVe/Q9QYQkqF27A7SlnS7kJxN5+9lw3gJfQ/WF EMlo3Z24at14jyQ5JVu3ghT9l/PT+vlsHQ7NlXCPpuPOlKdrKokoW08ZL+gH0y85Aj8V qFaTod1FwvSTFYaqDoeaLVDk9SMoJSkWI9qvn4XUrrpTj6hAPROS8hn+ctyjq0PduBke U/2vcbT0c3NFs6uYXAL4Mm60JP4PpiviYeLlh/xir5uTjq3l93showQo0hlbF7u/4CxE Y8RA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i133-v6si22864075pgc.351.2018.06.06.01.04.55; Wed, 06 Jun 2018 01:05:09 -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; 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 S932474AbeFFIEP (ORCPT + 99 others); Wed, 6 Jun 2018 04:04:15 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34400 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932290AbeFFIEL (ORCPT ); Wed, 6 Jun 2018 04:04:11 -0400 Received: by mail-wm0-f65.google.com with SMTP id q4-v6so21925029wmq.1 for ; Wed, 06 Jun 2018 01:04:10 -0700 (PDT) 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:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=d4mJPCqZm4P9wzDuoWWwASC0GgsNC3nZd2Z9CTHNfjg=; b=De+FX34I6z/EOVgJrShZCc3JbwXfaCNOzqWLQPPPFumv4l75rNq9vKRZtVJyzQIE6r kHW+Hh3vnL6xLalIjzvdl/XD6CqsBbs2uPKS0Yrm7Ag7AZxfbX9ml59uQ7onWRujHZ6A qXL45eWdgtDggdIFEqJQOeJ0CGUlVR/zIrX3yh/OaIRKTHpdiAsM59ZIwsqipfSYQ866 d75T0JJDKoXTwLpDP665FC63takaOvGR1WIGGrHN62e0jmEKqKwZkhiIxCbQa5vDKbsk AZHWUAW52niQpRE+LInWcUh2u1Nj5phgjYP7Vs2BtgKW1dcTiHdW3qppTlsu2ebD3RA0 TCXQ== X-Gm-Message-State: APt69E0z4rVXaTY275ppRUTv54EImZIyUTdj+SwLtGBLI/5vWSj4MggC s8lHEvMImWQd4hipO3z4HtE= X-Received: by 2002:a1c:b7d4:: with SMTP id h203-v6mr938543wmf.161.1528272250318; Wed, 06 Jun 2018 01:04:10 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id o16-v6sm16331002wrp.8.2018.06.06.01.04.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jun 2018 01:04:09 -0700 (PDT) Received: by techadventures.net (Postfix, from userid 1000) id 4BFE212322A; Wed, 6 Jun 2018 10:04:08 +0200 (CEST) Date: Wed, 6 Jun 2018 10:04:08 +0200 From: Oscar Salvador To: Naoya Horiguchi Cc: Matthew Wilcox , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Andrew Morton , Michal Hocko , "mingo@kernel.org" , "dan.j.williams@intel.com" , Huang Ying , Pavel Tatashin Subject: Re: kernel panic in reading /proc/kpageflags when enabling RAM-simulated PMEM Message-ID: <20180606080408.GA31794@techadventures.net> References: <20180605005402.GA22975@hori1.linux.bs1.fc.nec.co.jp> <20180605011836.GA32444@bombadil.infradead.org> <20180605073500.GA23766@hori1.linux.bs1.fc.nec.co.jp> <20180606051624.GA16021@hori1.linux.bs1.fc.nec.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180606051624.GA16021@hori1.linux.bs1.fc.nec.co.jp> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 06, 2018 at 05:16:24AM +0000, Naoya Horiguchi wrote: > On Tue, Jun 05, 2018 at 07:35:01AM +0000, Horiguchi Naoya(堀口 直也) wrote: > > On Mon, Jun 04, 2018 at 06:18:36PM -0700, Matthew Wilcox wrote: > > > On Tue, Jun 05, 2018 at 12:54:03AM +0000, Naoya Horiguchi wrote: > > > > Reproduction precedure is like this: > > > > - enable RAM based PMEM (with a kernel boot parameter like memmap=1G!4G) > > > > - read /proc/kpageflags (or call tools/vm/page-types with no arguments) > > > > (- my kernel config is attached) > > > > > > > > I spent a few days on this, but didn't reach any solutions. > > > > So let me report this with some details below ... > > > > > > > > In the critial page request, stable_page_flags() is called with an argument > > > > page whose ->compound_head was somehow filled with '0xffffffffffffffff'. > > > > And compound_head() returns (struct page *)(head - 1), which explains the > > > > address 0xfffffffffffffffe in the above message. > > > > > > Hm. compound_head shares with: > > > > > > struct list_head lru; > > > struct list_head slab_list; /* uses lru */ > > > struct { /* Partial pages */ > > > struct page *next; > > > unsigned long _compound_pad_1; /* compound_head */ > > > unsigned long _pt_pad_1; /* compound_head */ > > > struct dev_pagemap *pgmap; > > > struct rcu_head rcu_head; > > > > > > None of them should be -1. > > > > > > > It seems that this kernel panic happens when reading kpageflags of pfn range > > > > [0xbffd7, 0xc0000), which coresponds to a 'reserved' range. > > > > > > > > [ 0.000000] user-defined physical RAM map: > > > > [ 0.000000] user: [mem 0x0000000000000000-0x000000000009fbff] usable > > > > [ 0.000000] user: [mem 0x000000000009fc00-0x000000000009ffff] reserved > > > > [ 0.000000] user: [mem 0x00000000000f0000-0x00000000000fffff] reserved > > > > [ 0.000000] user: [mem 0x0000000000100000-0x00000000bffd6fff] usable > > > > [ 0.000000] user: [mem 0x00000000bffd7000-0x00000000bfffffff] reserved > > > > [ 0.000000] user: [mem 0x00000000feffc000-0x00000000feffffff] reserved > > > > [ 0.000000] user: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved > > > > [ 0.000000] user: [mem 0x0000000100000000-0x000000013fffffff] persistent (type 12) > > > > > > > > So I guess 'memmap=' parameter might badly affect the memory initialization process. > > > > > > > > This problem doesn't reproduce on v4.17, so some pre-released patch introduces it. > > > > I hope this info helps you find the solution/workaround. > > > > > > Can you try bisecting this? It could be one of my patches to reorder struct > > > page, or it could be one of Pavel's deferred page initialisation patches. > > > Or something else ;-) > > > > Thank you for the comment. I'm trying bisecting now, let you know the result later. > > > > And I found that my statement "not reproduce on v4.17" was wrong (I used > > different kvm guests, which made some different test condition and misguided me), > > this seems an older (at least < 4.15) bug. > > (Cc: Pavel) > > Bisection showed that the following commit introduced this issue: > > commit f7f99100d8d95dbcf09e0216a143211e79418b9f > Author: Pavel Tatashin > Date: Wed Nov 15 17:36:44 2017 -0800 > > mm: stop zeroing memory during allocation in vmemmap > > This patch postpones struct page zeroing to later stage of memory initialization. > My kernel config disabled CONFIG_DEFERRED_STRUCT_PAGE_INIT so two callsites of > __init_single_page() were never reached. So in such case, struct pages populated > by vmemmap_pte_populate() could be left uninitialized? > And I'm not sure yet how this issue becomes visible with memmap= setting. I think that this becomes visible because memmap=x!y creates a persistent memory region: parse_memmap_one { ... } else if (*p == '!') { start_at = memparse(p+1, &p); e820__range_add(start_at, mem_size, E820_TYPE_PRAM); ... } and this region it is not added neither in memblock.memory nor in memblock.reserved. Ranges in memblock.memory get zeroed in memmap_init_zone(), while memblock.reserved get zeroed in free_low_memory_core_early(): static unsigned long __init free_low_memory_core_early(void) { ... for_each_reserved_mem_region(i, &start, &end) reserve_bootmem_region(start, end); ... } Maybe I am mistaken, but I think that persistent memory regions should be marked as reserved. A comment in do_mark_busy() suggests this: static bool __init do_mark_busy(enum e820_type type, struct resource *res) { ... /* * Treat persistent memory like device memory, i.e. reserve it * for exclusive use of a driver */ ... } I wonder if something like this could work and if so, if it is right (i haven't tested it yet): diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 71c11ad5643e..3c9686ef74e5 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -1247,6 +1247,11 @@ void __init e820__memblock_setup(void) if (end != (resource_size_t)end) continue; + if (entry->type == E820_TYPE_PRAM || entry->type == E820_TYPE_PMEM) { + memblock_reserve(entry->addr, entry->size); + continue; + } + if (entry->type != E820_TYPE_RAM && entry->type != E820_TYPE_RESERVED_KERN) continue; Best Regards Oscar Salvador