Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp347848yba; Sat, 20 Apr 2019 04:01:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqyB4LgGq8svPV7jrD/2QsjIKr5kKEAX00jjQGPhKnTodxe+bvxHle+/butZmtQsC4a1cbID X-Received: by 2002:a17:902:e781:: with SMTP id cp1mr3435566plb.268.1555758076884; Sat, 20 Apr 2019 04:01:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555758076; cv=none; d=google.com; s=arc-20160816; b=TGV9+mfr71qmNGps2eFouy4/Ll9RWxyV0nNfI20vrFlztDGWLeIl9zQiub/x77OQ90 NX3RovE4P9WYakbLY/H2DO5Ji+yVLh6y1iRDGR5P2PlDORgWN+GfIH6obHaQR/EsKOlM CyIIus4ox1Jo+k4mYwrTWp0W4fWRo74cSkf7gn9pulRzReWGGukhMjF7bYMnwn3NotVx LqffiF64q9UdN5v3YQvu3+8HBhY9qy5XsJfzs9zwdgVDQqZVjil6Cfx9xYnS+r4hO2ej s8e/HjY1ZsbzwNu/u56eMKA37h5Ogwhc2CdXXKmqHSnplY9DDL313+uN1/8QvRDPrrfB KDCQ== 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=yz3B73RPYKTx2VuqbWjMdacjnkbnZh6qaedZedqV0Sg=; b=ni2MkhcR5lTPtSJ2LlAxm6Wn3o7DDNX3jCkGixZVdUZrLWo0OEhNPCk/XxXtuidFsJ xh7AqczcFL2ZpncbxqC270IuqX+n/KImBKs1ShxKpzS4M0RZGz51pR71YYmNFaSwIrbH 7A+intODdyZxjxi/emSuEpRA2qFw1v199WGOaMB918TpFlxYKnJG3f3xoYZXOpOyKW0M /Fda1M1i47x3y83U7Fgt4tk+8w4eNnAgL39wwRZOlKCQPjzNKKU4clDfVvAHAdVA/iJ3 b+ceGzK+RwSo5tp3FN/KEgVjQGPZhJ3wCDZ9i0Y/TcyokOATyyb28IUFBC03gBHbE6O4 wpmQ== 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 p14si7802257pfn.267.2019.04.20.04.00.59; Sat, 20 Apr 2019 04:01:16 -0700 (PDT) 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 S1726302AbfDTK6m (ORCPT + 99 others); Sat, 20 Apr 2019 06:58:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34538 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725920AbfDTK6l (ORCPT ); Sat, 20 Apr 2019 06:58:41 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D522CA1FA; Sat, 20 Apr 2019 10:58:41 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.38]) by smtp.corp.redhat.com (Postfix) with SMTP id 0B4955D9D6; Sat, 20 Apr 2019 10:58:39 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Sat, 20 Apr 2019 12:58:40 +0200 (CEST) Date: Sat, 20 Apr 2019 12:58:38 +0200 From: Oleg Nesterov To: Roman Gushchin Cc: Roman Gushchin , Tejun Heo , Kernel Team , "cgroups@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v10 4/9] cgroup: cgroup v2 freezer Message-ID: <20190420105838.GA17468@redhat.com> References: <20190405174708.1010-1-guro@fb.com> <20190405174708.1010-5-guro@fb.com> <20190419151912.GA12152@redhat.com> <20190419161118.GA23357@tower.DHCP.thefacebook.com> <20190419162600.GC12228@redhat.com> <20190419165600.GC23357@tower.DHCP.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190419165600.GC23357@tower.DHCP.thefacebook.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sat, 20 Apr 2019 10:58:41 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/19, Roman Gushchin wrote: > > > > > > > > > wake_up_interruptible() ? > > > > > > Wait_up_interruptible() is supposed to work with a workqueue, > > > but here there is nothing like this. Probably, I didn't understand your idea. > > > Can you, please, elaborate a bit more? > > > > Not sure I understand... We need to wake up the task if it sleeps in > > do_freezer_trap(), right? do_freezer_trap() uses TASK_INTERRUPTIBLE, so > > why can't wake_up_interruptible() == __wake_up(TASK_INTERRUPTIBLE) work? > > Right, but __wake_up is supposed to wake threads blocked on a waitqueue: Ugh sorry ;) of course I meant wake_up_state(task, TASK_INTERRUPTIBLE). > > > > > + if (unlikely(cgroup_task_frozen(current))) { > > > > > spin_unlock_irq(&sighand->siglock); > > > > > + cgroup_leave_frozen(true); > > > > > goto relock; > > > > > } > > > > > > > > afaics cgroup_leave_frozen(false) makes more sense here. > > > > > > Why? I don't see any reasons why the task should remain in the frozen > > > state after this point. > > > > But cgroup_leave_frozen(false) will equally clear ->frozen if !CGRP_FREEZE ? > > OTOH, if CGRP_FREEZE is set again, why do we need to clear ->frozen? > > Hm, it might work too, but I'm not sure I like it more. IMO, the best option > is to have a single cgroup_leave_frozen(true) in signal.c, it's just simpler. > If a user changed the desired state of cgroup twice, there is no need to avoid > state transitions. Or maybe I don't see it yet. Then why do we need cgroup_leave_frozen(false) in wait_for_vfork_done() ? How does it differ from get_signal() ? If nothing else. Suppose that wait_for_vfork_done() calls leave(false) and this races with freezer, CGRP_FREEZE is already set but JOBCTL_TRAP_FREEZE is not. This sets TIF_SIGPENDING to ensure the task won't return to user mode, thus it calls get_signal(). get_signal() doesn't see JOBCTL_TRAP_FREEZE, it notices ->frozen == T and does cgroup_leave_frozen(true) which clears ->frozen. Then the task calls dequeue_signal(), clears TIF_SIGPENDING and returns to user mode? Oleg.