Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6867920yba; Tue, 14 May 2019 15:24:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1Ot3uvhJ2ruI996LuhZ/fuqF8UO5zqzGa2VwGHNGiq5pCEF/k3fHIwYV+FdykCsVXEcWz X-Received: by 2002:a17:902:bb89:: with SMTP id m9mr2233499pls.188.1557872686524; Tue, 14 May 2019 15:24:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557872686; cv=none; d=google.com; s=arc-20160816; b=mro7fgrml1ts6M3tWMMJ2K/H+g6NawXNxTpZlh7ElmxhF8tDVtI07Dxjo37C4BR8L/ o4kl9f14wCGxjVRI0j8jr7BxzPFnExHpUVtPCbFfsn6whc9aoWO2Bo6sAu8e2RuzdOrU 6joUgQ11mfy+uV+4EFFVVB5fyO4IbUIrfsHC2mvrQc9S5mDfjDGoFARncFmrRzQ9thjQ lKJ7kaZJL7AF0ddTql8w8xghGbdC2C+jXoEKfs/GxxzJQ9CxeuVgN3uwOOYbDKPrLrLp ZOHJPNlp2CplXjzMuDOE2/zSUuDxTGOVLAkL7yOITyiX8r+40KV3iiYWwUAn2opV+wV9 ipMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=CsggJypPIk8DH++cGPuBgHz39PHWizXtY9sP11HHgsI=; b=PymglgXt9mdtqflLypLAA/hrqoh+f5IoH6U9v+IOa7mVu6Cys/lUxG3aPZzbH10DP0 SrDjXg9eZhXAhMtEKdzKpBevphOMsva3gzQsC+3mDVlgJtLhQuZ2dUiBe/hvo00qlj0s 9kSbyx9KJ6EJmSHaHmp+qinvA+miL6DHq2PRD8vvjVP68Jx601csdIy97ndEsv3m71cA 6Xw/pCKtTjwbUzH5Gduc4zrIeTef+mkH8xcHsHuakFqppxjaJdHuFhKrvcWRn6oct+zd E4Tgj1lrEZfk45/tiqui1okyFcEvP2bvIgVgzHWUe4YtqmmV1/dLnkV7mdrsHCHzoxcp TP+A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l11si81658pgp.438.2019.05.14.15.24.28; Tue, 14 May 2019 15:24:46 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727149AbfENWVc (ORCPT + 99 others); Tue, 14 May 2019 18:21:32 -0400 Received: from mga11.intel.com ([192.55.52.93]:1878 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726248AbfENWVa (ORCPT ); Tue, 14 May 2019 18:21:30 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 May 2019 15:21:29 -0700 X-ExtLoop1: 1 Received: from unknown (HELO localhost.localdomain) ([10.232.112.69]) by orsmga005.jf.intel.com with ESMTP; 14 May 2019 15:21:28 -0700 Date: Tue, 14 May 2019 16:16:09 -0600 From: Keith Busch To: "Rafael J. Wysocki" Cc: Mario Limonciello , Christoph Hellwig , Keith Busch , Sagi Grimberg , linux-nvme , Linux Kernel Mailing List , Linux PM , Kai-Heng Feng Subject: Re: [PATCH] nvme/pci: Use host managed power state for suspend Message-ID: <20190514221609.GC19977@localhost.localdomain> References: <20190510212937.11661-1-keith.busch@intel.com> <0080aaff18e5445dabca509d4113eca8@AUSX13MPC105.AMER.DELL.COM> <955722d8fc16425dbba0698c4806f8fd@AUSX13MPC105.AMER.DELL.COM> <20190513143741.GA25500@lst.de> <20190513145522.GA15421@localhost.localdomain> <20190513150458.GA15437@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 14, 2019 at 10:04:22AM +0200, Rafael J. Wysocki wrote: > On Mon, May 13, 2019 at 5:10 PM Keith Busch wrote: > > > > On Mon, May 13, 2019 at 03:05:42PM +0000, Mario.Limonciello@dell.com wrote: > > > This system power state - suspend to idle is going to freeze threads. > > > But we're talking a multi threaded kernel. Can't there be a timing problem going > > > on then too? With a disk flush being active in one task and the other task trying > > > to put the disk into the deepest power state. If you don't freeze the queues how > > > can you guarantee that didn't happen? > > > > But if an active data flush task is running, then we're not idle and > > shouldn't go to low power. > > To be entirely precise, system suspend prevents user space from > running while it is in progress. It doesn't do that to kernel > threads, at least not by default, though, so if there is a kernel > thread flushing the data, it needs to be stopped or suspended somehow > directly in the system suspend path. [And yes, system suspend (or > hibernation) may take place at any time so long as all user space can > be prevented from running then (by means of the tasks freezer).] > > However, freezing the queues from a driver ->suspend callback doesn't > help in general and the reason why is hibernation. Roughly speaking, > hibernation works in two steps, the first of which creates a snapshot > image of system memory and the second one writes that image to > persistent storage. Devices are resumed between the two steps in > order to make it possible to do the write, but that would unfreeze the > queues and let the data flusher run. If it runs, it may cause the > memory snapshot image that has just been created to become outdated > and restoring the system memory contents from that image going forward > may cause corruption to occur. > > Thus freezing the queues from a driver ->suspend callback should not > be relied on for correctness if the same callback is used for system > suspend and hibernation, which is the case here. If doing that > prevents the system from crashing, it is critical to find out why IMO, > as that may very well indicate a broader issue, not necessarily in the > driver itself. > > But note that even if the device turns out to behave oddly, it still > needs to be handled, unless it may be prevented from shipping to users > in that shape. If it ships, users will face the odd behavior anyway. Thanks for all the information. I'll take another shot at this, should have it posted tomorrow. It's mostly not a problem to ensure enqueued and dispatched requests are completed before returning from our suspend callback. I originally had that behavior and backed it out when I thought it wasn't necessary. So I'll reintroduce that. I'm not sure yet how we may handle kernel tasks that are about to read/write pages, but haven't yet enqueued their requests. IO timeouts, shold they occur, have some problems here, so I'll need to send prep patches to address a few issues with that.