From patchwork Tue Sep 18 20:58:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10604869 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 512A0157B for ; Tue, 18 Sep 2018 20:59:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FC0F2BEAB for ; Tue, 18 Sep 2018 20:59:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 340F32BEB3; Tue, 18 Sep 2018 20:59:25 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5308B2BEAC for ; Tue, 18 Sep 2018 20:59:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729705AbeISCdq (ORCPT ); Tue, 18 Sep 2018 22:33:46 -0400 Received: from out002.mailprotect.be ([83.217.72.86]:45897 "EHLO out002.mailprotect.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729693AbeISCdp (ORCPT ); Tue, 18 Sep 2018 22:33:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mailprotect.be; s=mail; h=Content-Transfer-Encoding:MIME-Version:Message-Id :Date:Subject:Cc:To:From:reply-to:sender:bcc:in-reply-to:references: content-type; bh=ho+jWSfTYW2pJnOJztAuYTuGJqtxGYfvQP3zxpwaRW0=; b=TAlwyw9yVjZ9 vmTkVPWnYSZ+unmX3Y0/cgiAZWPRWkJ2jRGTMXHH7fqFZEQW11vHfr0wbza9CXo2BM+RB8M5qZRb1 4j7qleYfXA/g1ipesUW5A9DNWMJ99bOoQskNKMdlHA8/Mm0vMpPgUAP+1RBJ4u4LxSb0Djvd0it3s e6cbAIil45pFqPXL/kVQZG9CbPPQpDpB0iD893eLH2rrFDmROmtnzbiFjDTHKHHXX09ueK0CQXLVZ UsZi81Ftr7cGdsUbCeucm49gN9BSCvCLdduRuTk6UfBml62Wi2D0DmSn4CphXwQatS3doOGk04MHA E31EgrCFIOxjTl9XWxLHhg==; Received: from smtp-auth.mailprotect.be ([178.208.39.159]) by com-mpt-out002.mailprotect.be with esmtp (Exim 4.89) (envelope-from ) id 1g2N5c-0007p3-Pg; Tue, 18 Sep 2018 22:59:21 +0200 Received: from asus.hsd1.ca.comcast.net (c-174-62-111-89.hsd1.ca.comcast.net [174.62.111.89]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-auth.mailprotect.be (Postfix) with ESMTPSA id 2689BC0906; Tue, 18 Sep 2018 22:59:18 +0200 (CEST) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche Subject: [PATCH v8 0/8] blk-mq: Implement runtime power management Date: Tue, 18 Sep 2018 13:58:55 -0700 Message-Id: <20180918205903.15516-1-bvanassche@acm.org> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-Originating-IP: 178.208.39.159 X-SpamExperts-Domain: mailprotect.be X-SpamExperts-Username: 178.208.39.128/27 Authentication-Results: mailprotect.be; auth=pass smtp.auth=178.208.39.128/27@mailprotect.be X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.09) X-Recommended-Action: accept X-Filter-ID: EX5BVjFpneJeBchSMxfU5sRPsU5pU7Tu0B5whbYdUBV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eYNYaA4ur2/Is= X-Report-Abuse-To: spam@com-mpt-mgt001.mailprotect.be Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hello Jens, One of the pieces that is missing before blk-mq can be made the default is implementing runtime power management support for blk-mq. This patch series not only implements runtime power management for blk-mq but also fixes a starvation issue in the power management code for the legacy block layer. Please consider this patch series for the upstream kernel. Thanks, Bart. Changes compared to v7: - Addressed Jianchao's feedback about patch "Make blk_get_request() block for non-PM requests while suspended". - Added two new patches - one that documents the functions that iterate over requests and one that introduces a new function that iterates over all requests associated with a queue. Changes compared to v6: - Left out the patches that split RQF_PREEMPT in three flags. - Left out the patch that introduces the SCSI device state SDEV_SUSPENDED. - Left out the patch that introduces blk_pm_runtime_exit(). - Restored the patch that changes the PREEMPT_ONLY flag into a counter. Changes compared to v5: - Introduced a new flag RQF_DV that replaces RQF_PREEMPT for SCSI domain validation. - Introduced a new request queue state QUEUE_FLAG_DV_ONLY for SCSI domain validation. - Instead of using SDEV_QUIESCE for both runtime suspend and SCSI domain validation, use that state for domain validation only and introduce a new state for runtime suspend, namely SDEV_QUIESCE. - Reallow system suspend during SCSI domain validation. - Moved the runtime resume call from the request allocation code into blk_queue_enter(). - Instead of relying on q_usage_counter, iterate over the tag set to determine whether or not any requests are in flight. Changes compared to v4: - Dropped the patches "Give RQF_PREEMPT back its original meaning" and "Serialize queue freezing and blk_pre_runtime_suspend()". - Replaced "percpu_ref_read()" with "percpu_is_in_use()". - Inserted pm_request_resume() calls in the block layer request allocation code such that the context that submits a request no longer has to call pm_runtime_get(). Changes compared to v3: - Avoid adverse interactions between system-wide suspend/resume and runtime power management by changing the PREEMPT_ONLY flag into a counter. - Give RQF_PREEMPT back its original meaning, namely that it is only set for ide_preempt requests. - Remove the flag BLK_MQ_REQ_PREEMPT. - Removed the pm_request_resume() call. Changes compared to v2: - Fixed the build for CONFIG_BLOCK=n. - Added a patch that introduces percpu_ref_read() in the percpu-counter code. - Added a patch that makes it easier to detect missing pm_runtime_get*() calls. - Addressed Jianchao's feedback including the comment about runtime overhead of switching a per-cpu counter to atomic mode. Changes compared to v1: - Moved the runtime power management code into a separate file. - Addressed Ming's feedback. Bart Van Assche (6): block: Move power management code into a new source file block, scsi: Change the preempt-only flag into a counter block: Split blk_pm_add_request() and blk_pm_put_request() block: Schedule runtime resume earlier block: Make blk_get_request() block for non-PM requests while suspended blk-mq: Enable support for runtime power management Bart Van Assche (8): blk-mq: Document the functions that iterate over requests blk-mq: Introduce blk_mq_queue_rq_iter() block: Move power management code into a new source file block, scsi: Change the preempt-only flag into a counter block: Split blk_pm_add_request() and blk_pm_put_request() block: Schedule runtime resume earlier block: Make blk_get_request() block for non-PM requests while suspended blk-mq: Enable support for runtime power management block/Kconfig | 3 + block/Makefile | 1 + block/blk-core.c | 271 +++++----------------------------------- block/blk-mq-debugfs.c | 10 +- block/blk-mq-tag.c | 72 ++++++++++- block/blk-mq-tag.h | 2 + block/blk-mq.c | 2 + block/blk-pm.c | 242 +++++++++++++++++++++++++++++++++++ block/blk-pm.h | 69 ++++++++++ block/elevator.c | 22 +--- drivers/scsi/scsi_lib.c | 11 +- drivers/scsi/scsi_pm.c | 1 + drivers/scsi/sd.c | 1 + drivers/scsi/sr.c | 1 + include/linux/blk-pm.h | 24 ++++ include/linux/blkdev.h | 37 ++---- 16 files changed, 472 insertions(+), 297 deletions(-) create mode 100644 block/blk-pm.c create mode 100644 block/blk-pm.h create mode 100644 include/linux/blk-pm.h