Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2086908yba; Fri, 19 Apr 2019 11:52:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwP2xgbr7X9BoGOD/FQOTpFwMaThKJomh8xzFisp8BaXvfzSIUpI58N1Ts8b/OnBcMDKHwf X-Received: by 2002:aa7:8092:: with SMTP id v18mr5483747pff.35.1555699964374; Fri, 19 Apr 2019 11:52:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555699964; cv=none; d=google.com; s=arc-20160816; b=jp8bq1Jo+pe/h2YSYNF1kj2pUbck85lWtsRonAkiXowUrqXpfcHFQQeO90FzB2q3kW pLxP03iOkAv7BxzgwbAie9i38VeRJCTPe6DtpFTgd4cY1/0UvVqnZNzvONJl6k6hOwHI BsQqhLP43dod+WjQ6pX0OPYgqL0Sf411LKtnUWyzuehGsyx5F8HqPNNc/Wo4xVCxZOwr nI+MPDrczZGerEDDx+r5XFW3qlMDlJ/7p7+wwXa6Z24YnsO0D7B3anZXTqhORSXiQBCm Gmqj1TysIyHGrJaWbs/9lPTCBVNa6pp8f2fHye1uY5zbQCBy2lf/5l9Pa+5kASXOLnx5 Bz0w== 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=vt545D09TNzSjzGAv+r9jsWjpRII8LlbZbxRzEjZ/Q4=; b=T3IQB8VoNyMitk1GUFXwrGCi0DGCxdTQr+2NLZ8jmwCyCoRBQexygzfSVIZmbvf9Yt xQyNR29rUx8jYoc/eObEBmuercN3UDnUAmRSyF4vjNLJcaqDq4sgZlYDVYFxXMXudfvx lLQSFBAzMW8IXs1mfpBanEX2yfxdMTg4LlixgYdMVkjKEkHgRczF7s0SSx0VI+R8OrBu 3qLUUlRhyW3aGXGMYPdjb4Ry67RXNN+dj/vCiEKJyyYaQGGKw9Gnuo+sCgDY/b87tmSU Ny9wjfnyJEawclOb3fjU0kHCw1bfveBUS7q4wkh5SYtnCxsbPy+mWQBKjM692pl7NslT WBGQ== 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 d12si2366976pgl.386.2019.04.19.11.52.29; Fri, 19 Apr 2019 11:52:44 -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 S1728220AbfDSSvT (ORCPT + 99 others); Fri, 19 Apr 2019 14:51:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33962 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbfDSSvT (ORCPT ); Fri, 19 Apr 2019 14:51:19 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E803ACD4A8; Fri, 19 Apr 2019 16:26:02 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.38]) by smtp.corp.redhat.com (Postfix) with SMTP id 994D71001E98; Fri, 19 Apr 2019 16:26:01 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Fri, 19 Apr 2019 18:26:02 +0200 (CEST) Date: Fri, 19 Apr 2019 18:26:00 +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: <20190419162600.GC12228@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190419161118.GA23357@tower.DHCP.thefacebook.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 19 Apr 2019 16:26:03 +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: > > > Once again, suppose we race with CGRP_FREEZE. If JOBCTL_TRAP_FREEZE is already > > set then signal_pending() must be already T and we do not need recalc_sigpending? > > If JOBCTL_TRAP_FREEZE is not set yet, how can recalc_sigpending() help? > > This is paired with cgroup_task_frozen() check in recalc_sigpending_tsk(). Ooh, I didn't notice this version added cgroup_task_frozen() into recalc_sigpending_tsk() ... Honestly, I don't like this. But see another email I sent, we can cleanup this code later. > > > +static void cgroup_freeze_task(struct task_struct *task, bool freeze) > > > +{ > > > + unsigned long flags; > > > + > > > + /* If the task is about to die, don't bother with freezing it. */ > > > + if (!lock_task_sighand(task, &flags)) > > > + return; > > > + > > > + if (freeze) { > > > + task->jobctl |= JOBCTL_TRAP_FREEZE; > > > + signal_wake_up(task, false); > > > + } else { > > > + task->jobctl &= ~JOBCTL_TRAP_FREEZE; > > > + wake_up_process(task); > > > > 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? > > > static int ptrace_signal(int signr, kernel_siginfo_t *info) > > > { > > > /* > > > @@ -2442,6 +2483,10 @@ bool get_signal(struct ksignal *ksig) > > > ksig->info.si_signo = signr = SIGKILL; > > > sigdelset(¤t->pending.signal, SIGKILL); > > > recalc_sigpending(); > > > + current->jobctl &= ~JOBCTL_TRAP_FREEZE; > > > + spin_unlock_irq(&sighand->siglock); > > > + if (unlikely(cgroup_task_frozen(current))) > > > + cgroup_leave_frozen(true); > > > > Oh, and another leave_frozen below... > > Yeah, because of this new "goto fatal" shortcut. I understand, but the code doesn't look nice... but again, I can't suggest anything better at least right now, so please forget. > > > + 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? Oleg.