Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4771124imm; Tue, 11 Sep 2018 18:00:23 -0700 (PDT) X-Google-Smtp-Source: ANB0VdazBvX71ttE9kH2aR1Dcf26wf9Z33BgTy7fXY2DPyc05CJ3cXivn8lHTOjJnXbOpYilFlqW X-Received: by 2002:a62:6eca:: with SMTP id j193-v6mr32501757pfc.256.1536714023639; Tue, 11 Sep 2018 18:00:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536714023; cv=none; d=google.com; s=arc-20160816; b=ECI9WTlthnoqY+vBlP9DWwVzIHBYob1CmH82A93Hc1Sls2O67UooY89Wg+m6ESxBux rEujJ0/6ePgZl2StqPwOeipINggu1A6G3px3IhO5sfIC0ANrm2GH+SbGvgCwwG5tWWNm PbsWnDUiu1jSK8833cm5+JijjkIRBZDgEK2C0t0bNBq9OzYJ1eQONIV5D86v3EXQAXSu z6yXwe0HAJx7TiacAiQbufRxNzZm6aEPpRBZAkk2Z0jCStqERLedpXn3Mhv+OIi2C9IT InVGmgbmqo///vvpIE7Kwkom141rhBah8RmQpy6xa3H+ssznxyoIy951TIeiTq7K3Jqr CC7Q== 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 :references:in-reply-to:mime-version:dkim-signature; bh=V/CZuoxDlWV2LXi8Q0HeRK4VPjrLxaFxj16KV7q2mfc=; b=whVmFSMpmM1jRa381qsUXdoekk3TXoNqmtMMUiaxjhFYs4KmwtuATGa4ZWjAsbZzp1 8aiVyGHuSN+NngFvDS43ywlHHU7tA/+zIRL0+71q0zrbCmht6UGNJUeDrGb1CqqgIdXe VnmHpUb1giOe1J7TRlffYfaLJdRWrIBLbysju2PohVudDrwUtHVnNyYH4cwr+ZqcNq7w OgYfYBZdr+zIdLTPCzMG3Chl9xc6XxvZ3Vqv6ZMdNBDfCXxqASW3hxCCg7PvQri2xvj+ to80THPsjX0mgAHZjuWPqQTFit8OaNEzM8XyubTy2cZsLkd3b8Ig8LmqiWvoZ/ShnNM+ LWlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=MBcCzeuj; 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 m23-v6si22155839pgl.51.2018.09.11.18.00.08; Tue, 11 Sep 2018 18:00:23 -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=MBcCzeuj; 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 S1727957AbeILGBV (ORCPT + 99 others); Wed, 12 Sep 2018 02:01:21 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:34288 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726092AbeILGBU (ORCPT ); Wed, 12 Sep 2018 02:01:20 -0400 Received: by mail-oi0-f67.google.com with SMTP id 13-v6so435761ois.1 for ; Tue, 11 Sep 2018 17:59:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=V/CZuoxDlWV2LXi8Q0HeRK4VPjrLxaFxj16KV7q2mfc=; b=MBcCzeujulwuGlxNu4JBuEDSoBypjxqmREf9m6ObE18T7GMb5KVAIeCKGStddZhG6o lRdbWQE5CwJgu2O77VO2kXCxQVMh5Eyto1+85u86Bje0z2hvrasV2DCVY3vriVugJqGY iD5D+wo25rXVDvRdVEapSlHLkDvBsIemas/odHSYzJWlLraaN7oWUPPI99kfSsD5ZDV5 Q7z7hWIrKPAWt6BJ3f0p/qvNwQ6wdvjxwREWzihkt1+HAMjH3q5ZIxNX12SBRqGcAIkD LFAGoBtlXExwhWj+9Tz2cEKXU7XJmp4yaqVaXF0VpdPbMNbORdOQVc3TfLZAN6q+A43H Qs/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=V/CZuoxDlWV2LXi8Q0HeRK4VPjrLxaFxj16KV7q2mfc=; b=hD7QCa1ceN9WKBV8LFOo1VjCKYf1k9a0FPizhdLdHX4TCdTr90dxELxh4lEC2R7mj6 DlDykB5eanhA9tcN5IqA9Lsd57pxQYbdxTfjEwJubMu/sY+sjQ9DzXzbe/uAahJZ4wTI p+88K2YOnWPsPosQ4wBnRTdRU+wIwt7xqUeW64bqHBuNlafMmBbSOHihcwXt4N/D7ufe 4KG6TaSDB4GKhDqVbPwXBMB8D97OqMklXyXG+7UIwHvQtcQKw9MhUHT7+5IUMyjduPVa eFc6505CsveEU4ufD3NWuiH7E7bg8L4hW03yADPj5yZDIQKYx/T/EevkVHeclTBm3A3n 2gKg== X-Gm-Message-State: APzg51DLlY0449DzgHiMwsSfhJ/isJ8iYrRUHbmLuv/ArikJivKEnTJX wWmWXo/W14bxKtD2G+xvcXWcTEJ3ySCTBhQQRdoXqA== X-Received: by 2002:aca:4083:: with SMTP id n125-v6mr28083977oia.167.1536713966397; Tue, 11 Sep 2018 17:59:26 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4a:8e85:0:0:0:0:0 with HTTP; Tue, 11 Sep 2018 17:59:25 -0700 (PDT) In-Reply-To: References: <20180910232615.4068.29155.stgit@localhost.localdomain> <20180910234354.4068.65260.stgit@localhost.localdomain> From: Dan Williams Date: Tue, 11 Sep 2018 17:59:25 -0700 Message-ID: Subject: Re: [PATCH 3/4] mm: Defer ZONE_DEVICE page initialization to the point where we init pgmap To: Alexander Duyck Cc: linux-mm , LKML , linux-nvdimm , pavel.tatashin@microsoft.com, Michal Hocko , Dave Jiang , Ingo Molnar , Dave Hansen , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Andrew Morton , Logan Gunthorpe , "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 Tue, Sep 11, 2018 at 5:51 PM, Alexander Duyck wrote: > On Tue, Sep 11, 2018 at 3:35 PM Dan Williams wrote: >> >> On Mon, Sep 10, 2018 at 4:43 PM, Alexander Duyck >> wrote: >> > >> > From: Alexander Duyck >> > >> > 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. >> > >> > Signed-off-by: Alexander Duyck >> > --- >> > include/linux/mm.h | 2 + >> > kernel/memremap.c | 24 +++++--------- >> > mm/hmm.c | 12 ++++--- >> > mm/page_alloc.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++- >> >> Hmm, why mm/page_alloc.c and not kernel/memremap.c for this new >> helper? I think that would address the kbuild reports and keeps all >> the devm_memremap_pages / ZONE_DEVICE special casing centralized. I >> also think it makes sense to move memremap.c to mm/ rather than >> kernel/ especially since commit 5981690ddb8f "memremap: split >> devm_memremap_pages() and memremap() infrastructure". Arguably, that >> commit should have went ahead with the directory move. > > The issue ends up being the fact that I would then have to start > exporting infrastructure such as __init_single_page from page_alloc. I > have some follow-up patches I am working on that will generate some > other shared functions that can be used by both memmap_init_zone and > memmap_init_zone_device, as well as pulling in some of the code from > the deferred memory init. You wouldn't need to export it, just make it public to mm/ in mm/internal.h, or a similar local header. With kernel/memremap.c moved to mm/memremap.c this becomes even easier and better scoped for the shared symbols.