Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp847646imu; Tue, 11 Dec 2018 08:27:58 -0800 (PST) X-Google-Smtp-Source: AFSGD/XIdRFedRH5nY8z3tpKy/nilSkYbLxxCfIIKsajPX0mXYLx+igBMZt/P8VS73u1rid9zjIE X-Received: by 2002:a17:902:7c82:: with SMTP id y2mr16403725pll.33.1544545678768; Tue, 11 Dec 2018 08:27:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544545678; cv=none; d=google.com; s=arc-20160816; b=z13xTvkC383RmjOFeYB5Lyjig0yUYYDcy3M/uTG7qthNTVekrm4mz5B7r1vQef2VYW M6NCerTIgqSQzE4YJU+upVn5v5qOiVzuDIs5aStDGPCWgM1l8nObgpE0I7PcaRV1lAvt 0OR9zXPcjl2xXTVNpKY+0FY76XrDiJyGlQqzdmzdQJavWl9Lr4ZUkHhEMWt9cC1XF4gK 23ezRCPGZH6xUIjLmO6gfXWpKny/q2UJKaXHSsf4kAQkx3wjTgQwbAPx8L9T9Ek0SYQz 6kSSs1qAO6Xkmj9cYXJwzezp2/0uYTEvP8WNn8NwHxZzWn82OcGaTGyA0EOgjL2Nnyz7 jhFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=MGxPlR8FkQ0BHOqCg3zl535ggloefa9PvdT3N3dB+6Y=; b=dLwKnv7XFQ7K3onq7GbAF3niHFNYIRmf/D0peeH/yrGvnV3Yosf6GH6AMwZyy8z91E EPEOv34yBInchpLKkJew1Hi1417+HZd0aJDXVREwkjhRBLVrQMhx6uIAeRRuD2WuFjWI i/iuvp1wAkh955YCWGialMMZa2SvCFiYDq8eCywjkmhpkWgbL9zPHVL67ceiV1IHxJAM xqythMZYUuP6x+uSfcxXoEynToGR2xiCrIVhneTel693ilfsUDbIrMUzypYhMW8KBYhs raAeCtr4hGmn7eXedk+79zRa7Z3tMNPvtr5A8THBOO22keVkHID8K16KuAqUXjCuZHWv dQUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n5si12059022pgl.485.2018.12.11.08.27.25; Tue, 11 Dec 2018 08:27:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727365AbeLKQ0g (ORCPT + 99 others); Tue, 11 Dec 2018 11:26:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49456 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726628AbeLKQ0g (ORCPT ); Tue, 11 Dec 2018 11:26:36 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D91B7308FB8B; Tue, 11 Dec 2018 16:26:35 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.131]) by smtp.corp.redhat.com (Postfix) with SMTP id F2B3D600D6; Tue, 11 Dec 2018 16:26:33 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Tue, 11 Dec 2018 17:26:35 +0100 (CET) Date: Tue, 11 Dec 2018 17:26:32 +0100 From: Oleg Nesterov To: Roman Gushchin Cc: Tejun Heo , Dan Carpenter , Mike Rapoport , cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, Roman Gushchin Subject: Re: [PATCH v5 4/7] cgroup: cgroup v2 freezer Message-ID: <20181211162632.GB8504@redhat.com> References: <20181207201531.1665-1-guro@fb.com> <20181207201531.1665-5-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181207201531.1665-5-guro@fb.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 11 Dec 2018 16:26:36 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/07, Roman Gushchin wrote: > > Cgroup v2 freezer tries to put tasks into a state similar to jobctl > stop. This means that tasks can be killed, ptraced (using > PTRACE_SEIZE*), and interrupted. It is possible to attach to > a frozen task, get some information (e.g. read registers) and detach. I fail to understand how this all supposed to work. > @@ -368,6 +369,8 @@ static inline int signal_pending_state(long state, struct task_struct *p) > return 0; > if (!signal_pending(p)) > return 0; > + if (unlikely(cgroup_task_frozen(p) && p->jobctl == JOBCTL_TRAP_FREEZE)) > + return __fatal_signal_pending(p); I think I will never agree with this change ;) and I don't think it actually helps. > +void cgroup_enter_frozen(void) > +{ > + if (!current->frozen) { > + spin_lock_irq(&css_set_lock); > + current->frozen = true; > + cgroup_inc_frozen_cnt(task_dfl_cgroup(current), false, true); > + spin_unlock_irq(&css_set_lock); > + } > + > + __set_current_state(TASK_INTERRUPTIBLE); > + schedule(); So once again, suppose it races with PTRACE_INTERRUPT, or SIGSTOP, or something else which should be handled by get_signal() before do_freezer_trap(). If (say) PTRACE_INTERRUPT comes before schedule it will be lost. Otherwise the frozen task will react. This can't be right. Or I am totally confused. Perhaps you can split this patch? start with cgroup_enter_frozen() using TASK_KILLABLE, then teach it to handle ptrace/stop/etc? I think this way it would be simpler to discuss the necessary changes and document what exactly are you trying to do. and btw.... what about suspend? try_to_freeze_tasks() will obviously fail if there is a ->frozen thread? Oleg.