Received: from eggs.gnu.org ([2001:4830:134:3::10]:45229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bw462-0004mt-BH for qemu-devel@nongnu.org; Mon, 17 Oct 2016 05:20:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bw45z-0003pD-02 for qemu-devel@nongnu.org; Mon, 17 Oct 2016 05:20:38 -0400 Received: from lhrrgout.huawei.com ([194.213.3.17]:4138) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1bw45y-0003n5-LV for qemu-devel@nongnu.org; Mon, 17 Oct 2016 05:20:34 -0400 References: <1474014817-41572-1-git-send-email-pradeep.jagadeesh@huawei.com> From: Pradeep Jagadeesh Message-ID: <161e02dc-2358-cd62-46b8-5f5d4eca6b67@huawei.com> Date: Mon, 17 Oct 2016 11:19:11 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3] fsdev: add IO throttle support to fsdev devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alberto Garcia , Pradeep Jagadeesh , "Aneesh Kumar K.V" , Greg Kurz Cc: qemu-devel@nongnu.org, Claudio Fontana Hi Alberto, > On Fri 16 Sep 2016 10:33:36 AM CEST, Pradeep Jagadeesh wrote: > > Hi, > > first of all, sorry for the late reply! Here are my comments: > >> --- a/fsdev/qemu-fsdev-opts.c >> +++ b/fsdev/qemu-fsdev-opts.c >> @@ -37,6 +37,82 @@ static QemuOptsList qemu_fsdev_opts = { >> }, { >> .name = "sock_fd", >> .type = QEMU_OPT_NUMBER, >> + }, { >> + .name = "throttling.iops-total", >> + .type = QEMU_OPT_NUMBER, >> + .help = "limit total I/O operations per second", > /*...*/ >> + },{ >> + .name = "throttling.iops-size", >> + .type = QEMU_OPT_NUMBER, >> + .help = "when limiting by iops max size of an I/O in bytes", > > It would be nice if we could factor these so we don't have to have them > twice in the code. I think it should be doable with qemu_opts_append(). > > It can be done later in a separate patch if you prefer. > >> +typedef struct FsThrottle { >> + ThrottleState ts; >> + ThrottleTimers tt; >> + AioContext *aioctx; >> + ThrottleConfig cfg; >> + bool enabled; >> + CoQueue throttled_reqs[2]; >> + unsigned pending_reqs[2]; >> + bool any_timer_armed[2]; >> + QemuMutex lock; >> +} FsThrottle; > > You based your implementation on block/throttle-groups.c. I think yours > can be made simpler because one of the problems with mine is that it > needs to support multiple parallel I/O operations on the same throttling > group, and that's why the locking rules are more complex. With a single > user per ThrottleConfig this is not necessary. > > Have you checked if you really need them? My impression is that you > might be able to get rid of the 'lock', 'any_timer_armed' and > 'pending_reqs' fields. > > Please check commit 76f4afb40fa076ed23fe0ab42c7a768ddb71123f to see how > was the transition from single-drive throttling to group throttling, > specifically the bdrv_io_limits_intercept() function. You will see that > it was simpler. I tried removing the lock, I got into rcu issues, and the qemu hangs. Once I put them back, it works fine. -Pradeep > >> @@ -436,8 +436,8 @@ static ssize_t local_pwritev(FsContext *ctx, V9fsFidOpenState *fs, >> const struct iovec *iov, >> int iovcnt, off_t offset) >> { >> - ssize_t ret >> -; >> + ssize_t ret; >> + > > This could go to a separate patch, but I'm fine if you include it in > this one. > >> @@ -1213,6 +1213,8 @@ static int local_parse_opts(QemuOpts *opts, struct FsDriverEntry *fse) >> const char *sec_model = qemu_opt_get(opts, "security_model"); >> const char *path = qemu_opt_get(opts, "path"); >> >> + FsThrottle *fst = &fse->fst; >> + > > I'd remove the empty line between the declarations of 'path' and 'fst', > however... > >> if (!sec_model) { >> error_report("Security model not specified, local fs needs security model"); >> error_printf("valid options are:" >> @@ -1240,6 +1242,11 @@ static int local_parse_opts(QemuOpts *opts, struct FsDriverEntry *fse) >> error_report("fsdev: No path specified"); >> return -1; >> } >> + >> + if (fsdev_throttle_configure_iolimits(opts, fst) < 0) { >> + return -1; >> + } > > ...you don't need to declare fst here, you could also pass &fse->fst > directly. > > Berto >