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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZEGaZ+lQL7pHpmY5@righiandr-XPS-13-7390>
Date:   Thu, 20 Apr 2023 22:02:47 +0200
From:   Andrea Righi <andrea.righi@...onical.com>
To:     Tejun Heo <tj@...nel.org>
Cc:     torvalds@...ux-foundation.org, mingo@...hat.com,
        peterz@...radead.org, juri.lelli@...hat.com,
        vincent.guittot@...aro.org, dietmar.eggemann@....com,
        rostedt@...dmis.org, bsegall@...gle.com, mgorman@...e.de,
        bristot@...hat.com, vschneid@...hat.com, ast@...nel.org,
        daniel@...earbox.net, andrii@...nel.org, martin.lau@...nel.org,
        joshdon@...gle.com, brho@...gle.com, pjt@...gle.com,
        derkling@...gle.com, haoluo@...gle.com, dvernet@...a.com,
        dschatzberg@...a.com, dskarlat@...cmu.edu, riel@...riel.com,
        linux-kernel@...r.kernel.org, bpf@...r.kernel.org,
        kernel-team@...a.com, kernel test robot <lkp@...el.com>
Subject: Re: [PATCH 24/32] sched_ext: Add cgroup support

On Fri, Mar 17, 2023 at 11:33:25AM -1000, Tejun Heo wrote:
...
> +/**
> + * scx_bpf_task_cgroup - Return the sched cgroup of a task
> + * @p: task of interest
> + *
> + * @p->sched_task_group->css.cgroup represents the cgroup @p is associated with
> + * from the scheduler's POV. SCX operations should use this function to
> + * determine @p's current cgroup as, unlike following @p->cgroups,
> + * @p->sched_task_group is protected by @p's rq lock and thus atomic w.r.t. all
> + * rq-locked operations. Can be called on the parameter tasks of rq-locked
> + * operations. The restriction guarantees that @p's rq is locked by the caller.
> + */
> +struct cgroup *scx_bpf_task_cgroup(struct task_struct *p)
> +{
> +	struct task_group *tg = p->sched_task_group;
> +	struct cgroup *cgrp = &cgrp_dfl_root.cgrp;
> +
> +	if (!scx_kf_allowed_on_arg_tasks(__SCX_KF_RQ_LOCKED, p))
> +		goto out;
> +
> +	/*
> +	 * A task_group may either be a cgroup or an autogroup. In the latter
> +	 * case, @tg->css.cgroup is %NULL. A task_group can't become the other
> +	 * kind once created.
> +	 */
> +	if (tg && tg->css.cgroup)
> +		cgrp = tg->css.cgroup;
> +	else
> +		cgrp = &cgrp_dfl_root.cgrp;
> +out:
> +	cgroup_get(cgrp);
> +	return cgrp;
> +}

^ #ifdef CONFIG_CGROUP_SCHED, otherwise we may get build errors, like:

kernel/sched/ext.c:4251:34: error: 'struct task_struct' has no member named 'sched_task_group'

> +
>  BTF_SET8_START(scx_kfunc_ids_any)
>  BTF_ID_FLAGS(func, scx_bpf_kick_cpu)
>  BTF_ID_FLAGS(func, scx_bpf_dsq_nr_queued)
> @@ -3431,6 +3803,7 @@ BTF_ID_FLAGS(func, scx_bpf_error_bstr, KF_TRUSTED_ARGS)
>  BTF_ID_FLAGS(func, scx_bpf_destroy_dsq)
>  BTF_ID_FLAGS(func, scx_bpf_task_running, KF_RCU)
>  BTF_ID_FLAGS(func, scx_bpf_task_cpu, KF_RCU)
> +BTF_ID_FLAGS(func, scx_bpf_task_cgroup, KF_RCU | KF_ACQUIRE)

Ditto.

-Andrea

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ