lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 4 Jan 2024 21:20:02 -0800
From: John Stultz <jstultz@...gle.com>
To: Metin Kaya <metin.kaya@....com>
Cc: LKML <linux-kernel@...r.kernel.org>, Joel Fernandes <joelaf@...gle.com>, 
	Qais Yousef <qyousef@...gle.com>, Ingo Molnar <mingo@...hat.com>, 
	Peter Zijlstra <peterz@...radead.org>, Juri Lelli <juri.lelli@...hat.com>, 
	Vincent Guittot <vincent.guittot@...aro.org>, Dietmar Eggemann <dietmar.eggemann@....com>, 
	Valentin Schneider <vschneid@...hat.com>, Steven Rostedt <rostedt@...dmis.org>, 
	Ben Segall <bsegall@...gle.com>, Zimuzo Ezeozue <zezeozue@...gle.com>, 
	Youssef Esmat <youssefesmat@...gle.com>, Mel Gorman <mgorman@...e.de>, 
	Daniel Bristot de Oliveira <bristot@...hat.com>, Will Deacon <will@...nel.org>, Waiman Long <longman@...hat.com>, 
	Boqun Feng <boqun.feng@...il.com>, "Paul E. McKenney" <paulmck@...nel.org>, 
	Xuewen Yan <xuewen.yan94@...il.com>, K Prateek Nayak <kprateek.nayak@....com>, 
	Thomas Gleixner <tglx@...utronix.de>, kernel-team@...roid.com
Subject: Re: [PATCH v7 17/23] sched: Initial sched_football test implementation

On Fri, Dec 22, 2023 at 1:32 AM Metin Kaya <metin.kaya@....com> wrote:
>
> On 20/12/2023 12:18 am, John Stultz wrote:
> > Reimplementation of the sched_football test from LTP:
> > https://github.com/linux-test-project/ltp/blob/master/testcases/realtime/func/sched_football/sched_football.c
> >
> > But reworked to run in the kernel and utilize mutexes
> > to illustrate proper boosting of low priority mutex
> > holders.
> >
> > TODO:
> > * Need a rt_mutex version so it can work w/o proxy-execution
> > * Need a better place to put it
>
> I think also this patch can be upstreamed regardless of other Proxy
> Execution patches, right?

Well, we would need to use rt_mutexes for the !PROXY case to validate
inheritance.
But something like it could be included before PROXY lands.

> > + *
> > + * This is done via having N offsensive players that are
>
>                                  offensive

Fixed.

> > + * medium priority, which constantly are trying to increment the
> > + * ball_pos counter.
> > + *
> > + * Blocking this, are N defensive players that are higher
> > + * priority which just spin on the cpu, preventing the medium
> > + * priroity tasks from running.
>
>        priority

Fixed.

> > +atomic_t players_ready;
> > +atomic_t ball_pos;
> > +int players_per_team;
>
> Nit: Number of players cannot be lower than 0. Should it be unsigned then?

Fixed.

> > +bool game_over;
> > +
> > +struct mutex *mutex_low_list;
> > +struct mutex *mutex_mid_list;
> > +
> > +static inline
> > +struct task_struct *create_fifo_thread(int (*threadfn)(void *data), void *data,
> > +                                    char *name, int prio)
> > +{
> > +     struct task_struct *kth;
> > +     struct sched_attr attr = {
> > +             .size           = sizeof(struct sched_attr),
> > +             .sched_policy   = SCHED_FIFO,
> > +             .sched_nice     = 0,
> > +             .sched_priority = prio,
> > +     };
> > +     int ret;
> > +
> > +     kth = kthread_create(threadfn, data, name);
> > +     if (IS_ERR(kth)) {
> > +             pr_warn("%s eerr, kthread_create failed\n", __func__);
>
> Extra e at eerr?

Fixed.


> > +             return kth;
> > +     }
> > +     ret = sched_setattr_nocheck(kth, &attr);
> > +     if (ret) {
> > +             kthread_stop(kth);
> > +             pr_warn("%s: failed to set SCHED_FIFO\n", __func__);
> > +             return ERR_PTR(ret);
> > +     }
> > +
> > +     wake_up_process(kth);
> > +     return kth;
>
> I think the result of this function is actually unused. So,
> create_fifo_thread()'s return type can be void?

It's not used, but it probably should be. At least I should be
checking for the failure cases. I'll rework to fix this.



> > +
> > +int offense_thread(void *)
>
> Does this (no param name) build fine on Android env?

Good point, I've only been testing this bit with qemu. I'll fix it up.

> > +int ref_thread(void *arg)
> > +{
> > +     struct task_struct *kth;
> > +     long game_time = (long)arg;
> > +     unsigned long final_pos;
> > +     long i;
> > +
> > +     pr_info("%s: started ref, game_time: %ld secs !\n", __func__,
> > +             game_time);
> > +
> > +     /* Create low  priority defensive team */
>
> Sorry: extra space after `low`.

Fixed.

> > +     mutex_low_list = kmalloc_array(players_per_team,  sizeof(struct mutex), GFP_ATOMIC);
> > +     mutex_mid_list = kmalloc_array(players_per_team,  sizeof(struct mutex), GFP_ATOMIC);
>
> * Extra space after `players_per_team,`.
> * Shouldn't we check result of `kmalloc_array()`?
>
> Same comments for `mutex_low_list` (previous) line.

Yep.

Thanks for all the suggestions!
-john

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ