Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5202348ybl; Tue, 10 Dec 2019 02:12:10 -0800 (PST) X-Google-Smtp-Source: APXvYqw8cfHJ8ouP9yoR3L6arnYJ1n/q5ABEBv0Vf4rL8CIuXP3RGeadJ/1hgNsaJ0MpGnDv0TqU X-Received: by 2002:a05:6830:605:: with SMTP id w5mr23934283oti.298.1575972730097; Tue, 10 Dec 2019 02:12:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575972730; cv=none; d=google.com; s=arc-20160816; b=MaCe5UTGkHwKG6FXn04rQ4zZWOPj8MYELROpKiJnp7wDWjKmZ+eKmXZAcqShPCRF9v 9k6VJPQAYocfcd4ejEH2IfyDSQdA4fbFrt2hZTF1Puham6aaLCWcYuG9fVohO7slAXsN VHIGoQ7M1JUddmRAsMqKLeTUUQDQIvmBmSxt3sHo5iquQLPsu5LxLESXhPIGQKj8xgxL uvL6zIwpfTMY+Zsm4kAbeC17t5xQtmOTMK4UjisV25C3Cyx9DdIEfPrAKk1VInwfXpp2 iDN10tt6knLBXvC98neww01N3TXVJRxxO57XgpmdSr1urli69kw69N8fMsFY0pv1Cc1F ZB0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:autocrypt:from:references:cc:to:subject :dkim-signature; bh=/fNSAK93ztMW9L1B/NS00CbJs6KXG9nyQ8geCOXUcHA=; b=amVeiKj6ZhC+6OfoM+CBALDfDCwxNy64LCIo1IWIOe6JhkaAzK5VssYxwCCFOHkp4u oBMcsq4O7dAuG+LUFzb4n7oJ5KE1mzLm5yaB97XHE5snL08i/sRbeRlYIgQrpOr0+5Ww +R/0um1OaMO7LutUQIeFihnijIb854sVM9PlUrmTKQ+/xZzdxyiBLiAsWS6DW3PU6zgP wu3xmHX1aQ1Vo6+jK4LeyC1+H0h3tqwNxlftA0w3acX/qzVyZjzqQY6dieIjLzhZZQ1C XnxE6heiYkJJ3Ny4Rki19tiDutMkPtGKaohu8yehIULoAZwNIm4FiezgIx792AjFVUnH 8huA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NfA+nEQC; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z23si1678179otm.284.2019.12.10.02.11.57; Tue, 10 Dec 2019 02:12:10 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NfA+nEQC; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727242AbfLJKLQ (ORCPT + 99 others); Tue, 10 Dec 2019 05:11:16 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:28514 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727219AbfLJKLN (ORCPT ); Tue, 10 Dec 2019 05:11:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575972671; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=/fNSAK93ztMW9L1B/NS00CbJs6KXG9nyQ8geCOXUcHA=; b=NfA+nEQCABHL83P1v4tkr9VrDUNo67/RGhQ2Gn5FqzFD9fvhA/MhTdqMV32qewKrGP6v+R 22v5z0/tgIG9TXo9G5f1xmc01l384a7ypTNws6TdxvVne8kXg1kuFzTAMb83bA466TEEMj yFsqb/cb9oARGpEPZjWN5c7tQWDo3Xk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-188-laAmNaQoMZGmiLgtL7GHyQ-1; Tue, 10 Dec 2019 05:11:08 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9B25F18AAFA2; Tue, 10 Dec 2019 10:11:06 +0000 (UTC) Received: from [10.36.117.222] (ovpn-117-222.ams2.redhat.com [10.36.117.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 450B75D6D4; Tue, 10 Dec 2019 10:11:04 +0000 (UTC) Subject: Re: [PATCH v1 1/3] mm: fix uninitialized memmaps on a partially populated last section To: Daniel Jordan Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org, Naoya Horiguchi , Pavel Tatashin , Andrew Morton , Steven Sistare , Michal Hocko , Bob Picco , Oscar Salvador References: <20191209174836.11063-1-david@redhat.com> <20191209174836.11063-2-david@redhat.com> <20191209211502.zhbvzv2qwbvcperm@ca-dmjordan1.us.oracle.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; prefer-encrypt=mutual; keydata= mQINBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacP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Q 9wD/g1qA6w/+M+ggFv+JdVsz5+ZIc6MSyGUozASX+bmIuPeIecc9UsFRatc91LuJCKMkD9Uv GOcWSeFpLrSGRQ1Z7EMzFVU//qVs6uzhsNk0RYMyS0B6oloW3FpyQ+zOVylFWQCzoyyf227y GW8HnXunJSC+4PtlL2AY4yZjAVAPLK2l6mhgClVXTQ/S7cBoTQKP+jvVJOoYkpnFxWE9pn4t H5QIFk7Ip8TKr5k3fXVWk4lnUi9MTF/5L/mWqdyIO1s7cjharQCstfWCzWrVeVctpVoDfJWp 4LwTuQ5yEM2KcPeElLg5fR7WB2zH97oI6/Ko2DlovmfQqXh9xWozQt0iGy5tWzh6I0JrlcxJ ileZWLccC4XKD1037Hy2FLAjzfoWgwBLA6ULu0exOOdIa58H4PsXtkFPrUF980EEibUp0zFz GotRVekFAceUaRvAj7dh76cToeZkfsjAvBVb4COXuhgX6N4pofgNkW2AtgYu1nUsPAo+NftU CxrhjHtLn4QEBpkbErnXQyMjHpIatlYGutVMS91XTQXYydCh5crMPs7hYVsvnmGHIaB9ZMfB njnuI31KBiLUks+paRkHQlFcgS2N3gkRBzH7xSZ+t7Re3jvXdXEzKBbQ+dC3lpJB0wPnyMcX FOTT3aZT7IgePkt5iC/BKBk3hqKteTnJFeVIT7EC+a6YUFg= Organization: Red Hat GmbH Message-ID: Date: Tue, 10 Dec 2019 11:11:03 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <20191209211502.zhbvzv2qwbvcperm@ca-dmjordan1.us.oracle.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: laAmNaQoMZGmiLgtL7GHyQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09.12.19 22:15, Daniel Jordan wrote: > Hi David, >=20 > On Mon, Dec 09, 2019 at 06:48:34PM +0100, David Hildenbrand wrote: >> If max_pfn is not aligned to a section boundary, we can easily run into >> BUGs. This can e.g., be triggered on x86-64 under QEMU by specifying a >> memory size that is not a multiple of 128MB (e.g., 4097MB, but also >> 4160MB). I was told that on real HW, we can easily have this scenario >> (esp., one of the main reasons sub-section hotadd of devmem was added). >> >> The issue is, that we have a valid memmap (pfn_valid()) for the >> whole section, and the whole section will be marked "online". >> pfn_to_online_page() will succeed, but the memmap contains garbage. >> >> E.g., doing a "cat /proc/kpageflags > /dev/null" results in >> >> [ 303.218313] BUG: unable to handle page fault for address: fffffffffff= ffffe >> [ 303.218899] #PF: supervisor read access in kernel mode >> [ 303.219344] #PF: error_code(0x0000) - not-present page >> [ 303.219787] PGD 12614067 P4D 12614067 PUD 12616067 PMD 0 >> [ 303.220266] Oops: 0000 [#1] SMP NOPTI >> [ 303.220587] CPU: 0 PID: 424 Comm: cat Not tainted 5.4.0-next-20191128= + #17 >=20 Hi Daniel, > I can't reproduce this on x86-64 qemu, next-20191128 or mainline, with ei= ther > memory size. What config are you using? How often are you hitting it? Thanks for verifying! Hah, there is one piece missing to reproduce via "cat /proc/kpageflags > /dev/null" that I ignored on my QEMU cmdline (see b= elow) I can reproduce it reliably (QEMU with "-m 4160M") via [root@localhost ~]# uname -a Linux localhost 5.5.0-rc1-next-20191209 #93 SMP Tue Dec 10 10:46:19 CET 201= 9 x86_64 x86_64 x86_64 GNU/Linux [root@localhost ~]# ./page-types -r -a 0x144001 [ 200.476376] BUG: unable to handle page fault for address: ffffffffffffff= fe [ 200.477500] #PF: supervisor read access in kernel mode [ 200.478334] #PF: error_code(0x0000) - not-present page [ 200.479076] PGD 59614067 P4D 59614067 PUD 59616067 PMD 0=20 [ 200.479557] Oops: 0000 [#4] SMP NOPTI [ 200.479875] CPU: 0 PID: 603 Comm: page-types Tainted: G D W = 5.5.0-rc1-next-20191209 #93 [ 200.480646] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS = rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu4 [ 200.481648] RIP: 0010:stable_page_flags+0x4d/0x410 [ 200.482061] Code: f3 ff 41 89 c0 48 b8 00 00 00 00 01 00 00 00 45 84 c0 = 0f 85 cd 02 00 00 48 8b 53 08 48 8b 2b 48f [ 200.483644] RSP: 0018:ffffb139401cbe60 EFLAGS: 00010202 [ 200.484091] RAX: fffffffffffffffe RBX: fffffbeec5100040 RCX: 00000000000= 00000 [ 200.484697] RDX: 0000000000000001 RSI: ffffffff9535c7cd RDI: 00000000000= 00246 [ 200.485313] RBP: ffffffffffffffff R08: 0000000000000000 R09: 00000000000= 00000 [ 200.485917] R10: 0000000000000000 R11: 0000000000000000 R12: 00000000001= 44001 [ 200.486523] R13: 00007ffd6ba55f48 R14: 00007ffd6ba55f40 R15: ffffb139401= cbf08 [ 200.487130] FS: 00007f68df717580(0000) GS:ffff9ec77fa00000(0000) knlGS:= 0000000000000000 [ 200.487804] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 200.488295] CR2: fffffffffffffffe CR3: 0000000135d48000 CR4: 00000000000= 006f0 [ 200.488897] Call Trace: [ 200.489115] kpageflags_read+0xe9/0x140 [ 200.489447] proc_reg_read+0x3c/0x60 [ 200.489755] vfs_read+0xc2/0x170 [ 200.490037] ksys_pread64+0x65/0xa0 [ 200.490352] do_syscall_64+0x5c/0xa0 [ 200.490665] entry_SYSCALL_64_after_hwframe+0x49/0xbe (tool located in tools/vm/page-types.c, see also patch #2) To reproduce via "cat /proc/kpageflags > /dev/null", you have to hot/coldplug one DIMM, to move max_pfn beyond the garbage memmap (see also patch #2). My QEMU cmdline with Fedora 31: qemu-system-x86_64 \ --enable-kvm \ -m 4160M,slots=3D4,maxmem=3D8G \ -hda Fedora-Cloud-Base-31-1.9.x86_64.qcow2 \ -machine pc \ -nographic \ -nodefaults \ -chardev stdio,id=3Dserial,signal=3Doff \ -device isa-serial,chardev=3Dserial \ -object memory-backend-ram,id=3Dmem0,size=3D1024M \ -device pc-dimm,id=3Ddimm0,memdev=3Dmem0 [root@localhost ~]# uname -a Linux localhost 5.3.7-301.fc31.x86_64 #1 SMP Mon Oct 21 19:18:58 UTC 2019 x= 86_64 x86_64 x86_64 GNU/Linux [root@localhost ~]# cat /proc/kpageflags > /dev/null [ 111.517275] BUG: unable to handle page fault for address: ffffffffffffff= fe [ 111.517907] #PF: supervisor read access in kernel mode [ 111.518333] #PF: error_code(0x0000) - not-present page [ 111.518771] PGD a240e067 P4D a240e067 PUD a2410067 PMD 0=20 >=20 > It may not have anything to do with the config, and I may be getting luck= y with > the garbage in my memory. >=20 Some things that might be relevant from my config. # CONFIG_PAGE_POISONING is not set CONFIG_DEFERRED_STRUCT_PAGE_INIT=3Dy CONFIG_SPARSEMEM_EXTREME=3Dy CONFIG_SPARSEMEM_VMEMMAP_ENABLE=3Dy CONFIG_SPARSEMEM_VMEMMAP=3Dy CONFIG_HAVE_MEMBLOCK_NODE_MAP=3Dy CONFIG_MEMORY_HOTPLUG=3Dy CONFIG_MEMORY_HOTPLUG_SPARSE=3Dy CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE=3Dy The F31 default config should make it trigger. Will update this patch description - thanks! ... --=20 Thanks, David / dhildenb