From: Greg Kroah-Hartman Date: Tue, 27 Feb 2024 09:24:00 +0000 (+0100) Subject: 6.1-stable patches X-Git-Tag: v4.19.308~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f4b225be082a9ac73f96e939bd3436522869bc26;p=thirdparty%2Fkernel%2Fstable-queue.git 6.1-stable patches added patches: fs-aio-restrict-kiocb_set_cancel_fn-to-i-o-submitted-via-libaio.patch mm-damon-reclaim-fix-quota-stauts-loss-due-to-online-tunings.patch --- diff --git a/queue-6.1/fs-aio-restrict-kiocb_set_cancel_fn-to-i-o-submitted-via-libaio.patch b/queue-6.1/fs-aio-restrict-kiocb_set_cancel_fn-to-i-o-submitted-via-libaio.patch new file mode 100644 index 00000000000..5023aaf9be4 --- /dev/null +++ b/queue-6.1/fs-aio-restrict-kiocb_set_cancel_fn-to-i-o-submitted-via-libaio.patch @@ -0,0 +1,84 @@ +From b820de741ae48ccf50dd95e297889c286ff4f760 Mon Sep 17 00:00:00 2001 +From: Bart Van Assche +Date: Thu, 15 Feb 2024 12:47:38 -0800 +Subject: fs/aio: Restrict kiocb_set_cancel_fn() to I/O submitted via libaio + +From: Bart Van Assche + +commit b820de741ae48ccf50dd95e297889c286ff4f760 upstream. + +If kiocb_set_cancel_fn() is called for I/O submitted via io_uring, the +following kernel warning appears: + +WARNING: CPU: 3 PID: 368 at fs/aio.c:598 kiocb_set_cancel_fn+0x9c/0xa8 +Call trace: + kiocb_set_cancel_fn+0x9c/0xa8 + ffs_epfile_read_iter+0x144/0x1d0 + io_read+0x19c/0x498 + io_issue_sqe+0x118/0x27c + io_submit_sqes+0x25c/0x5fc + __arm64_sys_io_uring_enter+0x104/0xab0 + invoke_syscall+0x58/0x11c + el0_svc_common+0xb4/0xf4 + do_el0_svc+0x2c/0xb0 + el0_svc+0x2c/0xa4 + el0t_64_sync_handler+0x68/0xb4 + el0t_64_sync+0x1a4/0x1a8 + +Fix this by setting the IOCB_AIO_RW flag for read and write I/O that is +submitted by libaio. + +Suggested-by: Jens Axboe +Cc: Christoph Hellwig +Cc: Avi Kivity +Cc: Sandeep Dhavale +Cc: Jens Axboe +Cc: Greg Kroah-Hartman +Cc: Kent Overstreet +Cc: stable@vger.kernel.org +Signed-off-by: Bart Van Assche +Link: https://lore.kernel.org/r/20240215204739.2677806-2-bvanassche@acm.org +Signed-off-by: Christian Brauner +Signed-off-by: Bart Van Assche +Signed-off-by: Greg Kroah-Hartman +--- + fs/aio.c | 9 ++++++++- + include/linux/fs.h | 2 ++ + 2 files changed, 10 insertions(+), 1 deletion(-) + +--- a/fs/aio.c ++++ b/fs/aio.c +@@ -595,6 +595,13 @@ void kiocb_set_cancel_fn(struct kiocb *i + struct kioctx *ctx = req->ki_ctx; + unsigned long flags; + ++ /* ++ * kiocb didn't come from aio or is neither a read nor a write, hence ++ * ignore it. ++ */ ++ if (!(iocb->ki_flags & IOCB_AIO_RW)) ++ return; ++ + if (WARN_ON_ONCE(!list_empty(&req->ki_list))) + return; + +@@ -1476,7 +1483,7 @@ static int aio_prep_rw(struct kiocb *req + req->ki_complete = aio_complete_rw; + req->private = NULL; + req->ki_pos = iocb->aio_offset; +- req->ki_flags = req->ki_filp->f_iocb_flags; ++ req->ki_flags = req->ki_filp->f_iocb_flags | IOCB_AIO_RW; + if (iocb->aio_flags & IOCB_FLAG_RESFD) + req->ki_flags |= IOCB_EVENTFD; + if (iocb->aio_flags & IOCB_FLAG_IOPRIO) { +--- a/include/linux/fs.h ++++ b/include/linux/fs.h +@@ -337,6 +337,8 @@ enum rw_hint { + #define IOCB_NOIO (1 << 20) + /* can use bio alloc cache */ + #define IOCB_ALLOC_CACHE (1 << 21) ++/* kiocb is a read or write operation submitted by fs/aio.c. */ ++#define IOCB_AIO_RW (1 << 23) + + struct kiocb { + struct file *ki_filp; diff --git a/queue-6.1/mm-damon-reclaim-fix-quota-stauts-loss-due-to-online-tunings.patch b/queue-6.1/mm-damon-reclaim-fix-quota-stauts-loss-due-to-online-tunings.patch new file mode 100644 index 00000000000..46090a0e078 --- /dev/null +++ b/queue-6.1/mm-damon-reclaim-fix-quota-stauts-loss-due-to-online-tunings.patch @@ -0,0 +1,80 @@ +From 1b0ca4e4ff10a2c8402e2cf70132c683e1c772e4 Mon Sep 17 00:00:00 2001 +From: SeongJae Park +Date: Fri, 16 Feb 2024 11:40:24 -0800 +Subject: mm/damon/reclaim: fix quota stauts loss due to online tunings + +From: SeongJae Park + +commit 1b0ca4e4ff10a2c8402e2cf70132c683e1c772e4 upstream. + +Patch series "mm/damon: fix quota status loss due to online tunings". + +DAMON_RECLAIM and DAMON_LRU_SORT is not preserving internal quota status +when applying new user parameters, and hence could cause temporal quota +accuracy degradation. Fix it by preserving the status. + + +This patch (of 2): + +For online parameters change, DAMON_RECLAIM creates new scheme based on +latest values of the parameters and replaces the old scheme with the new +one. When creating it, the internal status of the quota of the old +scheme is not preserved. As a result, charging of the quota starts from +zero after the online tuning. The data that collected to estimate the +throughput of the scheme's action is also reset, and therefore the +estimation should start from the scratch again. Because the throughput +estimation is being used to convert the time quota to the effective size +quota, this could result in temporal time quota inaccuracy. It would be +recovered over time, though. In short, the quota accuracy could be +temporarily degraded after online parameters update. + +Fix the problem by checking the case and copying the internal fields for +the status. + +Link: https://lkml.kernel.org/r/20240216194025.9207-1-sj@kernel.org +Link: https://lkml.kernel.org/r/20240216194025.9207-2-sj@kernel.org +Fixes: e035c280f6df ("mm/damon/reclaim: support online inputs update") +Signed-off-by: SeongJae Park +Cc: [5.19+] +Signed-off-by: Andrew Morton +Signed-off-by: Greg Kroah-Hartman +--- + mm/damon/reclaim.c | 18 +++++++++++++++++- + 1 file changed, 17 insertions(+), 1 deletion(-) + +--- a/mm/damon/reclaim.c ++++ b/mm/damon/reclaim.c +@@ -141,9 +141,20 @@ static struct damos *damon_reclaim_new_s + &damon_reclaim_wmarks); + } + ++static void damon_reclaim_copy_quota_status(struct damos_quota *dst, ++ struct damos_quota *src) ++{ ++ dst->total_charged_sz = src->total_charged_sz; ++ dst->total_charged_ns = src->total_charged_ns; ++ dst->charged_sz = src->charged_sz; ++ dst->charged_from = src->charged_from; ++ dst->charge_target_from = src->charge_target_from; ++ dst->charge_addr_from = src->charge_addr_from; ++} ++ + static int damon_reclaim_apply_parameters(void) + { +- struct damos *scheme; ++ struct damos *scheme, *old_scheme; + int err = 0; + + err = damon_set_attrs(ctx, &damon_reclaim_mon_attrs); +@@ -154,6 +165,11 @@ static int damon_reclaim_apply_parameter + scheme = damon_reclaim_new_scheme(); + if (!scheme) + return -ENOMEM; ++ if (!list_empty(&ctx->schemes)) { ++ damon_for_each_scheme(old_scheme, ctx) ++ damon_reclaim_copy_quota_status(&scheme->quota, ++ &old_scheme->quota); ++ } + damon_set_schemes(ctx, &scheme, 1); + + return damon_set_region_biggest_system_ram_default(target, diff --git a/queue-6.1/series b/queue-6.1/series index 775ddaf3903..d578e7842af 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -185,3 +185,5 @@ drm-amd-display-fix-memory-leak-in-dm_sw_fini.patch i2c-imx-when-being-a-target-mark-the-last-read-as-pr.patch erofs-simplify-compression-configuration-parser.patch erofs-fix-inconsistent-per-file-compression-format.patch +mm-damon-reclaim-fix-quota-stauts-loss-due-to-online-tunings.patch +fs-aio-restrict-kiocb_set_cancel_fn-to-i-o-submitted-via-libaio.patch