From: Greg Kroah-Hartman Date: Thu, 16 Jul 2026 13:17:26 +0000 (+0200) Subject: 6.18-stable patches X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a89bcf62498038f7a147bdfa59d96d6abbfa2032;p=thirdparty%2Fkernel%2Fstable-queue.git 6.18-stable patches added patches: sched-fair-only-update-stats-for-allowed-cpus-when-looking-for-dst-group.patch usb-gadget-f_fs-initialize-epfile-in-early-to-fix-endpoint-direction-checks.patch --- diff --git a/queue-6.18/sched-fair-only-update-stats-for-allowed-cpus-when-looking-for-dst-group.patch b/queue-6.18/sched-fair-only-update-stats-for-allowed-cpus-when-looking-for-dst-group.patch new file mode 100644 index 0000000000..c868aa3996 --- /dev/null +++ b/queue-6.18/sched-fair-only-update-stats-for-allowed-cpus-when-looking-for-dst-group.patch @@ -0,0 +1,45 @@ +From 82d6e01a0699800efd8b048eb584c907ccb47b7a Mon Sep 17 00:00:00 2001 +From: Adam Li +Date: Sat, 11 Oct 2025 06:43:22 +0000 +Subject: sched/fair: Only update stats for allowed CPUs when looking for dst group + +From: Adam Li + +commit 82d6e01a0699800efd8b048eb584c907ccb47b7a upstream. + +Load imbalance is observed when the workload frequently forks new threads. +Due to CPU affinity, the workload can run on CPU 0-7 in the first +group, and only on CPU 8-11 in the second group. CPU 12-15 are always idle. + +{ 0 1 2 3 4 5 6 7 } {8 9 10 11 12 13 14 15} + * * * * * * * * * * * * + +When looking for dst group for newly forked threads, in many times +update_sg_wakeup_stats() reports the second group has more idle CPUs +than the first group. The scheduler thinks the second group is less +busy. Then it selects least busy CPUs among CPU 8-11. Therefore CPU 8-11 +can be crowded with newly forked threads, at the same time CPU 0-7 +can be idle. + +A task may not use all the CPUs in a schedule group due to CPU affinity. +Only update schedule group statistics for allowed CPUs. + +Signed-off-by: Adam Li +Signed-off-by: Peter Zijlstra (Intel) +Cc: Erwan Velu +Signed-off-by: Greg Kroah-Hartman +--- + kernel/sched/fair.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/kernel/sched/fair.c ++++ b/kernel/sched/fair.c +@@ -10847,7 +10847,7 @@ static inline void update_sg_wakeup_stat + if (sd->flags & SD_ASYM_CPUCAPACITY) + sgs->group_misfit_task_load = 1; + +- for_each_cpu(i, sched_group_span(group)) { ++ for_each_cpu_and(i, sched_group_span(group), p->cpus_ptr) { + struct rq *rq = cpu_rq(i); + unsigned int local; + diff --git a/queue-6.18/series b/queue-6.18/series index 38becb1917..71721bbe35 100644 --- a/queue-6.18/series +++ b/queue-6.18/series @@ -473,3 +473,5 @@ fuse-uring-avoid-use-after-free-in-fuse_uring_async_stop_queues.patch fuse-uring-avoid-queue-stopped-races-and-set-read-that-value-under-lock.patch fuse-uring-make-a-fuse_req-on-sqe-commit-only-findable-after-memcpy.patch fuse-uring-remove-request-less-entries-from-ent_w_req_queue-to-fix-null-deref.patch +sched-fair-only-update-stats-for-allowed-cpus-when-looking-for-dst-group.patch +usb-gadget-f_fs-initialize-epfile-in-early-to-fix-endpoint-direction-checks.patch diff --git a/queue-6.18/usb-gadget-f_fs-initialize-epfile-in-early-to-fix-endpoint-direction-checks.patch b/queue-6.18/usb-gadget-f_fs-initialize-epfile-in-early-to-fix-endpoint-direction-checks.patch new file mode 100644 index 0000000000..de52e102e5 --- /dev/null +++ b/queue-6.18/usb-gadget-f_fs-initialize-epfile-in-early-to-fix-endpoint-direction-checks.patch @@ -0,0 +1,47 @@ +From 82cfd4739011bdc7e87b5d585703427e89ddfaa5 Mon Sep 17 00:00:00 2001 +From: Neill Kapron +Date: Fri, 19 Jun 2026 04:06:03 +0000 +Subject: usb: gadget: f_fs: Initialize epfile->in early to fix endpoint direction checks + +From: Neill Kapron + +commit 82cfd4739011bdc7e87b5d585703427e89ddfaa5 upstream. + +When parsing endpoint descriptors, ffs_data_got_descs() generates the +eps_addrmap which contains the endpoint direction. However, epfile->in +was previously only populated in ffs_func_eps_enable() which executes +upon USB host connection. As a result, early userspace ioctls like +FUNCTIONFS_DMABUF_ATTACH that run before the host connects would see +epfile->in as 0, leading to incorrect DMA directions. + +By moving the initialization to ffs_epfiles_create(), epfile->in is +accurate before userspace opens the endpoint files. + +Fixes: 7b07a2a7ca02 ("usb: gadget: functionfs: Add DMABUF import interface") +Cc: stable +Assisted-by: Antigravity:gemini-3.1-pro +Signed-off-by: Neill Kapron +Link: https://patch.msgid.link/20260619040609.4010746-2-nkapron@google.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/gadget/function/f_fs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/usb/gadget/function/f_fs.c ++++ b/drivers/usb/gadget/function/f_fs.c +@@ -2354,6 +2354,7 @@ static int ffs_epfiles_create(struct ffs + sprintf(epfile->name, "ep%02x", ffs->eps_addrmap[i]); + else + sprintf(epfile->name, "ep%u", i); ++ epfile->in = (ffs->eps_addrmap[i] & USB_ENDPOINT_DIR_MASK) ? 1 : 0; + epfile->dentry = ffs_sb_create_file(ffs->sb, epfile->name, + epfile, + &ffs_epfile_operations); +@@ -2440,7 +2441,6 @@ static int ffs_func_eps_enable(struct ff + ret = usb_ep_enable(ep->ep); + if (!ret) { + epfile->ep = ep; +- epfile->in = usb_endpoint_dir_in(ep->ep->desc); + epfile->isoc = usb_endpoint_xfer_isoc(ep->ep->desc); + } else { + break;