Received: by 2002:a4a:3008:0:0:0:0:0 with SMTP id q8-v6csp3547526oof; Mon, 10 Sep 2018 16:46:16 -0700 (PDT) X-Google-Smtp-Source: ANB0VdavUa3QFf3+olaObouzaW+6LBZeBFsrOHnNi+CUsu2+M6kxy9kiJA12UEdLsRBzC0VPupVP X-Received: by 2002:a17:902:76c5:: with SMTP id j5-v6mr24427267plt.140.1536623176563; Mon, 10 Sep 2018 16:46:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536623176; cv=none; d=google.com; s=arc-20160816; b=qJ2d+wgOYxwrZyA4XaQW+j5GZ+wyfD8NHJwUkOPsumclyix4TDwQoQMfkw4u4gvJRM RbDwHeOhXXgkAJ4DrETPL6lZkjmN20P57OhMll1abz6bdeOqm2HAzIeTHz5eGGa926jq h5V8MQxBN3jAleDEUVy4J+Xtyuhc5kIidZ1eoi0iNA3/6StZOUhxi7nHAs+TxbkFGr0S l1j+9GwXkBJ9qZ944whrqCeOYVoFUHk/yFp4G70Ia20zSvSgHkaUdYLuoTwPFths5qao FHsgNSBdsjN8mJ/Vaz5h69aezoUF/e5DTNd3sEBWGzBOmmQlGKcroUeZoOl3hJOdI5N6 /BwQ== 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:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=MJv9XTQcitO3gy5LNlz5Iv9gvth5EHKXzc6g36JI3Fc=; b=stOUsfiLGOLzPrclyre6N0ivIzRD8Q43gl5Skb1ndIVs98ZZsmCZJK1WVrma5DjSYV JLMniw0ZyXpB3Pb/9FUD9b96O8dpWJLVJB6hS9Lt/CJXw6/Pg64be0L4ZhLUkhuspxlP cWjku4NmXBXL6Iv7HeVtyxEgBfAvnuDcQ/EvMfZfiIf5IpEMZqUukzRU+lEVSom/OBy/ qd98jNqEUAzXXwHFlWiK3kp7eXSYLcIoFgSBs6XF1K+wl0To0bXtYETu++7WqR7QuL85 2iJzrXFFJlPAipBZVaShMcyAzzQpelz0Qs9XKcDaWTtw0jHktUjHpKKAIfPg3AKql6I8 ZS4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="PO+/yHzK"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 205-v6si18992000pgd.271.2018.09.10.16.46.01; Mon, 10 Sep 2018 16:46:16 -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=@gmail.com header.s=20161025 header.b="PO+/yHzK"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726612AbeIKEk1 (ORCPT + 99 others); Tue, 11 Sep 2018 00:40:27 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:33946 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725945AbeIKEk1 (ORCPT ); Tue, 11 Sep 2018 00:40:27 -0400 Received: by mail-pl1-f194.google.com with SMTP id f6-v6so10463950plo.1 for ; Mon, 10 Sep 2018 16:44:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=MJv9XTQcitO3gy5LNlz5Iv9gvth5EHKXzc6g36JI3Fc=; b=PO+/yHzKVe6BrtyAYDCrPoH1MS/MgG2SdH2MWE4Pu16baBk2jwxUqndfwe7rrtFeej oNi0xoLwWDoh/gd29YEKhez5Fy1B0bGTUGlQS4awi43cRSQ8iOBoIPq5oivMRFj72UY5 f/VQa99Utf8IKzhwwIc7PqOHfuuG7xBmEB/exPT+8K0id8EJdHbVG4JJatsFCVZDMBi5 2gMw6sr3IyU1oH20TXT94TN7u7jJ3We/C7qEycP6m4tSiuK2GvyPZIZu3sCMOBGm/r0U e8ToHPOnpYI6rp3t/sHjxch8Nt0PHUEgdYOTrCXwZ1s33o4RIGLboXtgZK6qo7kLre/9 vMFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=MJv9XTQcitO3gy5LNlz5Iv9gvth5EHKXzc6g36JI3Fc=; b=XesGyFVYgpJ8E/a4FRZ5k4E3ScUPGZzBC10SQ4V55pYcd/gGSMfFfxB6O6TIIsJLAD 5wcKRIY2n3d1Rhkv5tJZ2/ziwVfzBMQMJfnPsGH5xg0a9FqfNWv0XJEnByNXi1BcTUrO AMoShwH1GObg0amJRruAb/O0+l9P9DY41HkbhA9IcF6Wmq5D54kNd9QG8h4JdgzFGQ1o TI+IRvBKhXRhFIZBHHR66y5vPFLPN7I8pmOnJkQWgaG54A21SmiOnsQ6JauevDJtBNwe 5vvp3EVidW6AhOytYLpBG171RlNnSYlCm9LIi3DivUND4Y/6EVEb3aFXaKpKjtcxRH5+ ZBew== X-Gm-Message-State: APzg51Ct3cUF2bRdoVYta4BH3HBKUdNcpVf1evB+NLFK173Smm1BQWcP t8obgaOqaMdAS39NQakFAp4i0eVI X-Received: by 2002:a17:902:7402:: with SMTP id g2-v6mr24285976pll.321.1536623041876; Mon, 10 Sep 2018 16:44:01 -0700 (PDT) Received: from localhost.localdomain (static-50-53-21-37.bvtn.or.frontiernet.net. [50.53.21.37]) by smtp.gmail.com with ESMTPSA id u184-v6sm21581039pgd.46.2018.09.10.16.44.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Sep 2018 16:44:01 -0700 (PDT) Subject: [PATCH 4/4] nvdimm: Trigger the device probe on a cpu local to the device From: Alexander Duyck To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org Cc: pavel.tatashin@microsoft.com, mhocko@suse.com, dave.jiang@intel.com, mingo@kernel.org, dave.hansen@intel.com, jglisse@redhat.com, akpm@linux-foundation.org, logang@deltatee.com, dan.j.williams@intel.com, kirill.shutemov@linux.intel.com Date: Mon, 10 Sep 2018 16:44:00 -0700 Message-ID: <20180910234400.4068.15541.stgit@localhost.localdomain> In-Reply-To: <20180910232615.4068.29155.stgit@localhost.localdomain> References: <20180910232615.4068.29155.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Duyck This patch is based off of the pci_call_probe function used to initialize PCI devices. The general idea here is to move the probe call to a location that is local to the memory being initialized. By doing this we can shave significant time off of the total time needed for initialization. With this patch applied I see a significant reduction in overall init time as without it the init varied between 23 and 37 seconds to initialize a 3GB node. With this patch applied the variance is only between 23 and 26 seconds to initialize each node. I hope to refine this further in the future by combining this logic into the async_schedule_domain code that is already in use. By doing that it would likely make this functionality redundant. Signed-off-by: Alexander Duyck --- drivers/nvdimm/bus.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c index 8aae6dcc839f..5b73953176b1 100644 --- a/drivers/nvdimm/bus.c +++ b/drivers/nvdimm/bus.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "nd-core.h" #include "nd.h" #include "pfn.h" @@ -90,6 +91,48 @@ static void nvdimm_bus_probe_end(struct nvdimm_bus *nvdimm_bus) nvdimm_bus_unlock(&nvdimm_bus->dev); } +struct nvdimm_drv_dev { + struct nd_device_driver *nd_drv; + struct device *dev; +}; + +static long __nvdimm_call_probe(void *_nddd) +{ + struct nvdimm_drv_dev *nddd = _nddd; + struct nd_device_driver *nd_drv = nddd->nd_drv; + + return nd_drv->probe(nddd->dev); +} + +static int nvdimm_call_probe(struct nd_device_driver *nd_drv, + struct device *dev) +{ + struct nvdimm_drv_dev nddd = { nd_drv, dev }; + int rc, node, cpu; + + /* + * Execute driver initialization on node where the device is + * attached. This way the driver will be able to access local + * memory instead of having to initialize memory across nodes. + */ + node = dev_to_node(dev); + + cpu_hotplug_disable(); + + if (node < 0 || node >= MAX_NUMNODES || !node_online(node)) + cpu = nr_cpu_ids; + else + cpu = cpumask_any_and(cpumask_of_node(node), cpu_online_mask); + + if (cpu < nr_cpu_ids) + rc = work_on_cpu(cpu, __nvdimm_call_probe, &nddd); + else + rc = __nvdimm_call_probe(&nddd); + + cpu_hotplug_enable(); + return rc; +} + static int nvdimm_bus_probe(struct device *dev) { struct nd_device_driver *nd_drv = to_nd_device_driver(dev->driver); @@ -104,7 +147,7 @@ static int nvdimm_bus_probe(struct device *dev) dev->driver->name, dev_name(dev)); nvdimm_bus_probe_start(nvdimm_bus); - rc = nd_drv->probe(dev); + rc = nvdimm_call_probe(nd_drv, dev); if (rc == 0) nd_region_probe_success(nvdimm_bus, dev); else