From patchwork Tue Dec 4 17:59:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10712317 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 A3D8D13BF for ; Tue, 4 Dec 2018 17:59:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95FA12C02D for ; Tue, 4 Dec 2018 17:59:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 899BE2C0C8; Tue, 4 Dec 2018 17:59:13 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 171222C02D for ; Tue, 4 Dec 2018 17:59:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726127AbeLDR7M (ORCPT ); Tue, 4 Dec 2018 12:59:12 -0500 Received: from mail-yb1-f194.google.com ([209.85.219.194]:39008 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726038AbeLDR7M (ORCPT ); Tue, 4 Dec 2018 12:59:12 -0500 Received: by mail-yb1-f194.google.com with SMTP id w17-v6so7217460ybl.6 for ; Tue, 04 Dec 2018 09:59:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=GFRyB8WkMSBI/UzgnLSEUSzwykBa1/VmJFQwo6jL5ps=; b=svWp2f/DNZnSOduhqoSqjkvStyuP1fTnOaQ3UOKbUDJSbwPjMmJCg5pJkz2vmcBOGo O43tabssgDGvukYxVsSQF8lwS2dALF6h6S3z8XtMItkldLgma0sp3AbNYwYN3XOi8c1V RciyXu+1DjFd429uSLdc+MmmuiS6TFQ5znT8pjsj8cm8dQkx84pExPFWRYFvDVeVaHdO SSE+hO6B39v4770Su8nhcqFCQDGtBoqWKLo8rzzOFVUuzHVx4lFBdo9/1uWi0uRMcC9w Rdl+xcroOc3Rg9SB66UHKMW6R1Eg79KKI03hoeQsf2DaGGM6j5WvS/nk0Ua5dZwpg5Aw RgcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=GFRyB8WkMSBI/UzgnLSEUSzwykBa1/VmJFQwo6jL5ps=; b=EsX7qEbh61jbEX0IaTZ5ncCKaAqN8ljFoTlwf/RTCqu6g+tWSmdX+Oy99m4JbMR0bV YDct2kxYTOS4GeOzJ1daUZBeRurxdClP2AfklPnkbwmNTI3rdjpB2jjWwM46XFcQahqH 56S0FnQhymCQZJ6/wQY2NZZA5rPfVjwUYf/gxgKDoqVFTi9xedTefjUqZuXqrA8t0yL6 gyKaWMB2FGV+98dOQYrcoXBzWWebtol72Fwy/5B+n+SD4t5+vJe1M10CqjCSf47e0uUe QUXoQRSjlzqIo1zToVPHbyh8VoU3YQcS3UK7MIrMPS741M6TwIaCIkuFrkZXd6lRrKDL 30mQ== X-Gm-Message-State: AA+aEWbmU7mRusoiZQj9oKqPSh5DKBYJmgO6ERhBn4iB0wS88ecCu6pM Qro1iyIHUnL6tw3BwEHe7XVBtA== X-Google-Smtp-Source: AFSGD/VAiCgXAj+RCav6dU+9tRippvnvINtHqIRHT2oJik5oHpflibd3P0JarNGa2IkVjxCXcAQjVQ== X-Received: by 2002:a25:1043:: with SMTP id 64-v6mr20119581ybq.159.1543946351200; Tue, 04 Dec 2018 09:59:11 -0800 (PST) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id d4sm7002555ywe.104.2018.12.04.09.59.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 09:59:10 -0800 (PST) From: Josef Bacik To: kernel-team@fb.com, linux-block@vger.kernel.org, axboe@kernel.dk Subject: [PATCH 1/3] block: add rq_qos_wait to rq_qos Date: Tue, 4 Dec 2018 12:59:02 -0500 Message-Id: <20181204175904.8486-2-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181204175904.8486-1-josef@toxicpanda.com> References: <20181204175904.8486-1-josef@toxicpanda.com> 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 Originally when I split out the common code from blk-wbt into rq_qos I left the wbt_wait() where it was and simply copied and modified it slightly to work for io-latency. However they are both basically the same thing, and as time has gone on wbt_wait() has ended up much smarter and kinder than it was when I copied it into io-latency, which means io-latency has lost out on these improvements. Since they are the same thing essentially except for a few minor things, create rq_qos_wait() that replicates what wbt_wait() currently does with callbacks that can be passed in for the snowflakes to do their own thing as appropriate. Signed-off-by: Josef Bacik --- block/blk-rq-qos.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ block/blk-rq-qos.h | 6 ++++ 2 files changed, 92 insertions(+) diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c index 80f603b76f61..e932ef9d2718 100644 --- a/block/blk-rq-qos.c +++ b/block/blk-rq-qos.c @@ -176,6 +176,92 @@ void rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle) rq_depth_calc_max_depth(rqd); } +struct rq_qos_wait_data { + struct wait_queue_entry wq; + struct task_struct *task; + struct rq_wait *rqw; + acquire_inflight_cb_t *cb; + void *private_data; + bool got_token; +}; + +static int rq_qos_wake_function(struct wait_queue_entry *curr, + unsigned int mode, int wake_flags, void *key) +{ + struct rq_qos_wait_data *data = container_of(curr, + struct rq_qos_wait_data, + wq); + + /* + * If we fail to get a budget, return -1 to interrupt the wake up loop + * in __wake_up_common. + */ + if (!data->cb(data->rqw, data->private_data)) + return -1; + + data->got_token = true; + list_del_init(&curr->entry); + wake_up_process(data->task); + return 1; +} + +/** + * rq_qos_wait - throttle on a rqw if we need to + * @private_data - caller provided specific data + * @acquire_inflight_cb - inc the rqw->inflight counter if we can + * @cleanup_cb - the callback to cleanup in case we race with a waker + * + * This provides a uniform place for the rq_qos users to do their throttling. + * Since you can end up with a lot of things sleeping at once, this manages the + * waking up based on the resources available. The acquire_inflight_cb should + * inc the rqw->inflight if we have the ability to do so, or return false if not + * and then we will sleep until the room becomes available. + * + * cleanup_cb is in case that we race with a waker and need to cleanup the + * inflight count accordingly. + */ +void rq_qos_wait(struct rq_wait *rqw, void *private_data, + acquire_inflight_cb_t *acquire_inflight_cb, + cleanup_cb_t *cleanup_cb) +{ + struct rq_qos_wait_data data = { + .wq = { + .func = rq_qos_wake_function, + .entry = LIST_HEAD_INIT(data.wq.entry), + }, + .task = current, + .rqw = rqw, + .cb = acquire_inflight_cb, + .private_data = private_data, + }; + bool has_sleeper; + + has_sleeper = wq_has_sleeper(&rqw->wait); + if (!has_sleeper && acquire_inflight_cb(rqw, private_data)) + return; + + prepare_to_wait_exclusive(&rqw->wait, &data.wq, TASK_UNINTERRUPTIBLE); + do { + if (data.got_token) + break; + if (!has_sleeper && acquire_inflight_cb(rqw, private_data)) { + finish_wait(&rqw->wait, &data.wq); + + /* + * We raced with wbt_wake_function() getting a token, + * which means we now have two. Put our local token + * and wake anyone else potentially waiting for one. + */ + if (data.got_token) + cleanup_cb(rqw, private_data); + break; + } + io_schedule(); + has_sleeper = false; + } while (1); + finish_wait(&rqw->wait, &data.wq); +} + void rq_qos_exit(struct request_queue *q) { while (q->rq_qos) { diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h index 6e09e98b93ea..8678875de420 100644 --- a/block/blk-rq-qos.h +++ b/block/blk-rq-qos.h @@ -93,6 +93,12 @@ static inline void rq_qos_del(struct request_queue *q, struct rq_qos *rqos) } } +typedef bool (acquire_inflight_cb_t)(struct rq_wait *rqw, void *private_data); +typedef void (cleanup_cb_t)(struct rq_wait *rqw, void *private_data); + +void rq_qos_wait(struct rq_wait *rqw, void *private_data, + acquire_inflight_cb_t *acquire_inflight_cb, + cleanup_cb_t *cleanup_cb); bool rq_wait_inc_below(struct rq_wait *rq_wait, unsigned int limit); void rq_depth_scale_up(struct rq_depth *rqd); void rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle); From patchwork Tue Dec 4 17:59:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10712319 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 2364313A4 for ; Tue, 4 Dec 2018 17:59:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 183192C02D for ; Tue, 4 Dec 2018 17:59:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C7F42C0C8; Tue, 4 Dec 2018 17:59:15 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 A2E442C02D for ; Tue, 4 Dec 2018 17:59:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726061AbeLDR7O (ORCPT ); Tue, 4 Dec 2018 12:59:14 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:39389 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726038AbeLDR7O (ORCPT ); Tue, 4 Dec 2018 12:59:14 -0500 Received: by mail-yw1-f67.google.com with SMTP id j6so7330711ywj.6 for ; Tue, 04 Dec 2018 09:59:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=aoM0TGuZdp2Tjvb7I0kBQhIGZxUwsDSKQW86qy2szPk=; b=S5rd6I7jHTaarpyfr8mcIvoFPC2cOWEf+cQsr4bnICCzzpjhPL/AO4iKuP+Be0D5ZA k3j1YP6HHgij49JuhO8ayDixwI/hRl8ZKqGUQ+VPcqtqgRxA6lFIa5JdeOPYLC1QteAp DiDMKbwVFMcpst/S7JFGE2wJj2plN78CvBVLnvOEYllGwoOevD8gGd/uI5GDXKM8PWBM Dt+9R84g7+Q2KYY8O0X25Jx8YMJ2uf+sUebbXSOKCTHm6cj5GCuCgHD+zzFSHVwt84wm CgIThjpzw1H1W2hpfAsWf8fCk+/uKYPy+ud+WC2mOAs1ZKjKP99/gKWwg6j5MLkSFGq/ mZnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=aoM0TGuZdp2Tjvb7I0kBQhIGZxUwsDSKQW86qy2szPk=; b=hbZm4ucLyI+jrAgnI2LDknPl5aP3OjXEkpPxZnfBemSa+IiogjqIA06HccceDiB7jl JHBoUjJhCgwxFDkZYI1yhSn6h5eLSFUp26t+6kVT3GgagrHGrquHaDkkmrKA59y5xcVY u7C4zxT5mPk4r8nAgMejLFMXSlLxqs6ypUqEfE8q71ZQHMdqI+t3tfU435G/psmIIuuQ 9J35+IyKBtoS+Akn65+PHuvcV6+pOPQIkha+aBr973CPaVoCUWbmhw8JssH7LrcAloZv J7rhCBkwRQuFCKeXAX0dPakdbZzONoLYWBa7Hhj4mT32UOreJQCfsyo69vokQtRVFMHL smHg== X-Gm-Message-State: AA+aEWZ/qN/2quOS05eNtn+7VIC+SZjFpBVogenT4ETtaAd66jcU+DSH CcgiuYo3iy6vlECmPW0zkoZ5sg== X-Google-Smtp-Source: AFSGD/Xua5rv9FOdDQPLwlFvO1o+ohmDveZaOQ2CpoKMEV6kyRbphIrmmmYkNdkuYDKJ4fopiMjZlQ== X-Received: by 2002:a0d:cf04:: with SMTP id r4mr6211889ywd.283.1543946352786; Tue, 04 Dec 2018 09:59:12 -0800 (PST) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id x135-v6sm6322998ywg.68.2018.12.04.09.59.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 09:59:12 -0800 (PST) From: Josef Bacik To: kernel-team@fb.com, linux-block@vger.kernel.org, axboe@kernel.dk Subject: [PATCH 2/3] block: convert wbt_wait() to use rq_qos_wait() Date: Tue, 4 Dec 2018 12:59:03 -0500 Message-Id: <20181204175904.8486-3-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181204175904.8486-1-josef@toxicpanda.com> References: <20181204175904.8486-1-josef@toxicpanda.com> 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 Now that we have rq_qos_wait() in place, convert wbt_wait() over to using it with it's specific callbacks. Signed-off-by: Josef Bacik --- block/blk-wbt.c | 65 ++++++++++----------------------------------------------- 1 file changed, 11 insertions(+), 54 deletions(-) diff --git a/block/blk-wbt.c b/block/blk-wbt.c index d051ebfb4852..40207edd1d89 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -489,31 +489,21 @@ static inline unsigned int get_limit(struct rq_wb *rwb, unsigned long rw) } struct wbt_wait_data { - struct wait_queue_entry wq; - struct task_struct *task; struct rq_wb *rwb; - struct rq_wait *rqw; + enum wbt_flags wb_acct; unsigned long rw; - bool got_token; }; -static int wbt_wake_function(struct wait_queue_entry *curr, unsigned int mode, - int wake_flags, void *key) +static bool wbt_inflight_cb(struct rq_wait *rqw, void *private_data) { - struct wbt_wait_data *data = container_of(curr, struct wbt_wait_data, - wq); - - /* - * If we fail to get a budget, return -1 to interrupt the wake up - * loop in __wake_up_common. - */ - if (!rq_wait_inc_below(data->rqw, get_limit(data->rwb, data->rw))) - return -1; + struct wbt_wait_data *data = private_data; + return rq_wait_inc_below(rqw, get_limit(data->rwb, data->rw)); +} - data->got_token = true; - list_del_init(&curr->entry); - wake_up_process(data->task); - return 1; +static void wbt_cleanup_cb(struct rq_wait *rqw, void *private_data) +{ + struct wbt_wait_data *data = private_data; + wbt_rqw_done(data->rwb, rqw, data->wb_acct); } /* @@ -525,45 +515,12 @@ static void __wbt_wait(struct rq_wb *rwb, enum wbt_flags wb_acct, { struct rq_wait *rqw = get_rq_wait(rwb, wb_acct); struct wbt_wait_data data = { - .wq = { - .func = wbt_wake_function, - .entry = LIST_HEAD_INIT(data.wq.entry), - }, - .task = current, .rwb = rwb, - .rqw = rqw, + .wb_acct = wb_acct, .rw = rw, }; - bool has_sleeper; - - has_sleeper = wq_has_sleeper(&rqw->wait); - if (!has_sleeper && rq_wait_inc_below(rqw, get_limit(rwb, rw))) - return; - - prepare_to_wait_exclusive(&rqw->wait, &data.wq, TASK_UNINTERRUPTIBLE); - do { - if (data.got_token) - break; - - if (!has_sleeper && - rq_wait_inc_below(rqw, get_limit(rwb, rw))) { - finish_wait(&rqw->wait, &data.wq); - - /* - * We raced with wbt_wake_function() getting a token, - * which means we now have two. Put our local token - * and wake anyone else potentially waiting for one. - */ - if (data.got_token) - wbt_rqw_done(rwb, rqw, wb_acct); - break; - } - - io_schedule(); - has_sleeper = false; - } while (1); - finish_wait(&rqw->wait, &data.wq); + rq_qos_wait(rqw, &data, wbt_inflight_cb, wbt_cleanup_cb); } static inline bool wbt_should_throttle(struct rq_wb *rwb, struct bio *bio) From patchwork Tue Dec 4 17:59:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10712321 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 42F1313BF for ; Tue, 4 Dec 2018 17:59:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 377742C02D for ; Tue, 4 Dec 2018 17:59:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C0D32C0C8; Tue, 4 Dec 2018 17:59:16 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 CE74E2C02D for ; Tue, 4 Dec 2018 17:59:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726172AbeLDR7P (ORCPT ); Tue, 4 Dec 2018 12:59:15 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:40611 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726038AbeLDR7P (ORCPT ); Tue, 4 Dec 2018 12:59:15 -0500 Received: by mail-yw1-f68.google.com with SMTP id r130so7335324ywg.7 for ; Tue, 04 Dec 2018 09:59:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=JFjeMkzQnvt65WEN65pEXIU7mUFoHGUxDprOdq3GdMc=; b=Z10VZR7AltmR99fgUrNlg7bMI3R9gi2H3SSZBRJEKakqVFueUr6VWNK0CpNsadNlkJ l1u5vIud9MGgCKTnFiUPxcNmKkVFYcZoilEUbHJW0PNs/aYoUpUS9hlSpQ+mhpX24gDX b05KfLrdYJA+uuHg+HitxUMXsI3xgzZ1SI34o1fXn7MUsxyFeUwxuqy2IDPZCTAbJ9BK jAX7ld/f4Y5fwUmOSXTY4zLDg9yiml/pDKArAG/rUAn3JeD6EXjhHv2zCBcJdh1vd8Di FctCRroPbro3Qh0LWELdH6GONz/1zp0SwrXUdenewsd5CPDBko7HlC34k+YrPY/rZ+ln XICw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=JFjeMkzQnvt65WEN65pEXIU7mUFoHGUxDprOdq3GdMc=; b=qdNGJRBKEgm05nYpvHcYTPwbiIeLdH6+mlc7p3QgybisVQoqkHqwMy9U75MOxDkxSA elmT/FlH6mYXUqEdmdTUavmUGAU92J08K8WVBfakqtr6NUXqYxF9TPpdoVGikulSEIzh IXXG6k5Gz4VRSxnhCa1WISyaVy4w71pCQd6slaP++e4LdjRTjfNa+k5YOxz9xZ9arMe7 eD99Exd+DVgRfrboL/W6LOMYBkQDC19DLvJ2kBP2AVYIuwTyHOugThxZYyxp818rerfT GodrJtRI0VEay98aAxfQdqZYMxoYyH8zWCZUQM6o7wXactv6/uZfBDpzDdkTFxCP+T9i RjoQ== X-Gm-Message-State: AA+aEWb8/rVPlG7z22/2UPw1weCZPDVnfgNJfpRpfeqH7YIXHJPnyCUA G3tAzhYYv3reyLn8CLK9xnBAQw== X-Google-Smtp-Source: AFSGD/UAf0G0QCSBSR3IpX5Fvy4gTOjixuaZogDnHc5nBdYFjZAiNrihVNryutKt9zU9jeIk6z7CTQ== X-Received: by 2002:a81:ac44:: with SMTP id z4mr21124157ywj.178.1543946354278; Tue, 04 Dec 2018 09:59:14 -0800 (PST) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id m67sm5397105ywb.54.2018.12.04.09.59.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 09:59:13 -0800 (PST) From: Josef Bacik To: kernel-team@fb.com, linux-block@vger.kernel.org, axboe@kernel.dk Subject: [PATCH 3/3] block: convert io-latency to use rq_qos_wait Date: Tue, 4 Dec 2018 12:59:04 -0500 Message-Id: <20181204175904.8486-4-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181204175904.8486-1-josef@toxicpanda.com> References: <20181204175904.8486-1-josef@toxicpanda.com> 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 Now that we have this common helper, convert io-latency over to use it as well. Signed-off-by: Josef Bacik --- block/blk-iolatency.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index 5f7f1773be61..ac74b41f4131 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -262,15 +262,15 @@ static inline void iolat_update_total_lat_avg(struct iolatency_grp *iolat, stat->rqs.mean); } -static inline bool iolatency_may_queue(struct iolatency_grp *iolat, - wait_queue_entry_t *wait, - bool first_block) +static void iolat_cleanup_cb(struct rq_wait *rqw, void *private_data) { - struct rq_wait *rqw = &iolat->rq_wait; + atomic_dec(&rqw->inflight); + wake_up(&rqw->wait); +} - if (first_block && waitqueue_active(&rqw->wait) && - rqw->wait.head.next != &wait->entry) - return false; +static bool iolat_acquire_inflight(struct rq_wait *rqw, void *private_data) +{ + struct iolatency_grp *iolat = private_data; return rq_wait_inc_below(rqw, iolat->rq_depth.max_depth); } @@ -281,8 +281,6 @@ static void __blkcg_iolatency_throttle(struct rq_qos *rqos, { struct rq_wait *rqw = &iolat->rq_wait; unsigned use_delay = atomic_read(&lat_to_blkg(iolat)->use_delay); - DEFINE_WAIT(wait); - bool first_block = true; if (use_delay) blkcg_schedule_throttle(rqos->q, use_memdelay); @@ -299,20 +297,7 @@ static void __blkcg_iolatency_throttle(struct rq_qos *rqos, return; } - if (iolatency_may_queue(iolat, &wait, first_block)) - return; - - do { - prepare_to_wait_exclusive(&rqw->wait, &wait, - TASK_UNINTERRUPTIBLE); - - if (iolatency_may_queue(iolat, &wait, first_block)) - break; - first_block = false; - io_schedule(); - } while (1); - - finish_wait(&rqw->wait, &wait); + rq_qos_wait(rqw, iolat, iolat_acquire_inflight, iolat_cleanup_cb); } #define SCALE_DOWN_FACTOR 2