Re: [LTP] [PATCH 3/6] sched_football: Re-add the crazy fans to interrupt everyone

John Stultz via ltp
2024-04-29T23:06:55Z

On Mon, Apr 29, 2024 at 2:11 AM Cyril Hrubis <chrubis@suse.cz> wrote:
>
> Hi!
> > * This is a scheduler test that uses a football analogy.
> > * The premise is that we want to make sure that lower priority threads
> > - * (defensive team). The offense is trying to increment the balls position,
> > - * while the defense is trying to block that from happening.
> > + * don't run while we have runnable higher priority threads.
> > + * The offense is trying to increment the balls position, while the
> > + * defense is trying to block that from happening.
> > * And the ref (highest priority thread) will blow the wistle if the
> > * ball moves. Finally, we have crazy fans (higer prority) that try to
> > * distract the defense by occasionally running onto the field.
> > *
> > * Steps:
> > - * - Create a fixed number of offense threads (lower priority)
> > + * - Create NR_CPU offense threads (lower priority)
> > + * - Create NR_CPU defense threads (mid priority)
> > + * - Create 2*NR_CPU fan threads (high priority)
> > * - Create a referee thread (highest priority)
> > - * - Once everyone is on the field, the offense thread increments the
> > - * value of 'the_ball'. The defense thread tries to block
> > - * the ball by never letting the offense players get the CPU (it just
> > - * spins).
> > + * - Once everyone is on the field, the offense thread spins incrementing
> > + * the value of 'the_ball'. The defense thread tries to block the ball
> > + * by never letting the offense players get the CPU (it just spins).
> > + * The crazy fans sleep a bit, then jump the rail and run across the
> > + * field, disrupting the players on the field.
> > * - The refree threads wakes up regularly to check if the game is over :)
> > * - In the end, if the value of 'the_ball' is >0, the test is considered
> > * to have failed.
> > @@ -52,7 +56,7 @@
> > * bugfixes and cleanups. -- Josh Triplett
> > * 2009-06-23 Simplified atomic startup mechanism, avoiding thundering herd
> > * scheduling at the beginning of the game. -- Darren Hart
> > - *
> > + * 2024-04-23 Re-add crazy fans! Along with minor cleanups -- John Stultz
>
> We use git now, so it's kind of pointless to add more changelog lines
> into the file itself.

Ack. Sounds good. Will drop.

> >
> > +#define NSEC_PER_SEC 1000000000ULL
> > +unsigned long long ts_delta(struct timespec *start, struct timespec *stop)
> > +{
> > + unsigned long long a, b;
> > +
> > + a = start->tv_sec * NSEC_PER_SEC + start->tv_nsec;
> > + b = stop->tv_sec * NSEC_PER_SEC + stop->tv_nsec;
> > + return b - a;
> > +}
>
> This is tst_timespec_diff() from include/tst_timer.h
>

Ah. I didn't even think to look, it's such a habit to hand write it in
my own small tests.

Though this runs into the same issue of conflicting defines from the
librttest.h, so your suggestions there would be appreciated.

I could probably utilize the ts_minus/ts_to_nsec logic as well in
librttest.h as an alternative.

Thanks for the review feedback!
-john