From patchwork Wed Sep 26 21:01:05 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: 10616819 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 B250C180E for ; Wed, 26 Sep 2018 21:01:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4F122B84D for ; Wed, 26 Sep 2018 21:01:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A324C2B87C; Wed, 26 Sep 2018 21:01:47 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 214A12B84D for ; Wed, 26 Sep 2018 21:01:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726778AbeI0DQe (ORCPT ); Wed, 26 Sep 2018 23:16:34 -0400 Received: from com-out001.mailprotect.be ([83.217.72.83]:46583 "EHLO com-out001.mailprotect.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727131AbeI0DQe (ORCPT ); Wed, 26 Sep 2018 23:16:34 -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=v4hELt/yIVDIucauBFCBmaAn4vItU8CslCk+rcK/oVE=; b=B1rxZI9z7ESZ 1THNwMY/h1/X1/5D2izIv4QHAkmQGb7jKmT8sWnLPwxGh3KudJ3S/BiqWTapLbVwPxbgkNUgkH2X3 J5OP5RAo6qSrFifl1UrD4JM6I/1fTBNiZTzT8ezqtoV9ct2fVD1Na/rNGFLDrrZGCd57BH9Ma8inm 9bleR2Vgev7ZPHbWWaVGmKlc1xDMNsmypS6YoNH1tttxtdELXzCuGgtpyu/nWKi/G0AzZVKCwrI0i ygCSlnqZv3Z/5Rue85kstFYoLbChzebcl4p7WU4wNotRsKAoYfp7wsh1CvDYrAx7StlrBD/ujBWoK cJsAm8SF9P4HgHlkLm1JOw==; Received: from smtp-auth.mailprotect.be ([178.208.39.159]) by com-mpt-out001.mailprotect.be with esmtp (Exim 4.89) (envelope-from ) id 1g5GwE-000Ch9-M6; Wed, 26 Sep 2018 23:01:39 +0200 Received: from desktop-bart.svl.corp.google.com (unknown [104.133.8.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 30979C0511; Wed, 26 Sep 2018 23:01:24 +0200 (CEST) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , "Martin K . Petersen" , Jianchao Wang , Hannes Reinecke , Johannes Thumshirn , Alan Stern Subject: [PATCH v11 3/8] block: Split blk_pm_add_request() and blk_pm_put_request() Date: Wed, 26 Sep 2018 14:01:05 -0700 Message-Id: <20180926210110.20362-4-bvanassche@acm.org> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog In-Reply-To: <20180926210110.20362-1-bvanassche@acm.org> References: <20180926210110.20362-1-bvanassche@acm.org> 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.02) X-Recommended-Action: accept X-Filter-ID: EX5BVjFpneJeBchSMxfU5l9p2RykhusDbB+PzKuxLKl602E9L7XzfQH6nu9C/Fh9KJzpNe6xgvOx q3u0UDjvO1tLifGj39bI0bcPyaJsYTaOqZpfO3PVJjdazu3l6Zm3CrxbKqqxVb1b/D8J7mjn9ilV cTJ2PzGYt6C/dLANFNC9eBrzwetNxEiSKDRqnfKMQkpuFrILVINAX/FRRdHr3yMkm/wiy60JYYB9 uF3NAa2g1pZKwiWCImQQO2sJllH2SGIdHuYbIJvBnZmUT8jII/ODWQ+TOBzfO9ZWChwqLrRtQGa8 rfVqcnGFOMq2D/9ZqvrTdEmAmAz04LoQQdgc4aYARgjnuHaYoBczpAr33GpjBMLLaM2KtLCkia0v MuKlBxbS7+nVR7qfIyvZKnVQNeKVse1sVhWabI0/+PN3sILfno2VGCQBTzV5700QuyS2nB91/WsJ i78ADPGYDhYdq/2p7chPBr9Suc7XsfyyMyRMs3x71t5DHCETMYRS4C1JUuIF2yn03s7TS3ghm2vg BtmmngDbiCqrDh/638bDFveIcHlK5Xt74cx9xpLTapBBIWJTOvft3Y9D3D5je6Fi1aSZOeuLeApg TfFSSpne6KJYbuQrf2k+DKrsx9JdAdbfrp4mNrOT5C/nYMDaWYUKFPMY4F2VSLjcAX5wkBjuRtGq r3wBwEeX6Ai55FPRpzhbMjMm/D2rEPnNAuCCnt9B9yxnMyDcssgJk4TFOnIdiKwgr/U0flMcy2Vi /IcBgY4a/OOwajxbqjCef6Smuows/rE2LVWBPF9IzF6zg4ZEKfAjd0WvgVSVkM9+5JhInxQze/Qk ioJxyfHmUVFdcKIc0G60KJiD32bchiuBPQIfMzbOudhi11hQc8pktdd7tiISsjH69DXQvqXCOgKH wqsoNN4F1lU/G5bsD6sx+ZbP+ok6iq4BARkMc7GL4L2H5LT1WkE9KY9LcGdyxgcUHrldmFBrMyfp YuyanAZpMXssfrVFND0q3lxSCbF8ydR7MXDsLJ9uRReSv8I4hhmhe4tLeYtGRDz0z+XkjgXpC0sZ BDKEikTSRw8lxi7VJgFyVuZVskP7V5Y77AVSbw8rDRvcV+uO5TcDeKjrEmYPn2IVWRvMxBtjAPy6 eLm/JRe7n5dpYhai3vEoMrcP3ydYA96eq5Klr/Cq7U2vgXLghPzhXKb8XG910biZEcomWehz4u8s zDg6HYuTCyYgL61SIkBTYTWFca/UjxrIgBCE9DdH/TDk2EPy497nssgnoMkIb3rMFAyxyz4M82bX +iXOYfJTgg== 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 Reviewed-by: Ming Lei Reviewed-by: Christoph Hellwig Cc: Martin K. Petersen 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;