From patchwork Wed May 3 12:53:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Michal_Koutn=C3=BD?= X-Patchwork-Id: 89739 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1304197vqo; Wed, 3 May 2023 05:56:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5MNTUzZYRn7UC/BTvJZiFtQXFT5AAYe41fTWHD1G6xMukeamUQVa9HQ+K9cY48mncufP5Q X-Received: by 2002:a17:90a:b106:b0:234:889f:c35d with SMTP id z6-20020a17090ab10600b00234889fc35dmr21915759pjq.3.1683118616464; Wed, 03 May 2023 05:56:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683118616; cv=none; d=google.com; s=arc-20160816; b=DH/TV11dKvSFzlexKXANFQfgi+EYyJcLrScKQ/6FsHejDmFkfN8a3DVAa9cJjWR0IF 90FpaXqTZAIyud4Wduvpot5bY6MhudAbbSUp91UPZnpBtn06gEaognhAsupLbWdFtpI3 b5+x8m9ekYS08BtxY38Uq8UwL0bxlr9svQ2uS3A+b+09sDdrDtGyN/tf8tILBm+ImkZb IJYyTtSaFmHzMfv7fw/6lNRVAOXYMSOiP0jrmSRZSQCeYz7vDJ1obkwfARb/Ky6CI4R/ q+qxguull2+6D/2XiYuQF/rArUhSyeAxIWUHWobP/xjK4gU8Is0jwEt4nurdPT2o1sWJ OUQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=XGQuVbsJSpb3XLS+PmIsQvClRUbeKXxErey9Ewqz9fM=; b=lq0bvArp32WIRrs2SkwgXue3Aj8s28hIG9VuIRvJqRUTaqoMxRH2FxjX5oAY6ey2Ar h6ki3epAHQG/i4GTQ8rozRmeEDP5n80c1esmIEF9tfvg6VMxalvcMYlAVgcyrrRPAS16 mNrNcLp81hfqoidV+uTW0NI6YyDXyEOsBZDwr+vI9idqi4shAL3zzxUzWBiAKz9/HKN9 Q3eTdA5HibfyYNQsvKA7lUDccIUryi4OODJ4DPKZ1FyaYqWWS3DEp2yMqjzGEUSLj6Nx N2g95bW8wkvxtRDD5B1vzna1OqzXtzbDowX7A2/K9M9CAYwkXPz3L94voGFGD6o4J/pZ AsEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=chZi2O4e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i1-20020a17090a058100b0024c0c3c81e4si1394098pji.83.2023.05.03.05.56.42; Wed, 03 May 2023 05:56:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=chZi2O4e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229954AbjECMy1 (ORCPT + 99 others); Wed, 3 May 2023 08:54:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229916AbjECMyU (ORCPT ); Wed, 3 May 2023 08:54:20 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 107BA59FB; Wed, 3 May 2023 05:54:04 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B7B38227F7; Wed, 3 May 2023 12:54:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1683118442; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XGQuVbsJSpb3XLS+PmIsQvClRUbeKXxErey9Ewqz9fM=; b=chZi2O4e9/GB1oKRKC9Hfqkl6IfrkSSPGMUBfDu9Vj7bOqk3o22tv2oyX3AvbbHqWiE8xK FQGsfFkRsAvGEXzIwnGGKoI7/5atVK12eFnEpLC8iBeRSvv6QsESycZXHZ6S2Wa/i/OSIU OexiNAKjs9f7vG6vfdJfQ4anBsioP8M= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 983AE13584; Wed, 3 May 2023 12:54:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ojRRJGpZUmSWDQAAMHmgww (envelope-from ); Wed, 03 May 2023 12:54:02 +0000 From: =?utf-8?q?Michal_Koutn=C3=BD?= To: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tejun Heo , Zefan Li , Johannes Weiner , Benjamin Berg Subject: [RFC PATCH] cgroup: Return error when attempting to migrate a zombie process Date: Wed, 3 May 2023 14:53:59 +0200 Message-Id: <20230503125359.14789-1-mkoutny@suse.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764877786452970516?= X-GMAIL-MSGID: =?utf-8?q?1764877786452970516?= Zombies aren't migrated. However, return value of a migration write may suggest a zombie process was migrated and causing confusion about lack of cgroup.events:populated between origin and target cgroups (e.g. target cgroup rmdir). Notify the users about no effect of their action by a return value. (update_dfl_csses migration of zombies still silently passes since it is not meant to be user-visible migration anyway.) Suggested-by: Benjamin Berg Signed-off-by: Michal Koutný --- kernel/cgroup/cgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Reasons for RFC: 1) Some users may notice the change, 2) EINVAL vs ESCHR, 3) add a selftest? diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 625d7483951c..306547dd7b76 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -2968,7 +2968,8 @@ struct task_struct *cgroup_procs_write_start(char *buf, bool threadgroup, * become trapped in a cpuset, or RT kthread may be born in a * cgroup with no rt_runtime allocated. Just say no. */ - if (tsk->no_cgroup_migration || (tsk->flags & PF_NO_SETAFFINITY)) { + if (tsk->no_cgroup_migration || (tsk->flags & PF_NO_SETAFFINITY) || + !atomic_read(&tsk->signal->live)) { tsk = ERR_PTR(-EINVAL); goto out_unlock_threadgroup; }