Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6081908yba; Tue, 14 May 2019 01:06:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzg93ikJV8dHOFhd3AJtxjfMHfidmeEirSuxDOXeqX8g8BwzjkAcIKbYHGvNuAC2wl1SCA X-Received: by 2002:a62:b517:: with SMTP id y23mr33768946pfe.182.1557821160721; Tue, 14 May 2019 01:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557821160; cv=none; d=google.com; s=arc-20160816; b=miqveKUmKcU5B0hc6vELGB3YGEuMkzi3Rof7tVybY+R1/S85FqUWnBtQLpQmRj/yAV CvBJkLE8ASS2m83IiCUuXEQIt8YSttH6K6z7CZv7tFXkAhvh8ijgy1yEtZz16LYHDGom Ds1fbq9Hzv5i68BrdnMAVnWIWT3kURWRb+H0hteZ5X44cXkF9dU41EbvnuHs5LzQmZIf uPvZtiKLL5dbG57IuZDtiWDk0sP9LrpbFXkhusLK1xVN4ZldzuE0R8KzXwy1uO+E/vvN jQOm0QAiSonzfGZVSaxCcTMwDuC44Vxvn8rLlQ7EGHDNnH0IlyEcC2hXvv4QDFPnlbaQ rubA== 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 :in-reply-to:references:mime-version; bh=kB17CNIkNudo9lQqUE06/YkvGevRbJzz0AoPJPb6ktc=; b=Fj36cNEtf4dIbOSxqC4smkIFJFevJyc2aBxEeYsY/3M5GaA2vMAhzg6VXM1jOztxjm cQ1WPyG5z6dYKemfSIbTiDKXJd8HXrI0uXwYTuI4KJbXw505apbNM5xjNS+RrjEjBxfg N3yNX+BMzL2qAphbn7whKSO9rHLBLT0g1iXHM9AcAWFboRlWjjxP64aZ+BaQ8ly5bN0D 0jR6esK2DvTbea2HYnDYHsoEHr6N3530puTqCerzpponiSQQTYAwm2VOeifJ9ONZ9AVf F+KNTxXNhs1sf0Pn8HakQDiQZy3O+slkT8wJW0iAZLgmzAsAiG7sxIDxlmx6usj6NI2N nlcg== 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 d71si19735122pga.487.2019.05.14.01.05.44; Tue, 14 May 2019 01:06:00 -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 S1726107AbfENIEg (ORCPT + 99 others); Tue, 14 May 2019 04:04:36 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:46342 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725866AbfENIEf (ORCPT ); Tue, 14 May 2019 04:04:35 -0400 Received: by mail-ot1-f68.google.com with SMTP id j49so6720805otc.13; Tue, 14 May 2019 01:04:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kB17CNIkNudo9lQqUE06/YkvGevRbJzz0AoPJPb6ktc=; b=Z+HjzeLhr0Dqle03P0O/1srlROaWqziSFK4q78z4SOkQaRR1v5+3EiYgyR7pxtafXm WK2tdbr1ofhyHluvIPiN6bByHsuVFwA0iL+xSjp/ZEPVls6HBbndwscET8eYWwDeFTUj TlCGUk6Y0P51eW6yYTPe4oBjHaQ33pghQ88z0kHIKS2m05++SCVmj6O3VfqQGaWCJGxY fUv6btXYZmQi1Mt225fkX0QwDqdWMdI13AA2uhr9SvVJ+VWghqyTS5O66HN+IM/npiO1 6GH3EsXNAOnz9ux59nxIZwm7GrvzT0gPJoHY7+J4L7d8wTU8YRqPuMBfyzzGFBbx0DGb XvlQ== X-Gm-Message-State: APjAAAXhj1w/ku1PCqdgvzVN/D8YI19rrKKbLZJFdJBiy5s2kYcy2MFt SLvnBMAecax2k9PM0uSCtax3Pqii+gxN/zjUinE= X-Received: by 2002:a9d:5912:: with SMTP id t18mr14859091oth.252.1557821074817; Tue, 14 May 2019 01:04:34 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <20190513150458.GA15437@localhost.localdomain> From: "Rafael J. Wysocki" Date: Tue, 14 May 2019 10:04:22 +0200 Message-ID: Subject: Re: [PATCH] nvme/pci: Use host managed power state for suspend To: Keith Busch Cc: Mario Limonciello , Christoph Hellwig , Keith Busch , Sagi Grimberg , linux-nvme , "Rafael J. Wysocki" , Linux Kernel Mailing List , Linux PM , Kai-Heng Feng 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 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.