From patchwork Sun Jul 2 10:06:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manos Pitsidianakis X-Patchwork-Id: 9821103 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B2039602F0 for ; Sun, 2 Jul 2017 10:09:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A09A3274D0 for ; Sun, 2 Jul 2017 10:09:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9459E27D4D; Sun, 2 Jul 2017 10:09:23 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E67E8274D0 for ; Sun, 2 Jul 2017 10:09:22 +0000 (UTC) Received: from localhost ([::1]:57396 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dRbog-0008OW-5c for patchwork-qemu-devel@patchwork.kernel.org; Sun, 02 Jul 2017 06:09:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dRbnR-0008M9-0t for qemu-devel@nongnu.org; Sun, 02 Jul 2017 06:08:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dRbnP-00026P-SE for qemu-devel@nongnu.org; Sun, 02 Jul 2017 06:08:04 -0400 Received: from smtp1.ntua.gr ([2001:648:2000:de::183]:58864) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dRbnM-000246-Ra; Sun, 02 Jul 2017 06:08:01 -0400 Received: from mail.ntua.gr (ppp005055127131.access.hol.gr [5.55.127.131]) (authenticated bits=0) by smtp1.ntua.gr (8.15.2/8.15.2) with ESMTPSA id v62A7TYZ064060 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 2 Jul 2017 13:07:29 +0300 (EEST) (envelope-from el13635@mail.ntua.gr) X-Authentication-Warning: smtp1.ntua.gr: Host ppp005055127131.access.hol.gr [5.55.127.131] claimed to be mail.ntua.gr From: Manos Pitsidianakis To: qemu-devel Date: Sun, 2 Jul 2017 13:06:46 +0300 Message-Id: <20170702100646.20656-3-el13635@mail.ntua.gr> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170702100646.20656-1-el13635@mail.ntua.gr> References: <20170702100646.20656-1-el13635@mail.ntua.gr> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:648:2000:de::183 Subject: [Qemu-devel] [PATCH 2/2] block: remove timer canceling in throttle_config() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , Stefan Hajnoczi , qemu-block Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP throttle_config() cancels the timers of the calling BlockBackend. This doesn't make sense because other BlockBackends in the group remain untouched. There's no need to cancel the timers in the one specific BlockBackend so let's not do that. Throttled requests will run as scheduled and future requests will follow the new configuration. This also allows a throttle group's configuration to be changed even when it has no members. Signed-off-by: Manos Pitsidianakis Reviewed-by: Stefan Hajnoczi --- block/throttle-groups.c | 10 +--------- fsdev/qemu-fsdev-throttle.c | 2 +- include/qemu/throttle.h | 1 - tests/test-throttle.c | 4 ++-- util/throttle.c | 14 -------------- 5 files changed, 4 insertions(+), 27 deletions(-) diff --git a/block/throttle-groups.c b/block/throttle-groups.c index 71af3f72a1..890bfded3f 100644 --- a/block/throttle-groups.c +++ b/block/throttle-groups.c @@ -426,18 +426,10 @@ void throttle_group_restart_blk(BlockBackend *blk) void throttle_group_config(BlockBackend *blk, ThrottleConfig *cfg) { BlockBackendPublic *blkp = blk_get_public(blk); - ThrottleTimers *tt = &blkp->throttle_timers; ThrottleState *ts = blkp->throttle_state; ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts); qemu_mutex_lock(&tg->lock); - /* throttle_config() cancels the timers */ - if (timer_pending(tt->timers[0])) { - tg->any_timer_armed[0] = false; - } - if (timer_pending(tt->timers[1])) { - tg->any_timer_armed[1] = false; - } - throttle_config(ts, tg->clock_type, tt, cfg); + throttle_config(ts, tg->clock_type, cfg); qemu_mutex_unlock(&tg->lock); throttle_group_restart_blk(blk); diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c index 453fb1efde..49eebb5412 100644 --- a/fsdev/qemu-fsdev-throttle.c +++ b/fsdev/qemu-fsdev-throttle.c @@ -86,7 +86,7 @@ void fsdev_throttle_init(FsThrottle *fst) fsdev_throttle_read_timer_cb, fsdev_throttle_write_timer_cb, fst); - throttle_config(&fst->ts, QEMU_CLOCK_REALTIME, &fst->tt, &fst->cfg); + throttle_config(&fst->ts, QEMU_CLOCK_REALTIME, &fst->cfg); qemu_co_queue_init(&fst->throttled_reqs[0]); qemu_co_queue_init(&fst->throttled_reqs[1]); } diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h index 8d2fd77d2b..d056008c18 100644 --- a/include/qemu/throttle.h +++ b/include/qemu/throttle.h @@ -140,7 +140,6 @@ bool throttle_is_valid(ThrottleConfig *cfg, Error **errp); void throttle_config(ThrottleState *ts, QEMUClockType clock_type, - ThrottleTimers *tt, ThrottleConfig *cfg); void throttle_get_config(ThrottleState *ts, ThrottleConfig *cfg); diff --git a/tests/test-throttle.c b/tests/test-throttle.c index 2d9cd4647c..768f11dfed 100644 --- a/tests/test-throttle.c +++ b/tests/test-throttle.c @@ -228,7 +228,7 @@ static void test_config_functions(void) read_timer_cb, write_timer_cb, &ts); /* structure reset by throttle_init previous_leak should be null */ g_assert(!ts.previous_leak); - throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &tt, &orig_cfg); + throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &orig_cfg); /* has previous leak been initialized by throttle_config ? */ g_assert(ts.previous_leak); @@ -486,7 +486,7 @@ static bool do_test_accounting(bool is_ops, /* are we testing bps or ops */ throttle_init(&ts); throttle_timers_init(&tt, ctx, QEMU_CLOCK_VIRTUAL, read_timer_cb, write_timer_cb, &ts); - throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &tt, &cfg); + throttle_config(&ts, QEMU_CLOCK_VIRTUAL, &cfg); /* account a read */ throttle_account(&ts, false, size); diff --git a/util/throttle.c b/util/throttle.c index 3e948071dd..b2a52b8b34 100644 --- a/util/throttle.c +++ b/util/throttle.c @@ -388,24 +388,14 @@ static void throttle_unfix_bucket(LeakyBucket *bkt) } } -/* take care of canceling a timer */ -static void throttle_cancel_timer(QEMUTimer *timer) -{ - assert(timer != NULL); - - timer_del(timer); -} - /* Used to configure the throttle * * @ts: the throttle state we are working on * @clock_type: the group's clock_type - * @tt: the throttle timers we use in this aio context * @cfg: the config to set */ void throttle_config(ThrottleState *ts, QEMUClockType clock_type, - ThrottleTimers *tt, ThrottleConfig *cfg) { int i; @@ -417,10 +407,6 @@ void throttle_config(ThrottleState *ts, } ts->previous_leak = qemu_clock_get_ns(clock_type); - - for (i = 0; i < 2; i++) { - throttle_cancel_timer(tt->timers[i]); - } } /* used to get config