From nobody Wed Feb 11 05:17:29 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4f9ms625l5z6RtyQ for ; Wed, 11 Feb 2026 05:17:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4f9ms56SMzz3STP for ; Wed, 11 Feb 2026 05:17:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1770787049; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oTR+NhEToNQbFR5VNo5NfDmGvQGg13Sl9Wob+E+ttq4=; b=QFesiHjmcdyMkuLqJhocKVBWOkVqQ6ziEFckyst6kytLTJSwEUmQrJF4CdpNkevCvHqz2M g+dgzTQnFyyP4M0mu5vBhesBkMqTXZwagfZGt1dUccCFfjz4p9XPLGAcceY8oKGqw6stZx PxTQHChxc6ffJMufvWS/yaHpIKYcrlt4jVNv8dWuSs+rrL9LOaQZ/7cDqiOe1U3mDZIHOe vSz3m5L/GZlys3vL/b4ybPTdQHp58Vr4ov1yMWEpzG08EpOhIPF8lcgn5JnRqhecvbIFyq wFrzDXJi/ZU6vUKLeAX59yYDOfzouycAE8lTRYs2UwFWb0IaaHuhleWfOOiHvw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1770787049; a=rsa-sha256; cv=none; b=hcmDC2MwgtAf5amYvinCBwm4pZo+av74Xvg8/77wRHdf3A2KboKyNbVXeGSpC5T0GfLVHu vsFFg3Y4611pjZGV2bWekMIakQcJeEUOhwnkmr+5Dz4kWW5ccg/YDwPtJlFXl43iJHPVot 8WNIAg1U8XypQHACYrfCHIwtQHTTFVZTGUuy6+O85SN6Obybh7EvyavH2reVjEMnkBbRb7 LXUyWkvqIUsG+loakHWTbNLAIbatI7Qd6HYQTUov57sSEYrLdUajEzTENRrGkNgHtdjNrI Cy4nWBa4iFjUwMmdJCCWnz/yueSrGQH/iApzKgyhf3m89JgNXvGks3SeUW9ycg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1770787049; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oTR+NhEToNQbFR5VNo5NfDmGvQGg13Sl9Wob+E+ttq4=; b=aWjeBpLXNTzDQjFTqwiwDSJqnTrXdREZk/iML/WGMX+UZRjSu6HECchFfBiwNw3qsYmHqc ED4d5SavRwLSyNEOmVztmRAe0XZPdir9q3TeeazHLz264FwsxKGsxHWrZltoYvr4j4KQaI dktSevma3taZ+UgG6b3UDOz//JHFuc3onZ/Nx0NgrM3TpNiohKOSGVcTdXjfVBvomhh1OV qtHfhFfmn/VE8ypl2qizT7Nc3rU4ISIDnr4P8XXsfSw8/jzstoV4wnnrTy/OYTCZ3aivw4 xLLYAYib6kwCrZTcCFNBjD9tb3XQr4yFv8fqmwg1ehcKtEV6RVbpkg1PXTcT2g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4f9ms55t92zccG for ; Wed, 11 Feb 2026 05:17:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 269a3 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 11 Feb 2026 05:17:29 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: e642bf4f6dab - stable/15 - net/iflib.c: move out scheduler-depended code into the hook List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: e642bf4f6dabcb7835f9d0ea9fefe3767d392317 Auto-Submitted: auto-generated Date: Wed, 11 Feb 2026 05:17:29 +0000 Message-Id: <698c10e9.269a3.186af751@gitrepo.freebsd.org> The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e642bf4f6dabcb7835f9d0ea9fefe3767d392317 commit e642bf4f6dabcb7835f9d0ea9fefe3767d392317 Author: Konstantin Belousov AuthorDate: 2026-01-22 13:38:20 +0000 Commit: Konstantin Belousov CommitDate: 2026-02-11 05:12:37 +0000 net/iflib.c: move out scheduler-depended code into the hook (cherry picked from commit b602ba1b5fd92bb226e32f5720885f856a5cb0bb) --- sys/kern/sched_4bsd.c | 7 +++++ sys/kern/sched_shim.c | 1 + sys/kern/sched_ule.c | 68 ++++++++++++++++++++++++++++++++++++++++++ sys/net/iflib.c | 82 ++------------------------------------------------- sys/sys/sched.h | 8 +++++ 5 files changed, 87 insertions(+), 79 deletions(-) diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index 03e7b71d3fe6..11baf9d2bdfa 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -1854,6 +1854,12 @@ sched_4bsd_do_timer_accounting(void) #endif } +static int +sched_4bsd_find_l2_neighbor(int cpu) +{ + return (-1); +} + struct sched_instance sched_4bsd_instance = { #define SLOT(name) .name = sched_4bsd_##name SLOT(load), @@ -1897,6 +1903,7 @@ struct sched_instance sched_4bsd_instance = { SLOT(tdname), SLOT(clear_tdname), SLOT(do_timer_accounting), + SLOT(find_l2_neighbor), SLOT(init), SLOT(init_ap), SLOT(setup), diff --git a/sys/kern/sched_shim.c b/sys/kern/sched_shim.c index d2f0b5749752..816d0b44bb52 100644 --- a/sys/kern/sched_shim.c +++ b/sys/kern/sched_shim.c @@ -94,6 +94,7 @@ DEFINE_SHIM0(sizeof_thread, int, sched_sizeof_thread) DEFINE_SHIM1(tdname, char *, sched_tdname, struct thread *, td) DEFINE_SHIM1(clear_tdname, void, sched_clear_tdname, struct thread *, td) DEFINE_SHIM0(do_timer_accounting, bool, sched_do_timer_accounting) +DEFINE_SHIM1(find_l2_neighbor, int, sched_find_l2_neighbor, int, cpu) DEFINE_SHIM0(init_ap, void, schedinit_ap) static char sched_name[32] = "ULE"; diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 22257b2c0d7a..7a745619480d 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -3360,6 +3360,73 @@ sched_ule_do_timer_accounting(void) return (true); } +#ifdef SMP +static int +sched_ule_find_child_with_core(int cpu, struct cpu_group *grp) +{ + int i; + + if (grp->cg_children == 0) + return (-1); + + MPASS(grp->cg_child); + for (i = 0; i < grp->cg_children; i++) { + if (CPU_ISSET(cpu, &grp->cg_child[i].cg_mask)) + return (i); + } + + return (-1); +} + +static int +sched_ule_find_l2_neighbor(int cpu) +{ + struct cpu_group *grp; + int i; + + grp = cpu_top; + if (grp == NULL) + return (-1); + + /* + * Find the smallest CPU group that contains the given core. + */ + i = 0; + while ((i = sched_ule_find_child_with_core(cpu, grp)) != -1) { + /* + * If the smallest group containing the given CPU has less + * than two members, we conclude the given CPU has no + * L2 neighbor. + */ + if (grp->cg_child[i].cg_count <= 1) + return (-1); + grp = &grp->cg_child[i]; + } + + /* Must share L2. */ + if (grp->cg_level > CG_SHARE_L2 || grp->cg_level == CG_SHARE_NONE) + return (-1); + + /* + * Select the first member of the set that isn't the reference + * CPU, which at this point is guaranteed to exist. + */ + for (i = 0; i < CPU_SETSIZE; i++) { + if (CPU_ISSET(i, &grp->cg_mask) && i != cpu) + return (i); + } + + /* Should never be reached */ + return (-1); +} +#else +static int +sched_ule_find_l2_neighbor(int cpu) +{ + return (-1); +} +#endif + struct sched_instance sched_ule_instance = { #define SLOT(name) .name = sched_ule_##name SLOT(load), @@ -3403,6 +3470,7 @@ struct sched_instance sched_ule_instance = { SLOT(tdname), SLOT(clear_tdname), SLOT(do_timer_accounting), + SLOT(find_l2_neighbor), SLOT(init), SLOT(init_ap), SLOT(setup), diff --git a/sys/net/iflib.c b/sys/net/iflib.c index f6b25558d0e8..0bea19d75231 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -29,7 +29,6 @@ #include "opt_inet.h" #include "opt_inet6.h" #include "opt_acpi.h" -#include "opt_sched.h" #include #include @@ -40,8 +39,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -4781,83 +4782,6 @@ cpuid_advance(if_ctx_t ctx, unsigned int cpuid, unsigned int n) return (cpuid); } -#if defined(SMP) && defined(SCHED_ULE) -extern struct cpu_group *cpu_top; /* CPU topology */ - -static int -find_child_with_core(int cpu, struct cpu_group *grp) -{ - int i; - - if (grp->cg_children == 0) - return (-1); - - MPASS(grp->cg_child); - for (i = 0; i < grp->cg_children; i++) { - if (CPU_ISSET(cpu, &grp->cg_child[i].cg_mask)) - return (i); - } - - return (-1); -} - - -/* - * Find an L2 neighbor of the given CPU or return -1 if none found. This - * does not distinguish among multiple L2 neighbors if the given CPU has - * more than one (it will always return the same result in that case). - */ -static int -find_l2_neighbor(int cpu) -{ - struct cpu_group *grp; - int i; - - grp = cpu_top; - if (grp == NULL) - return (-1); - - /* - * Find the smallest CPU group that contains the given core. - */ - i = 0; - while ((i = find_child_with_core(cpu, grp)) != -1) { - /* - * If the smallest group containing the given CPU has less - * than two members, we conclude the given CPU has no - * L2 neighbor. - */ - if (grp->cg_child[i].cg_count <= 1) - return (-1); - grp = &grp->cg_child[i]; - } - - /* Must share L2. */ - if (grp->cg_level > CG_SHARE_L2 || grp->cg_level == CG_SHARE_NONE) - return (-1); - - /* - * Select the first member of the set that isn't the reference - * CPU, which at this point is guaranteed to exist. - */ - for (i = 0; i < CPU_SETSIZE; i++) { - if (CPU_ISSET(i, &grp->cg_mask) && i != cpu) - return (i); - } - - /* Should never be reached */ - return (-1); -} - -#else -static int -find_l2_neighbor(int cpu) -{ - - return (-1); -} -#endif - /* * CPU mapping behaviors * --------------------- @@ -4910,7 +4834,7 @@ get_cpuid_for_queue(if_ctx_t ctx, unsigned int base_cpuid, unsigned int qid, unsigned int rx_cpuid; rx_cpuid = cpuid_advance(ctx, base_cpuid, qid); - l2_neighbor = find_l2_neighbor(rx_cpuid); + l2_neighbor = sched_find_l2_neighbor(rx_cpuid); if (l2_neighbor != -1) { return (l2_neighbor); } diff --git a/sys/sys/sched.h b/sys/sys/sched.h index 9c78452432b4..3ba40fb191d3 100644 --- a/sys/sys/sched.h +++ b/sys/sys/sched.h @@ -243,6 +243,13 @@ void schedinit_ap(void); bool sched_do_timer_accounting(void); +/* + * Find an L2 neighbor of the given CPU or return -1 if none found. This + * does not distinguish among multiple L2 neighbors if the given CPU has + * more than one (it will always return the same result in that case). + */ +int sched_find_l2_neighbor(int cpu); + struct sched_instance { int (*load)(void); int (*rr_interval)(void); @@ -285,6 +292,7 @@ struct sched_instance { char *(*tdname)(struct thread *td); void (*clear_tdname)(struct thread *td); bool (*do_timer_accounting)(void); + int (*find_l2_neighbor)(int cpuid); void (*init)(void); void (*init_ap)(void); void (*setup)(void);