From: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
To: Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 v2 1/2] fs/aio: restore the AIO ring of the dumped size in a pseudosuper VE
Date: Mon, 16 Nov 2026 11:31:49 +0100 [thread overview]
Message-ID: <20261116-pr-ptikhomirov-vstor-154129-aio-pseudosuper-ring-v2-1-532d149b4bd7@virtuozzo.com> (raw)
In-Reply-To: <20261116-pr-ptikhomirov-vstor-154129-aio-pseudosuper-ring-v2-0-532d149b4bd7@virtuozzo.com>
io_setup() makes the ring at least 4 events per possible CPU of the
node. The ring is mapped into the task memory, and CRIU restores it with
io_setup() and moves the new mapping to the address of the old one, so
it needs a ring of the same size. On a node with more possible CPUs it
gets a bigger ring, and the restore fails. E.g. io_setup(1) makes a
ring of one page, 127 events, on 4 CPUs, and of two pages, 255 events,
on 16 CPUs.
Skip the CPU heuristic while the VE is pseudosuper, which it is almost
only for the restore. Keep the other adjustments, the doubling and the
rounding up to pages: they don't depend on the node, and the queue depth
CRIU estimates from the dumped ring already offsets them, so the restore
gets the ring of the dumped size.
A ring restored below the minimum of this node doesn't use the per-CPU
caches of free slots: it has too few slots to spare for them.
https://virtuozzo.atlassian.net/browse/VSTOR-154129
Feature: ve: CRIU support
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
---
fs/aio.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/fs/aio.c b/fs/aio.c
index 901cb622fe2c4..2ff1758507611 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -109,6 +109,7 @@ struct kioctx {
* counter at a time:
*/
unsigned req_batch;
+ bool no_percpu_reqs;
/*
* This is what userspace passed to io_setup(), it's not used for
* anything but counting against the global max_reqs quota.
@@ -745,6 +746,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
struct mm_struct *mm = current->mm;
struct kioctx *ctx;
struct ve_struct *ve = get_exec_env();
+ bool no_percpu_reqs = false;
int err = -ENOMEM;
/*
@@ -761,8 +763,16 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
* and unavailable, double nr_events so userspace sees what they
* expected: additionally, we move req_batch slots to/from percpu
* counters at a time, so make sure that isn't 0:
+ *
+ * CRIU restores a ring with io_setup() and needs the size it had on
+ * dump, which can be below the minimum of this node due to the CPU
+ * heuristic below, so skip the heuristic on restore. Such a ring
+ * can't spare slots for the percpu counters, so it doesn't use them.
*/
- nr_events = max(nr_events, num_possible_cpus() * 4);
+ if (ve_is_super(ve) || !ve->is_pseudosuper)
+ nr_events = max(nr_events, num_possible_cpus() * 4);
+ else if (nr_events < num_possible_cpus() * 4)
+ no_percpu_reqs = true;
nr_events *= 2;
/* Prevent overflows */
@@ -779,6 +789,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
return ERR_PTR(-ENOMEM);
ctx->max_reqs = max_reqs;
+ ctx->no_percpu_reqs = no_percpu_reqs;
ctx->ve = get_ve(ve);
spin_lock_init(&ctx->ctx_lock);
@@ -950,6 +961,11 @@ static void put_reqs_available(struct kioctx *ctx, unsigned nr)
struct kioctx_cpu *kcpu;
unsigned long flags;
+ if (ctx->no_percpu_reqs) {
+ atomic_add(nr, &ctx->reqs_available);
+ return;
+ }
+
local_irq_save(flags);
kcpu = this_cpu_ptr(ctx->cpu);
kcpu->reqs_available += nr;
@@ -968,6 +984,9 @@ static bool __get_reqs_available(struct kioctx *ctx)
bool ret = false;
unsigned long flags;
+ if (ctx->no_percpu_reqs)
+ return atomic_dec_if_positive(&ctx->reqs_available) >= 0;
+
local_irq_save(flags);
kcpu = this_cpu_ptr(ctx->cpu);
if (!kcpu->reqs_available) {
--
2.56.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-16 10:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 10:31 [Devel] [PATCH hci-8.1 v2 0/2] fs/aio: fix CT migration with AIO to a node with more CPUs Pavel Tikhomirov
2026-11-16 10:31 ` Pavel Tikhomirov [this message]
2026-11-16 10:36 ` [Devel] [PATCH hci-8.1 v2 1/2] fs/aio: restore the AIO ring of the dumped size in a pseudosuper VE no-reply
2026-11-16 10:31 ` [Devel] [PATCH hci-8.1 v2 2/2] selftests/ve: check the AIO ring " Pavel Tikhomirov
2026-11-16 10:38 ` no-reply
2026-11-16 16:55 ` [Devel] [PATCH hci-8.1 v2 0/2] fs/aio: fix CT migration with AIO to a node with more CPUs Konstantin Khorenko
2026-11-16 16:55 ` Konstantin Khorenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116-pr-ptikhomirov-vstor-154129-aio-pseudosuper-ring-v2-1-532d149b4bd7@virtuozzo.com \
--to=ptikhomirov@virtuozzo.com \
--cc=devel@openvz.org \
--cc=khorenko@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.