]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit - fs/aio.c
fs: aio: fix the increment of aio-nr and counting against aio-max-nr
authorMauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
Wed, 5 Jul 2017 13:53:16 +0000 (10:53 -0300)
committerSeth Forshee <seth.forshee@canonical.com>
Fri, 22 Sep 2017 17:04:16 +0000 (12:04 -0500)
commit69f491013a2479074ac40c8f3232eb961c53e3fd
tree4ff6bdc30ff9f45a8877779dba1145c7c23193e5
parent675f3cdd55f5966700857392440aec0d357dc82c
fs: aio: fix the increment of aio-nr and counting against aio-max-nr

BugLink: http://bugs.launchpad.net/bugs/1718397
Currently, aio-nr is incremented in steps of 'num_possible_cpus() * 8'
for io_setup(nr_events, ..) with 'nr_events < num_possible_cpus() * 4':

    ioctx_alloc()
    ...
        nr_events = max(nr_events, num_possible_cpus() * 4);
        nr_events *= 2;
    ...
        ctx->max_reqs = nr_events;
    ...
        aio_nr += ctx->max_reqs;
    ....

This limits the number of aio contexts actually available to much less
than aio-max-nr, and is increasingly worse with greater number of CPUs.

For example, with 64 CPUs, only 256 aio contexts are actually available
(with aio-max-nr = 65536) because the increment is 512 in that scenario.

Note: 65536 [max aio contexts] / (64*4*2) [increment per aio context]
is 128, but make it 256 (double) as counting against 'aio-max-nr * 2':

    ioctx_alloc()
    ...
        if (aio_nr + nr_events > (aio_max_nr * 2UL) ||
        ...
            goto err_ctx;
    ...

This patch uses the original value of nr_events (from userspace) to
increment aio-nr and count against aio-max-nr, which resolves those.

Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
Reported-by: Lekshmi C. Pillai <lekshmi.cpillai@in.ibm.com>
Tested-by: Lekshmi C. Pillai <lekshmi.cpillai@in.ibm.com>
Tested-by: Paul Nguyen <nguyenp@us.ibm.com>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
(cherry picked from commit 2a8a98673c13cb2a61a6476153acf8344adfa992)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
fs/aio.c