From patchwork Mon Sep 10 23:44:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 10594921 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5B3DE6CB for ; Mon, 10 Sep 2018 23:44:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49012291BB for ; Mon, 10 Sep 2018 23:44:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D043291F4; Mon, 10 Sep 2018 23:44:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C989291BB for ; Mon, 10 Sep 2018 23:44:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F6F18E0008; Mon, 10 Sep 2018 19:44:04 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 67FAF8E0001; Mon, 10 Sep 2018 19:44:04 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5217D8E0008; Mon, 10 Sep 2018 19:44:04 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 0DF848E0001 for ; Mon, 10 Sep 2018 19:44:04 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id 2-v6so10572786plc.11 for ; Mon, 10 Sep 2018 16:44:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=MJv9XTQcitO3gy5LNlz5Iv9gvth5EHKXzc6g36JI3Fc=; b=byVfWoXOvooddAYHsvZt5KPfd48mAJq7EVZNPTXt5kYErCbFJ6FE5YzkFQRDFTwpp2 Op66bmVjSk1PCQgY4oK3vw866LZkfAT2Oo8UO2ZTRZbhBKL6eMpRbNnCF8ASqk7mAZkj YOp9ImvYL0UQeurt9ewo7r2ER0csseFHhCCpGPK2HghF0R/YlMBny4VF5cyEx9Bhqmb9 555H8Din5mACZaU1hrf0EarB8cXxHgYtZnzNi8sPSCwi97kk/UVFQg0htXtPIjFO9IR/ Mphr8agfRgGSbsaeRU5VcHNRWS21/tXx4ixTUnbX+bogB70yduhNvEx/pHAF5NcaFds2 bs/g== X-Gm-Message-State: APzg51BalOnB5LDc0hM+jcAAnErhArLkKx87fv14ItJJIMdTKHPmadZ8 Ckulgg3kIfV1V+2zZd/U0j43keeD68TdxL0YBuEtvUNDurwgwz634u1jA40/IB2LAI9N3pTYdCE EdkCmcMazD9vddYEPnLYy4jarQqkMro6b9VZIRuZC7yCh4kZaG1ZlauX+6hDNBbTKP3ndNAsi+P EZaHPjjmukBpmaWgeIvw9NMp8UfLT7lftteLKfJ6kwHDRmZ6hfBjMMoAJ9hARtZbevfIXT5RNtK vdhdi6hLDicbNIJq4gkCGxSf8Cpp7QIPFhsC43zHB4YKs9JqSJIZYPF7vTO+55aAHd4NQoBeawL tY130+E2/a4ZMMVzpvLlSiASKePKBY/deyEG3WtEILOiyy9GD0WRrz99BGsdnJRFyNN2hjmuDL0 r X-Received: by 2002:a63:ff1f:: with SMTP id k31-v6mr24770616pgi.20.1536623043718; Mon, 10 Sep 2018 16:44:03 -0700 (PDT) X-Received: by 2002:a63:ff1f:: with SMTP id k31-v6mr24770559pgi.20.1536623042302; Mon, 10 Sep 2018 16:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536623042; cv=none; d=google.com; s=arc-20160816; b=dmZZHI4c5Dxb8m9Uz6Y65PhlQTcTmDWzwGw0sz1YO7sGqW6knLjAEi28exoBEzfLTn wGba+4AboioYsNUuzzc2ASPVfarxiWqSS5eTJIgpgP+XuxoBrGmoAFK5M5lqHYAQWoum 1TrAtO8ezB8aF9hvzxObWRhsjTInR8S9CZZrWiVFXLi87F6FuKV1HxvfhDILgaBj+di2 HpBYUoiolhWzQVSg/ECxCDVTRbLCO5Y7cXWBh8Vde7kitVqHcYuvoPTHxHeg0pk6Rlg9 ohm84FuZN5hxsA8cckC+5kRbiGHBhSQkItZwAij1sY5xw2Z5FEvC2QEc+zyrh/d34yk7 OH2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject:dkim-signature; bh=MJv9XTQcitO3gy5LNlz5Iv9gvth5EHKXzc6g36JI3Fc=; b=r0uHMN9QQzdtRKtTEI08377mRuN/bUhC2WlgRilxfWGHgnJHkLqM9GmHSn7qm5rsAj cTOO2hU0rInY3Av72Py1XlrZ73afl7Y6xQv07002BxotykmpgDIxCRkQkvuv8Ma+1la6 36pjvj57iy8r+pd8M7TshRVPV6KFacrhrzLfuwBiM4/B8V4AGIRVz/yvRyIEvEJxj+LB qDYZ6AebRfrcooVYBrL4Zn6y5mye3u5jQ6q3AsUMkcg0gzmJhvJZfg8N2xyzDB/THQJJ lwmbAeFP/T3N8oaWMD01p5yK7DmpV7j52YiE7+Z558a095a5gb8XGiZ7A2povjZ68Ye5 ZRQw== 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: domain of alexander.duyck@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=alexander.duyck@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id u9-v6sor3090814plz.78.2018.09.10.16.44.02 for (Google Transport Security); Mon, 10 Sep 2018 16:44:02 -0700 (PDT) Received-SPF: pass (google.com: domain of alexander.duyck@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="PO+/yHzK"; spf=pass (google.com: domain of alexander.duyck@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=alexander.duyck@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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-Smtp-Source: ANB0Vdae3zS05W6i/7y646GBZXtkkHI+KeQ/8novIzql8yYtiMRq7VA37016jMUlgSw8jVTKp/3lWw== 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Pavel Tatashin --- 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