linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Roman Gushchin <guroan@gmail.com>
Cc: Tejun Heo <tj@kernel.org>,
	kernel-team@fb.com, cgroups@vger.kernel.org,
	linux-kernel@vger.kernel.org, Roman Gushchin <guro@fb.com>
Subject: Re: [PATCH v6 4/7] cgroup: cgroup v2 freezer
Date: Fri, 25 Jan 2019 14:43:36 +0100	[thread overview]
Message-ID: <20190125134336.GA18991@redhat.com> (raw)
In-Reply-To: <20181222000307.28231-5-guro@fb.com>

On 12/21, Roman Gushchin wrote:
>
> +static void cgroup_do_freeze(struct cgroup *cgrp, bool freeze)
> +{
> +	struct css_task_iter it;
> +	struct task_struct *task;
> +
> +	lockdep_assert_held(&cgroup_mutex);
> +
> +	spin_lock_irq(&css_set_lock);
> +	if (freeze) {
> +		cgrp->freezer.nr_tasks_to_freeze = __cgroup_task_count(cgrp);
> +		set_bit(CGRP_FREEZE, &cgrp->flags);
> +	} else {
> +		clear_bit(CGRP_FREEZE, &cgrp->flags);
> +	}
> +	spin_unlock_irq(&css_set_lock);
> +
> +	css_task_iter_start(&cgrp->self, 0, &it);
> +	while ((task = css_task_iter_next(&it))) {
> +		/*
> +		 * Ignore kernel threads here. Freezing cgroups containing
> +		 * kthreads isn't supported.
> +		 */
> +		if (task->flags & PF_KTHREAD)
> +			continue;
> +		cgroup_freeze_task(task, freeze);
> +	}
> +	css_task_iter_end(&it);

I don't understand why this can race with exiting task. Or with SIGKILL which
kills a task before it sets current->frozen.

How can we trust nr_tasks_to_freeze at all?

Yes you added cgroup_dec_tasks_to_freeze() into cgroup_exit(). But it won't be
called if CGRP_FROZEN was not set yet, or because of "spurious" transitions
caused by cgroup_inc/dec_frozen_cnt() called by this or other tasks.

it seems that cgroup_exit() should check CGRP_FREEZE instead...

Oleg.


  parent reply	other threads:[~2019-01-25 13:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-22  0:03 [PATCH v6 0/7] freezer for cgroup v2 Roman Gushchin
2018-12-22  0:03 ` [PATCH v6 1/7] cgroup: rename freezer.c into legacy_freezer.c Roman Gushchin
2018-12-22  0:03 ` [PATCH v6 2/7] cgroup: implement __cgroup_task_count() helper Roman Gushchin
2018-12-22  0:03 ` [PATCH v6 3/7] cgroup: protect cgroup->nr_(dying_)descendants by css_set_lock Roman Gushchin
2018-12-22  0:03 ` [PATCH v6 4/7] cgroup: cgroup v2 freezer Roman Gushchin
2019-01-25 12:27   ` Oleg Nesterov
2019-01-25 13:46     ` Oleg Nesterov
2019-01-28 19:59     ` Roman Gushchin
2019-01-30 16:52       ` Oleg Nesterov
2019-02-11 21:30         ` Roman Gushchin
2019-02-14 16:26           ` Oleg Nesterov
2019-02-14 16:41             ` Roman Gushchin
2019-01-25 13:43   ` Oleg Nesterov [this message]
2018-12-22  0:03 ` [PATCH v6 5/7] kselftests: cgroup: don't fail on cg_kill_all() error in cg_destroy() Roman Gushchin
2018-12-22  0:03 ` [PATCH v6 6/7] kselftests: cgroup: add freezer controller self-tests Roman Gushchin
2018-12-22  0:03 ` [PATCH v6 7/7] cgroup: document cgroup v2 freezer interface Roman Gushchin
2019-01-24 15:26 ` [PATCH v6 0/7] freezer for cgroup v2 Tejun Heo

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=20190125134336.GA18991@redhat.com \
    --to=oleg@redhat.com \
    --cc=cgroups@vger.kernel.org \
    --cc=guro@fb.com \
    --cc=guroan@gmail.com \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).