Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1291218ybf; Fri, 28 Feb 2020 18:52:55 -0800 (PST) X-Google-Smtp-Source: APXvYqygckCh9isISuB96kcuoSymCRTzHZbLbe3tJ2YMh1mk0vwy31fqbUKL5Hw+aEpB03KvZuT6 X-Received: by 2002:aca:be56:: with SMTP id o83mr5241102oif.25.1582944775162; Fri, 28 Feb 2020 18:52:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582944775; cv=none; d=google.com; s=arc-20160816; b=lYRsQ9uSDsy0aAU1ZNyKtv1fzIH2a7yMoMO9o3q5VlFR2P0eg3xVfm2rNg+060mfDI TQSUY4L0HHf5TpwTB2C+F0FHZnCIPy2ysRx7RHoX9CR7mR0rmlLqNzAi6iWPYcQN4p0q YIpLVvCrnZK1Lpi2SuUjw+SyHHAnBmi4LV0gpMetjiFhgfyPwgvY2uVmPsPIiNpkyeUB 2HZRzOQwZv5yZH3rtAQpSbGpPVhyoKRusN5HPL8xlQGKiLhwJSw9x17fQByb6hhQCVjl 5O6OyxxLw22571n4HdYCgckdyzBEorSFAu/4mhchGG7bEmwvYzl4MZacw426qu0mufk7 kExw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :message-id:subject:cc:to:from:date; bh=/vIYPU5tMGXMimaJGf9ECnUEHHytE0SwwRDZCzFO8Cc=; b=Jf/ZaKmyF4Kps6JdJ+PG/HDYdO1STV9VYZLMkVtJhNidkQtlYVPaoWdFO/kwTNgkFV 3WNBACIDJ6R39+3djnW2Pci3UFo24+N+dc7m9wi3pQp0NyiXEkOLzK1eYOerpOOeOhR6 T44efkZmKI/zafaiEH6UrDXRlDfDqavT9+dRWGye7sV4/wLqamc/SjQNjvcN0f7iWFZw u3ueuhEyjWeZRgw8b7tVTwI8zX642op0kLfLzYoWh2Mlnc+Ep9ZK7yZAYh2UjSp0G/+E FNcxtwPrKFfbIoz1FrYowwAAlDJCmBl5EuEKhICSAnu5QiJf7aM8E5ETVBSpGHgTU7LL M3iQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m17si2725744oie.187.2020.02.28.18.52.42; Fri, 28 Feb 2020 18:52:55 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726720AbgB2Cwg (ORCPT + 99 others); Fri, 28 Feb 2020 21:52:36 -0500 Received: from relay12.mail.gandi.net ([217.70.178.232]:40481 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726046AbgB2Cwg (ORCPT ); Fri, 28 Feb 2020 21:52:36 -0500 Received: from localhost (c-71-238-64-75.hsd1.or.comcast.net [71.238.64.75]) (Authenticated sender: josh@joshtriplett.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 3EC1F200007; Sat, 29 Feb 2020 02:52:30 +0000 (UTC) Date: Fri, 28 Feb 2020 18:52:28 -0800 From: Josh Triplett To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] nvme: Check for readiness more quickly, to speed up boot time Message-ID: <20200229025228.GA203607@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After initialization, nvme_wait_ready checks for readiness every 100ms, even though the drive may be ready far sooner than that. This delays system boot by hundreds of milliseconds. Reduce the delay, checking for readiness every millisecond instead. Boot-time tests on an AWS c5.12xlarge: Before: [ 0.546936] initcall nvme_init+0x0/0x5b returned 0 after 37 usecs ... [ 0.764178] nvme nvme0: 2/0/0 default/read/poll queues [ 0.768424] nvme0n1: p1 [ 0.774132] EXT4-fs (nvme0n1p1): mounted filesystem with ordered data mode. Opts: (null) [ 0.774146] VFS: Mounted root (ext4 filesystem) on device 259:1. ... [ 0.788141] Run /sbin/init as init process After: [ 0.537088] initcall nvme_init+0x0/0x5b returned 0 after 37 usecs ... [ 0.543457] nvme nvme0: 2/0/0 default/read/poll queues [ 0.548473] nvme0n1: p1 [ 0.554339] EXT4-fs (nvme0n1p1): mounted filesystem with ordered data mode. Opts: (null) [ 0.554344] VFS: Mounted root (ext4 filesystem) on device 259:1. ... [ 0.567931] Run /sbin/init as init process Signed-off-by: Josh Triplett --- drivers/nvme/host/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index a4d8c90ee7cc..04174a40b9b0 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2074,7 +2074,7 @@ static int nvme_wait_ready(struct nvme_ctrl *ctrl, u64 cap, bool enabled) if ((csts & NVME_CSTS_RDY) == bit) break; - msleep(100); + usleep_range(1000, 2000); if (fatal_signal_pending(current)) return -EINTR; if (time_after(jiffies, timeout)) { -- 2.25.1