Re: hwpstate_intel i386 build workaround [Was: Re: git: 7b26353a59d6 - main - hwpstate_intel: Disable package control on hybrid CPU]

From: Adrian Chadd <adrian_at_freebsd.org>
Date: Sat, 27 Jun 2026 15:23:59 UTC
please create a review for this? It sounds like they should've wrapped
it if #ifdef amd64 or something

-a

On Sat, 27 Jun 2026 at 07:19, Harry Schmalzbauer <freebsd@omnilan.de> wrote:
>
> On 2026-06-02 08:42, ShengYi Hung wrote:
> > The branch main has been updated by aokblast:
> >
> > URL: https://cgit.FreeBSD.org/src/commit/?id=7b26353a59d66dc1bc611fd042a49b9e3bd13699
> >
> > commit 7b26353a59d66dc1bc611fd042a49b9e3bd13699
> > Author:     ShengYi Hung <aokblast@FreeBSD.org>
> > AuthorDate: 2026-06-01 09:46:37 +0000
> > Commit:     ShengYi Hung <aokblast@FreeBSD.org>
> > CommitDate: 2026-06-02 06:41:41 +0000
> >
> >      hwpstate_intel: Disable package control on hybrid CPU
> >
> >      In package control mode, the performance of all cores depends on the
> >      most recent value written to the request field. If the last write comes
> >      from an E-core, all cores are forced to align with the E-core
> >      performance level, resulting in significant performance degradation.
> >      Therefore, package control is disabled on hybrid-core systems.
> >
> >      Reviewed by:    olce
> >      MFC after:      2 weeks
> >      Sponsored by:   The FreeBSD Foundation
> >      Sponsored by:   Framework Computer Inc
> >      Differential Revision: https://reviews.freebsd.org/D57377
> > ---
> >   sys/x86/cpufreq/hwpstate_intel.c | 21 +++++++++++++++++++++
>
>
> In lieu of a proper fix, due to lacking skills, I'm working around i386
> incompatibility with this diff:
>
> diff --git a/sys/x86/cpufreq/hwpstate_intel.c
> b/sys/x86/cpufreq/hwpstate_intel.c
> index db8600d7b89a..b9b68f1b14d0 100644
> --- a/sys/x86/cpufreq/hwpstate_intel.c
> +++ b/sys/x86/cpufreq/hwpstate_intel.c
> @@ -321,6 +321,7 @@ sysctl_epp_select(SYSCTL_HANDLER_ARGS)
>          return (ret);
>   }
>
> +#ifndef __i386__
>   static void
>   intel_hwpstate_hybrid_cb(void *ctx)
>   {
> @@ -328,11 +329,14 @@ intel_hwpstate_hybrid_cb(void *ctx)
>
>          atomic_add_32(small_cores, PCPU_GET(small_core));
>   }
> +#endif
>
>   void
>   intel_hwpstate_identify(driver_t *driver, device_t parent)
>   {
> +#ifndef __i386__
>          uint32_t small_cores = 0;
> +#endif
>
>          if (device_find_child(parent, "hwpstate_intel",
> DEVICE_UNIT_ANY) != NULL)
>                  return;
> @@ -353,6 +357,7 @@ intel_hwpstate_identify(driver_t *driver, device_t
> parent)
>          if ((cpu_power_eax & CPUTPM1_HWP) == 0)
>                  return;
>
> +#ifndef __i386__
>          /*
>           * On hybrid-core systems, package-level control cannot be used.
>           * It may cause all cores to run at the E-core frequency because
> @@ -363,6 +368,7 @@ intel_hwpstate_identify(driver_t *driver, device_t
> parent)
>              intel_hwpstate_hybrid_cb, smp_no_rendezvous_barrier,
> &small_cores);
>          if (small_cores > 0 && small_cores < mp_ncores)
>                  hwpstate_pkg_ctrl_enable = false;
> +#endif
>
>          if (BUS_ADD_CHILD(parent, 10, "hwpstate_intel",
> device_get_unit(parent))
>              == NULL)
>
> I know i386 is not supported anymore.
> Just in case anybody else wants to keep i368-stable/15 for bhyve guests
> for example, where cpufreq(4) isn't attaching anyways.
>
> Thanks,
>
> -harry
>
>