]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
io_uring: place fixed tables under memcg limits
authorPavel Begunkov <asml.silence@gmail.com>
Mon, 13 Sep 2021 15:13:30 +0000 (09:13 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Sep 2021 11:41:48 +0000 (13:41 +0200)
commit 0bea96f59ba40e63c0ae93ad6a02417b95f22f4d upstream.

Fixed tables may be large enough, place all of them together with
allocated tags under memcg limits.

Cc: stable@vger.kernel.org
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/b3ac9f5da9821bb59837b5fe25e8ef4be982218c.1629451684.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/io_uring.c

index 58ae2eab99efa2448cd5f1c668cd82f87819cffc..a1b6d338e3a0b77121f6d69866b8afffdf5ca1d7 100644 (file)
@@ -7195,11 +7195,11 @@ static struct io_rsrc_data *io_rsrc_data_alloc(struct io_ring_ctx *ctx,
 {
        struct io_rsrc_data *data;
 
-       data = kzalloc(sizeof(*data), GFP_KERNEL);
+       data = kzalloc(sizeof(*data), GFP_KERNEL_ACCOUNT);
        if (!data)
                return NULL;
 
-       data->tags = kvcalloc(nr, sizeof(*data->tags), GFP_KERNEL);
+       data->tags = kvcalloc(nr, sizeof(*data->tags), GFP_KERNEL_ACCOUNT);
        if (!data->tags) {
                kfree(data);
                return NULL;
@@ -7477,7 +7477,7 @@ static bool io_alloc_file_tables(struct io_file_table *table, unsigned nr_files)
 {
        unsigned i, nr_tables = DIV_ROUND_UP(nr_files, IORING_MAX_FILES_TABLE);
 
-       table->files = kcalloc(nr_tables, sizeof(*table->files), GFP_KERNEL);
+       table->files = kcalloc(nr_tables, sizeof(*table->files), GFP_KERNEL_ACCOUNT);
        if (!table->files)
                return false;
 
@@ -7485,7 +7485,7 @@ static bool io_alloc_file_tables(struct io_file_table *table, unsigned nr_files)
                unsigned int this_files = min(nr_files, IORING_MAX_FILES_TABLE);
 
                table->files[i] = kcalloc(this_files, sizeof(*table->files[i]),
-                                       GFP_KERNEL);
+                                       GFP_KERNEL_ACCOUNT);
                if (!table->files[i])
                        break;
                nr_files -= this_files;