Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp9159052ybl; Fri, 17 Jan 2020 07:16:55 -0800 (PST) X-Google-Smtp-Source: APXvYqzIPg9USFNbWsBN9WnDegGJ7zPcTcL+YwX5Iyiv4CYfv7s3pYYbFg+NcHHAhMI5HJumixSh X-Received: by 2002:a05:6808:197:: with SMTP id w23mr3874117oic.46.1579274215313; Fri, 17 Jan 2020 07:16:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579274215; cv=none; d=google.com; s=arc-20160816; b=bIvCZmJCvNnowbkH0M8N3vQq/Eni1O8vAKv3uuKIK44QUhLUbyLKU2u/YjkDB8IUN/ OZgBr/eE69DRz9sfOeJEVa1HmMR+IfCqVEtEKMHxQqcRtexpl3y1wvbHRYk68PpociR0 th1zlKcVn0VROFR77DjD0LEY4Q02RCqUkJOUuJoKxup++SadmJ6okSdVhN75clMS6oQ9 VexH8NuHUuTEP7xgGia59DqUtI+O+as5hRkLDpbo0MyfWQjQFRRp+zbo7ZyLnbMb1yGK Fc/abKfLvxPByr24yL8hWlaFOBWrb1UdbkPvq+vBM4fANfl6/5Xo1vvOHP+yr5CeVZcW EH9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Vo1Izpa0QpEMU5f21vGyPGqhzpL4ndVCfzryVBesP/M=; b=By/97zt71/MtwEbxBbosAgYHioQYsmbOIHbG+lxMeUsJ+W9+sL/yW+L/gXJweR/pNB PRLoKHk43hXS+C9kobWe6YcKGeB1d8eXf+5TD8QF6FP0LcrnJ1E97Ub7Z3ScMw7qTJ9l QRiXwkOBqMDJzU+xgrNaBcGvwAjb/J+1a2+5uKeVzHcg28zNVrltVnAnZUtQvz+A7Z8G SxAoaEMSKI3hCyNAtzlySqFz2sZbs2uL+HJoVV2k7u89McBgDkZRHul9wLjMf2F/V9aV UsR/pC4MABaE+zyFD31BKA94Rk5zfudpdIaXeVEj0McDwSZZ05Vz/NlS+d8OKaISg7DX jpGA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 38si6232554otu.166.2020.01.17.07.16.43; Fri, 17 Jan 2020 07:16:55 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729113AbgAQPPs (ORCPT + 99 others); Fri, 17 Jan 2020 10:15:48 -0500 Received: from mx2.suse.de ([195.135.220.15]:60056 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728739AbgAQPPr (ORCPT ); Fri, 17 Jan 2020 10:15:47 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C73C5AF41; Fri, 17 Jan 2020 15:15:45 +0000 (UTC) From: =?UTF-8?q?Michal=20Koutn=C3=BD?= To: cgroups@vger.kernel.org Cc: Johannes Weiner , Li Zefan , Tejun Heo , alex.shi@linux.alibaba.com, guro@fb.com, kernel-team@android.com, linger.lee@mediatek.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com, shuah@kernel.org, tomcherry@google.com Subject: [PATCH 2/3] cgroup: Iterate tasks that did not finish do_exit() Date: Fri, 17 Jan 2020 16:15:32 +0100 Message-Id: <20200117151533.12381-3-mkoutny@suse.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200117151533.12381-1-mkoutny@suse.com> References: <20200116043612.52782-1-surenb@google.com> <20200117151533.12381-1-mkoutny@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org PF_EXITING is set earlier than actual removal from css_set when a task is exitting. This can confuse cgroup.procs readers who see no PF_EXITING tasks, however, rmdir is checking against css_set membership so it can transitionally fail with EBUSY. Fix this by listing tasks that weren't unlinked from css_set active lists. It may happen that other users of the task iterator (without CSS_TASK_ITER_PROCS) spot a PF_EXITING task before cgroup_exit(). This is equal to the state before commit c03cd7738a83 ("cgroup: Include dying leaders with live threads in PROCS iterations") but it may be reviewed later. Reported-by: Suren Baghdasaryan Fixes: c03cd7738a83 ("cgroup: Include dying leaders with live threads in PROCS iterations") Signed-off-by: Michal Koutný --- kernel/cgroup/cgroup.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index b56283e13491..132d258e7172 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -4492,11 +4492,12 @@ static void css_task_iter_advance(struct css_task_iter *it) goto repeat; /* and dying leaders w/o live member threads */ - if (!atomic_read(&task->signal->live)) + if (it->cur_list == CSS_SET_TASKS_DYING && + !atomic_read(&task->signal->live)) goto repeat; } else { /* skip all dying ones */ - if (task->flags & PF_EXITING) + if (it->cur_list == CSS_SET_TASKS_DYING) goto repeat; } } -- 2.24.1