Re: [PATCH v4 06/24] sched/fair: Collect load-balancing stats for IPC classes

From: Ricardo Neri
Date: Thu Jul 06 2023 - 19:38:22 EST


On Mon, Jun 26, 2023 at 12:52:59PM -0700, Tim Chen wrote:
>
> > >
> > > nit: the comment is unnecessary, and a bit misleading, IMO.
> > >
> > > The comment says "This group will not be selected." but the only way to
> > > guarantee that here is to reset the sum_score to 0 when you find an
> > > invalid score, which I don't believe is your intention.
> >
> > You raise an interesting point. We will call this function for each rq
> > in the sched group. Thus, if we encounter an error, the scores would be
> > incomplete. Therefore, I think that the scores should be discarded and
> > reset to 0 so that they are not used, IMO.
>
> Since we still have other rqs to loop through, reset to 0 here does
> not guarantee that it will stay that way at the end of the loop when
> the sum could still be added to.

That is true, to discard the would need an indication that we should not
keep iterating on the runqueues of this group.

> May need a special value like -EINVAL
> and make the score a "long" to mark such case.

IIUC, unsigned longs allow to handle negative errors if you use
IS_ERR_VALUE(); but yes, it looks odd.