On Wed, Dec 17, 2025 at 08:51:50PM +0800, Chen, Yu C wrote:
> On 12/17/2025 5:40 PM, Aaron Lu wrote:
> > On Wed, Dec 03, 2025 at 03:07:36PM -0800, Tim Chen wrote:
> > > @@ -1501,6 +1507,7 @@ static void __no_profile task_cache_work(struct callback_head *work)
> > > mm->mm_sched_cpu = m_a_cpu;
> > > }
> > > + update_avg(&mm->nr_running_avg, nr_running);
> >
> > update_avg() doesn't appear to deal with small numbers well and can have
> > an error as large as 7, e.g. when nr_running < 8, nr_running_avg will
> > always be 0 and when nr_running >= 8 && < 16, nr_running_avg will be
> > 1 - 8, etc.
> >
> > AMD Genoa has 8 cores per LLC and this will break exceed_llc_nr() there.
> >
>
> Ah, you are right, thanks for pointing this out, dividing by 8 would make
> convergence slow for small LLC system. Maybe consider the number of Cores
Not just slow but the error is too large for a small LLC.
> in the LLC, the smaller the number is, the more we should honor the diff
> between two invoking of update_avg()?
>
> static inline void sched_cache_update_avg(u64 *avg, u64 sample)
> {
> s64 diff = sample - *avg;
> u32 divisor = clamp_t(u32, nr_cores_llc/4, 2, 8);
>
> *avg += diff / divisor;
> }
>
> For <=8 cores per LLC, the divisor is 2,
> for 16 cores per LLC, the divisor is 4,
> for >=32 cores per LLC, the divisor is 8
Yeah I guess it works. The error can be as large as 'divisor - 1' but
since this avg is an estimate, it may be OK.