Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4145615imm; Mon, 8 Oct 2018 16:00:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV61XpQW7NCQxL4rU1UNni/QmHr69F09HzMXd9Rgaael8+tIDoh6XlADnG/Pe1ZVOJra6sdor X-Received: by 2002:a17:902:748a:: with SMTP id h10-v6mr25849339pll.192.1539039659174; Mon, 08 Oct 2018 16:00:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539039659; cv=none; d=google.com; s=arc-20160816; b=GFdSJdAABRYKx9J1wsvCWTcvhn8cJ8UxDviwOCM6RKHYYrzQbZWankj4NI4O4mO36V GMddRobx5IYc9IfLcKfvfwKrob3CamWXf9EE9WSMv3N+JFobxi6OqDqIZzXoiPtb4L2d dKISDKsm+4+UWDl+qrFKk2gTSE5b/muAsivxjviw5yaOEVI/xkuWHZWo7wxiz+UKAAIP bry5pLLU9Y7ScIkeu8jAmOLhnZN2cDIEfmqOoRL2tPql7Eq/p0+/OPpG68BqCcX6zvGn DR9e07hsTSgqo6GVqtJv70MUuyT/wVt89vQxRPPYtq1t2uHB8Taw0ohEwBVzoU0Uq4st N3vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=yfrWdLDLMEYJrZyS69dJrB1eUHmsS6nPXa/e8epN1U8=; b=nJBTyuGed9kdi/iJkDqgwWv5WfpvLdDyt2ewtOip7SBON8dee69K40z+mc+G9iMF3U R2eMOKBbpn2gAjbjVqywwlTN8IFaeniV6UY1/rHRILvjFQ66MUcniudkumVnpTr5H22q bfQy/fafgEnnUvdKlcBqc3DK/9VTx1/xcz8SNyHfOQCqAfGJ2Q8ecrGwccRvz5dR4Wj4 vLm5am3D6s95LUXGA+IkEDC/dafM5+WGFx4BhvBj/jlsdNya/BI8Cn/b10L3YjCyisF+ iZmJCh1lTv+zpiurSA7Dg48rDAn8ihDzVDPYO+iRnq3VwkNsxJR9nMTcXmDG8MvfVaGo 9hwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=vG4UG41w; 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33-v6si20545882ply.251.2018.10.08.16.00.44; Mon, 08 Oct 2018 16:00:59 -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=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=vG4UG41w; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726569AbeJIGON (ORCPT + 99 others); Tue, 9 Oct 2018 02:14:13 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:36625 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbeJIGON (ORCPT ); Tue, 9 Oct 2018 02:14:13 -0400 Received: by mail-ot1-f66.google.com with SMTP id k5so8804884ote.3 for ; Mon, 08 Oct 2018 16:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yfrWdLDLMEYJrZyS69dJrB1eUHmsS6nPXa/e8epN1U8=; b=vG4UG41wfmwIJiKqvJUx8iLPuMTOjch/Yce8tTK+BnMWkBeM6mZP+3yIS82Begz3ri kX1PsRzw+V5jXEv37wNPMXnMqaD1bUjHzohVxIMVGWwM6TQwsdZbuYzXnvCIEPwegVuo k4hED67GEupIxJmoc6joW7zNQCeRxAvzbQoT22lJfnfBZ2YyhAsHa5erYRyqmDmpNMeq EfEv07dov7hy1ULuJUqeMapNx+xUOSjCTG6bm64cpfiU+vynjx8cyQewpVUCbeCYd+Zj 6pAfLKTD1P6Xr5kwWCEX/ahJHONk0ZPlTh2BWZDyIJZRzCe6kCG+7c3BasYoSu7ek8Gs yG7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yfrWdLDLMEYJrZyS69dJrB1eUHmsS6nPXa/e8epN1U8=; b=ASjIBPtS5Nau3pDciabVLkfLfI15rRyiFG8CCIEGoIuzxwcW/Ha85TdX7gm05dPipf HcYWtONfLdjsq7gfogrNA98c/THUVyjR8y84nxG2qeEyAUGLwjD8hHMWd0Dw9UZuUO7T e1QqgyYZFiuyq/bVhsVtfNixLvg778TxNzYtoGrhDZ6XweTvpKjD9Opn8TuVKvq29gsK Ham/c4yT6Gyy6nAKqG+XRDIt5Iy0mo+GCFVOlwaZ/FbvzYU6a+460pPGvb4fga3BrQAp KrBkZX7T/BZiNOm+FtgLMc4PWKutMb4sCn4I3aFkfOqWHG5ovqKtRhOfxkyIj+zJfvLv GKww== X-Gm-Message-State: ABuFfoiUU3i7djpswSI400Ru1clkesLlYnQphGEgUyYe3Mk0xoz4kVQA uYtrzO+fjCLfr3n5DBE22YI2zlDte0AUB8jvjOTFSw== X-Received: by 2002:a9d:56ef:: with SMTP id b44mr15742202otj.214.1539039611070; Mon, 08 Oct 2018 16:00:11 -0700 (PDT) MIME-Version: 1.0 References: <20180925200551.3576.18755.stgit@localhost.localdomain> <20180925202053.3576.66039.stgit@localhost.localdomain> <379e1d22-4194-6744-9e80-897b6ba126e9@linux.intel.com> <95de811f-ad44-c96d-3914-5625933d5e88@linux.intel.com> In-Reply-To: <95de811f-ad44-c96d-3914-5625933d5e88@linux.intel.com> From: Dan Williams Date: Mon, 8 Oct 2018 15:59:59 -0700 Message-ID: Subject: Re: [PATCH v5 4/4] mm: Defer ZONE_DEVICE page initialization to the point where we init pgmap To: alexander.h.duyck@linux.intel.com Cc: Linux MM , Andrew Morton , Linux Kernel Mailing List , linux-nvdimm , Pasha Tatashin , Michal Hocko , Dave Jiang , Dave Hansen , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , rppt@linux.vnet.ibm.com, Logan Gunthorpe , Ingo Molnar , "Kirill A. Shutemov" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 8, 2018 at 3:37 PM Alexander Duyck wrote: > > > > On 10/8/2018 3:00 PM, Dan Williams wrote: > > On Mon, Oct 8, 2018 at 2:48 PM Alexander Duyck > > wrote: > >> > >> On 10/8/2018 2:01 PM, Dan Williams wrote: > >>> On Tue, Sep 25, 2018 at 1:29 PM Alexander Duyck > >>> wrote: > >>>> > >>>> The ZONE_DEVICE pages were being initialized in two locations. One was with > >>>> the memory_hotplug lock held and another was outside of that lock. The > >>>> problem with this is that it was nearly doubling the memory initialization > >>>> time. Instead of doing this twice, once while holding a global lock and > >>>> once without, I am opting to defer the initialization to the one outside of > >>>> the lock. This allows us to avoid serializing the overhead for memory init > >>>> and we can instead focus on per-node init times. > >>>> > >>>> One issue I encountered is that devm_memremap_pages and > >>>> hmm_devmmem_pages_create were initializing only the pgmap field the same > >>>> way. One wasn't initializing hmm_data, and the other was initializing it to > >>>> a poison value. Since this is something that is exposed to the driver in > >>>> the case of hmm I am opting for a third option and just initializing > >>>> hmm_data to 0 since this is going to be exposed to unknown third party > >>>> drivers. > >>>> > >>>> Reviewed-by: Pavel Tatashin > >>>> Signed-off-by: Alexander Duyck > >>>> --- > >>>> > >>>> v4: Moved moved memmap_init_zone_device to below memmmap_init_zone to avoid > >>>> merge conflicts with other changes in the kernel. > >>>> v5: No change > >>> > >>> This patch appears to cause a regression in the "create.sh" unit test > >>> in the ndctl test suite. > >> > >> So all you had to do is run the create.sh script to see the issue? I > >> just want to confirm there isn't any additional information needed > >> before I try chasing this down. > > > > From the ndctl source tree run: > > > > make -j TESTS="create.sh" check > > > > ...the readme has some more setup instructions: > > https://github.com/pmem/ndctl/blob/master/README.md > > > > 0day has sometimes run this test suite automatically, but we need to > > get that more robust because setting up this environment is a bit of a > > hoop to jump through with the need to setup the nfit_test module. > > > >>> I tried to reproduce on -next with: > >>> > >>> 2302f5ee215e mm: defer ZONE_DEVICE page initialization to the point > >>> where we init pgmap > >>> > >>> ...but -next does not even boot for me at that commit. > >> > >> What version of -next? There are a couple of patches probably needed > >> depending on which version you are trying to boot. > > > > Today's -next, but backed up to that above commit. I was also seeing > > CONFIG_DEBUG_LIST spamming the logs, and a crash in the crypto layer. > > > >>> Here is a warning signature that proceeds a hang with this patch > >>> applied against v4.19-rc6: > >>> > >>> percpu ref (blk_queue_usage_counter_release) <= 0 (-1530626) after > >>> switching to atomic > >>> WARNING: CPU: 24 PID: 7346 at lib/percpu-refcount.c:155 > >>> percpu_ref_switch_to_atomic_rcu+0x1f7/0x200 > >>> CPU: 24 PID: 7346 Comm: modprobe Tainted: G OE 4.19.0-rc6+ #2458 > >>> [..] > >>> RIP: 0010:percpu_ref_switch_to_atomic_rcu+0x1f7/0x200 > >>> [..] > >>> Call Trace: > >>> > >>> ? percpu_ref_reinit+0x140/0x140 > >>> rcu_process_callbacks+0x273/0x880 > >>> __do_softirq+0xd2/0x428 > >>> irq_exit+0xf6/0x100 > >>> smp_apic_timer_interrupt+0xa2/0x220 > >>> apic_timer_interrupt+0xf/0x20 > >>> > >>> RIP: 0010:lock_acquire+0xb8/0x1a0 > >>> [..] > >>> ? __put_page+0x55/0x150 > >>> ? __put_page+0x55/0x150 > >>> __put_page+0x83/0x150 > >>> ? __put_page+0x55/0x150 > >>> devm_memremap_pages_release+0x194/0x250 > >>> release_nodes+0x17c/0x2c0 > >>> device_release_driver_internal+0x1a2/0x250 > >>> driver_detach+0x3a/0x70 > >>> bus_remove_driver+0x58/0xd0 > >>> __x64_sys_delete_module+0x13f/0x200 > >>> ? trace_hardirqs_off_thunk+0x1a/0x1c > >>> do_syscall_64+0x60/0x210 > >>> entry_SYSCALL_64_after_hwframe+0x49/0xbe > >>> > >> > >> So it looks like we are tearing down memory when this is triggered. Do > >> we know if this is at the end of the test or if this is running in > >> parallel with anything? > > > > Should not be running in parallel with anything this test is > > performing a series of namespace setup and teardown events. > > > > Wait, where did the call to "percpu_ref_get()" go? I think that's the bug. > > > > I have a reproduction on my system now as well. I should have a patch > ready to go for it in the next hour or so. > Nice! Thanks for jumping on this, and I like the "get_many" optimization.