From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965819AbcIWB0k (ORCPT ); Thu, 22 Sep 2016 21:26:40 -0400 Received: from mga04.intel.com ([192.55.52.120]:31041 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965686AbcIWB0j (ORCPT ); Thu, 22 Sep 2016 21:26:39 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,380,1470726000"; d="scan'208";a="172186468" Subject: Re: Should drivers like nvme let userspace control their latency via dev_pm_qos? To: Andy Lutomirski References: Cc: "linux-pm@vger.kernel.org" , Keith Busch , Jens Axboe , linux-nvme@lists.infradead.org, "linux-kernel@vger.kernel.org" , J Freyensee , Christoph Hellwig From: "Rafael J. Wysocki" Organization: Intel Technology Poland Sp. z o. o., KRS 101882, ul. Slowackiego 173, 80-298 Gdansk Message-ID: Date: Fri, 23 Sep 2016 03:26:32 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/16/2016 5:26 PM, Andy Lutomirski wrote: > I'm adding power management to the nvme driver, and I'm exposing > exactly one knob via sysfs: the maximum permissible latency. This > isn't a power domain issue, and it has no dependencies -- it's > literally just the maximum latency that the driver may impose on I/O > for power saving purposes. > > ISTM userspace should be able to specify its own latency tolerance in > a uniform way, and dev_pm_qos seems like the natural interface for > this, except that I cannot find a single instance in the tree of *any* > driver using it via the notifier mechanism. That's because the notifier mechanism is only used for the "resume latency" type of constraints. > I can find two drivers that do it using dev_pm_qos_expose_latency_tolerance(), and both are LPSS drivers? That's correct. Nobody else has used it so far. :-) > So: should I be exposing .set_latency_tolerance() or should I just use > a custom sysfs attribute? Or both? dev_pm_qos_expose_latency_tolerance() adds a single latency tolerance request object to the device and exposes a knob in user space by which that request object can be controlled. There may be more latency tolerance request objects for the same device if kernel code adds them. The effective latency tolerance is the minimum of all those requests and the callback is invoked every time that effective value changes. This also is described in the last section of Documentation/power/pm_qos_interface.txt (note that if the .set_latency_tolerance callback is present at the device registration time already, the latency tolerance sysfs attribute will be exposed automatically by the driver core). If that mechanism is suitable for the use case in question, I'd just use it. Thanks, Rafael