All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Patrick Bellasi <patrick.bellasi@arm.com>
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-api@vger.kernel.org, cgroups@vger.kernel.org,
	Ingo Molnar <mingo@redhat.com>, Tejun Heo <tj@kernel.org>,
	"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Paul Turner <pjt@google.com>, Michal Koutny <mkoutny@suse.com>,
	Quentin Perret <quentin.perret@arm.com>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Morten Rasmussen <morten.rasmussen@arm.com>,
	Juri Lelli <juri.lelli@redhat.com>, Todd Kjos <tkjos@google.com>,
	Joel Fernandes <joelaf@google.com>,
	Steve Muckle <smuckle@google.com>,
	Suren Baghdasaryan <surenb@google.com>,
	Alessio Balsini <balsini@android.com>
Subject: Re: [PATCH v14 5/6] sched/core: uclamp: Update CPU's refcount on TG's clamp changes
Date: Mon, 2 Sep 2019 09:38:36 +0200	[thread overview]
Message-ID: <20190902073836.GO2369@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <87woernqnb.fsf@arm.com>

On Mon, Sep 02, 2019 at 07:44:40AM +0100, Patrick Bellasi wrote:
> On Fri, Aug 30, 2019 at 09:48:34 +0000, Peter Zijlstra wrote...
> > On Thu, Aug 22, 2019 at 02:28:10PM +0100, Patrick Bellasi wrote:

> >> +	rq = task_rq_lock(p, &rf);
> >
> > Since modifying cgroup parameters is priv only, this should be OK I
> > suppose. Priv can already DoS the system anyway.
> 
> Are you referring to the possibility to DoS the scheduler by keep
> writing cgroup attributes?

Yep.

> Because, in that case I think cgroup attributes could be written also by
> non priv users. It all depends on how they are mounted and permissions
> are set. Isn't it?
> 
> Anyway, I'm not sure we can fix that here... and in principle we could
> have that DoS by setting CPUs affinities, which is user exposed.
> Isn't it?

Only for a single task; by using the cgroup thing we have that in-kernel
iteration of tasks.

The thing I worry about is bouncing rq->lock around the system; but
yeah, I suppose a normal user could achieve something similar with
enough tasks.

> >> +	/*
> >> +	 * Setting the clamp bucket is serialized by task_rq_lock().
> >> +	 * If the task is not yet RUNNABLE and its task_struct is not
> >> +	 * affecting a valid clamp bucket, the next time it's enqueued,
> >> +	 * it will already see the updated clamp bucket value.
> >> +	 */
> >> +	if (!p->uclamp[clamp_id].active)
> >> +		goto done;
> >> +
> >> +	uclamp_rq_dec_id(rq, p, clamp_id);
> >> +	uclamp_rq_inc_id(rq, p, clamp_id);
> >> +
> >> +done:
> >
> > I'm thinking that:
> >
> > 	if (p->uclamp[clamp_id].active) {
> > 		uclamp_rq_dec_id(rq, p, clamp_id);
> > 		uclamp_rq_inc_id(rq, p, clamp_id);
> > 	}
> >
> > was too obvious? ;-)
> 
> Yep, right... I think there was some more code in prev versions but I
> forgot to get rid of that "goto" pattern after some change.

OK, already fixed that.

  reply	other threads:[~2019-09-02  7:38 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-22 13:28 [PATCH v14 0/6] Add utilization clamping support (CGroups API) Patrick Bellasi
2019-08-22 13:28 ` Patrick Bellasi
2019-08-22 13:28 ` [PATCH v14 1/6] sched/core: uclamp: Extend CPU's cgroup controller Patrick Bellasi
2019-08-30  9:45   ` Peter Zijlstra
2019-09-02  6:38     ` Patrick Bellasi
2019-09-02  7:47       ` Peter Zijlstra
2019-09-02 23:02   ` Suren Baghdasaryan
2019-09-03  8:52     ` Michal Koutný
2019-09-03 14:21       ` Joel Fernandes
2019-09-03 14:21         ` Joel Fernandes
2019-09-03 14:21         ` Joel Fernandes
2019-09-03  8:31   ` [tip: sched/core] sched/uclamp: " tip-bot2 for Patrick Bellasi
2019-08-22 13:28 ` [PATCH v14 2/6] sched/core: uclamp: Propagate parent clamps Patrick Bellasi
2019-09-03  8:31   ` [tip: sched/core] sched/uclamp: " tip-bot2 for Patrick Bellasi
2019-08-22 13:28 ` [PATCH v14 3/6] sched/core: uclamp: Propagate system defaults to root group Patrick Bellasi
2019-09-03  8:31   ` [tip: sched/core] sched/uclamp: Propagate system defaults to the " tip-bot2 for Patrick Bellasi
2019-08-22 13:28 ` [PATCH v14 4/6] sched/core: uclamp: Use TG's clamps to restrict TASK's clamps Patrick Bellasi
2019-09-03  8:31   ` [tip: sched/core] sched/uclamp: " tip-bot2 for Patrick Bellasi
2019-08-22 13:28 ` [PATCH v14 5/6] sched/core: uclamp: Update CPU's refcount on TG's clamp changes Patrick Bellasi
2019-08-30  9:48   ` Peter Zijlstra
2019-09-02  6:44     ` Patrick Bellasi
2019-09-02  7:38       ` Peter Zijlstra [this message]
2019-09-03  8:31   ` [tip: sched/core] sched/uclamp: " tip-bot2 for Patrick Bellasi
2019-08-22 13:28 ` [PATCH v14 6/6] sched/core: uclamp: always use enum uclamp_id for clamp_id values Patrick Bellasi
2019-09-03  8:31   ` [tip: sched/core] sched/uclamp: Always use 'enum uclamp_id' " tip-bot2 for Patrick Bellasi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190902073836.GO2369@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=balsini@android.com \
    --cc=cgroups@vger.kernel.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=joelaf@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=mkoutny@suse.com \
    --cc=morten.rasmussen@arm.com \
    --cc=patrick.bellasi@arm.com \
    --cc=pjt@google.com \
    --cc=quentin.perret@arm.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=smuckle@google.com \
    --cc=surenb@google.com \
    --cc=tj@kernel.org \
    --cc=tkjos@google.com \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.