[Devel] [PATCH RHEL8 COMMIT] aio: ioctl(VE_AIO_IOC_WAIT_ACTIVE) in-flight reqs counting fix
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Apr 30 12:15:51 MSK 2021
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.23
------>
commit 4e9bdf495ab82108c683c1205386234068443401
Author: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
Date: Fri Apr 30 12:15:51 2021 +0300
aio: ioctl(VE_AIO_IOC_WAIT_ACTIVE) in-flight reqs counting fix
We have to take into account percpu part of reqs_available
counter on struct kioctx.
Fixes: f5d1279 ("ve/aio: Add a handle to checkpoint/restore AIO context")
https://jira.sw.ru/browse/PSBM-128710
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
Reviewed-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
fs/aio.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/fs/aio.c b/fs/aio.c
index 7c547247b056..4ae0cac0f3ff 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1898,9 +1898,19 @@ static bool has_reqs_active(struct kioctx *ctx)
{
unsigned long flags;
unsigned nr;
+ int cpu;
+ unsigned reqs_avail_batch = 0;
spin_lock_irqsave(&ctx->completion_lock, flags);
- nr = (ctx->nr_events - 1) - atomic_read(&ctx->reqs_available);
+ /*
+ * See get_reqs_available()/put_reqs_available() about
+ * how reqs_available distributed between atomic
+ * ctx->reqs_available and percpu ctx->cpu reqs_available.
+ */
+ for_each_possible_cpu(cpu)
+ reqs_avail_batch += per_cpu_ptr(ctx->cpu, cpu)->reqs_available;
+ nr = ctx->nr_events - 1;
+ nr -= atomic_read(&ctx->reqs_available) + reqs_avail_batch;
nr -= ctx->completed_events;
spin_unlock_irqrestore(&ctx->completion_lock, flags);
More information about the Devel
mailing list