From patchwork Mon Sep 17 20:15:22 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: 10603369 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 D32FE17D5 for ; Mon, 17 Sep 2018 20:15:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6FE92A319 for ; Mon, 17 Sep 2018 20:15:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BADA02A36B; Mon, 17 Sep 2018 20:15:56 +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 4B0D82A319 for ; Mon, 17 Sep 2018 20:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728367AbeIRBos (ORCPT ); Mon, 17 Sep 2018 21:44:48 -0400 Received: from out002.mailprotect.be ([83.217.72.86]:47339 "EHLO out002.mailprotect.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728190AbeIRBor (ORCPT ); Mon, 17 Sep 2018 21:44:47 -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:References :In-Reply-To:Message-Id:Date:Subject:Cc:To:From:reply-to:sender:bcc: content-type; bh=hPBHDdQ4zc/ToeByF0/bA5P1Aew+hsnfgnX4xwmEa7Y=; b=CcvQ4+83esuM UegYBYXQmChiYRNqQHCNtNLlHYUMV8mIobQ5QbVLb/wid3Sdq61khH2lNPlCzy03UuhP8Mt2L9yDR I4NeBz7b9B0nxTTO6iiancORrjdjOH3iGzCYYPTNPJn6CYYbQF6u7zrOmwgIo09C4TsJy3mQia4HU z6Jaq37YjDWTHii1QsuJ9NwLs3EVjzvnMjyJpfqdfcjx87uISFq95TXHR39YTm8+2he+FHZjIS+oL hwR3Yk2u7GD+52VmhGyuTXXdOCyHUlFRoDSsk+DWGyK/hTbcpA4N9d1Wbwb+Wx7W4UXk6YIB5qJ1L 0/DIA1qe2yR1kCDsHcjx+w==; Received: from smtp-auth.mailprotect.be ([178.208.39.155]) by com-mpt-out002.mailprotect.be with esmtp (Exim 4.89) (envelope-from ) id 1g1zvs-000AbJ-Tq; Mon, 17 Sep 2018 22:15:45 +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 B7562C05E8; Mon, 17 Sep 2018 22:15:42 +0200 (CEST) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , "Martin K . Petersen" , Ming Lei , Jianchao Wang , Hannes Reinecke , Johannes Thumshirn , Alan Stern Subject: [PATCH v7 3/6] block: Split blk_pm_add_request() and blk_pm_put_request() Date: Mon, 17 Sep 2018 13:15:22 -0700 Message-Id: <20180917201525.26570-4-bvanassche@acm.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180917201525.26570-1-bvanassche@acm.org> References: <20180917201525.26570-1-bvanassche@acm.org> MIME-Version: 1.0 X-Originating-IP: 178.208.39.155 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.02) X-Recommended-Action: accept X-Filter-ID: EX5BVjFpneJeBchSMxfU5vKEERwIwuhpycxnPSNDImZ602E9L7XzfQH6nu9C/Fh9KJzpNe6xgvOx q3u0UDjvO1tLifGj39bI0bcPyaJsYTaOqZpfO3PVJjdazu3l6Zm3CrxbKqqxVb1b/D8J7mjn9ilV cTJ2PzGYt6C/dLANFNC9eBrzwetNxEiSKDRqnfKMQkpuFrILVINAX/FRRdHr3yMkm/wiy60JYYB9 uF3NAa1Nk+QSW7RQzhAm/KStEkEjjSySmAlj1sIqwltPBEyYUVLTnxxOo8WXP45qj8D05F0GHXoj JzNBXYf7J9S/MLPJeew2ZFB8y+lVHOa/te45KxSlpp6gZ+aErQiqwMtUFszQVi7RanL0btaq9sjs zlKiU2Itm39BdCc4FEP6OrUewqv6w78MMfzJ6uM1Dx2pwT02MDKcFISveXb58XwZtRhJgl8rTFVB NUayNYioUf/jaE247rv5gOouGP1S4LTxm4IZFA/pqiraPmJuCFYZ26hO7EGy2J9deH+T4rZSs7oC RIPDMAUwB3tfqejuvISV+XjlglRDk9cYQA7KMLDnGOJ56M3u8AeQ7v6DJmTHsjuH4LUFg/fIocum fy7nlHshc2SgmIw4GlBMUJ5tmacVuNcCPzQwTZWk0LJpbj+275alueD3JP1TZOF7xCxMWPmtOrbT CB+y1/kdwCnPNDJxz2+x6xRwdbvGEYre0mvLtHe5W25UyoBaNn4UvUDGLvKfl0KGpS+C6BPAIEs8 PiiVo3EbitwIT4UrixKuvc+2A6GMBkdUx4wVmRRdNAC1VnP7J7aoVa9N1B5a7HEax6KxZtwTGplH cpVCCoX989hgB8R+yBmSQTjEQ7K8L3YnE3YXQesAIdpmOmCdfONBfm+H9NFGmOjvZljSaHUXzvZB t27HIYClx2Bar4+r4X5TDyO6kqbM3QJ+eNps9QCtxORQfh9Yfx+Rej4UShefUo+T6F7dpBEVniih uDwEGDcmr6e3OPT2vpc7DTbK73Uczg4v9NX8rPLdozHWIiOOCs6xV5cNI9rjKZFiIhhyep0/irEk 3vsdozEXh3VBsuhhhCkkaEnDctgzcDoFd+96Xw4QUNtTnUwBPU16Lw5D6FTpb21Gqfi2k7UH+ny4 RtGQXC7V+qNljyRU1W7yjZrVL5fyX8Ze+edKEy7bP5gIt23U7fpAnNNaaosU2ouOolw9cp1YOrL6 hzzbxWjrOIv823OwuoSzwXBEn95eECKi3gxjzXac2CLtWj2g85mHRkOrwPj67JONTwwsq9jL8kDn CowdqqA99B1XEvFeCBHWER7m/Rdd97Q= 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 Move the pm_request_resume() and pm_runtime_mark_last_busy() calls into two new functions and thereby separate legacy block layer code from code that works for both the legacy block layer and blk-mq. A later patch will add calls to the new functions in the blk-mq code. Signed-off-by: Bart Van Assche Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: Ming Lei Cc: Jianchao Wang Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Alan Stern --- block/blk-core.c | 1 + block/blk-pm.h | 36 +++++++++++++++++++++++++++++++----- block/elevator.c | 1 + 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 1a691f5269bb..fd91e9bf2893 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1744,6 +1744,7 @@ void __blk_put_request(struct request_queue *q, struct request *req) blk_req_zone_write_unlock(req); blk_pm_put_request(req); + blk_pm_mark_last_busy(req); elv_completed_request(q, req); diff --git a/block/blk-pm.h b/block/blk-pm.h index 1ffc8ef203ec..a8564ea72a41 100644 --- a/block/blk-pm.h +++ b/block/blk-pm.h @@ -6,8 +6,23 @@ #include #ifdef CONFIG_PM +static inline void blk_pm_request_resume(struct request_queue *q) +{ + if (q->dev && (q->rpm_status == RPM_SUSPENDED || + q->rpm_status == RPM_SUSPENDING)) + pm_request_resume(q->dev); +} + +static inline void blk_pm_mark_last_busy(struct request *rq) +{ + if (rq->q->dev && !(rq->rq_flags & RQF_PM)) + pm_runtime_mark_last_busy(rq->q->dev); +} + static inline void blk_pm_requeue_request(struct request *rq) { + lockdep_assert_held(rq->q->queue_lock); + if (rq->q->dev && !(rq->rq_flags & RQF_PM)) rq->q->nr_pending--; } @@ -15,17 +30,28 @@ static inline void blk_pm_requeue_request(struct request *rq) static inline void blk_pm_add_request(struct request_queue *q, struct request *rq) { - if (q->dev && !(rq->rq_flags & RQF_PM) && q->nr_pending++ == 0 && - (q->rpm_status == RPM_SUSPENDED || q->rpm_status == RPM_SUSPENDING)) - pm_request_resume(q->dev); + lockdep_assert_held(q->queue_lock); + + if (q->dev && !(rq->rq_flags & RQF_PM)) + q->nr_pending++; } static inline void blk_pm_put_request(struct request *rq) { - if (rq->q->dev && !(rq->rq_flags & RQF_PM) && !--rq->q->nr_pending) - pm_runtime_mark_last_busy(rq->q->dev); + lockdep_assert_held(rq->q->queue_lock); + + if (rq->q->dev && !(rq->rq_flags & RQF_PM)) + --rq->q->nr_pending; } #else +static inline void blk_pm_request_resume(struct request_queue *q) +{ +} + +static inline void blk_pm_mark_last_busy(struct request *rq) +{ +} + static inline void blk_pm_requeue_request(struct request *rq) { } diff --git a/block/elevator.c b/block/elevator.c index e18ac68626e3..1c992bf6cfb1 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -601,6 +601,7 @@ void __elv_add_request(struct request_queue *q, struct request *rq, int where) trace_block_rq_insert(q, rq); blk_pm_add_request(q, rq); + blk_pm_request_resume(q); rq->q = q;