From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9A40ECAAD8 for ; Fri, 23 Sep 2022 07:29:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D84780008; Fri, 23 Sep 2022 03:29:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 960E280007; Fri, 23 Sep 2022 03:29:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D9B580008; Fri, 23 Sep 2022 03:29:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6909180007 for ; Fri, 23 Sep 2022 03:29:06 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 382121A0914 for ; Fri, 23 Sep 2022 07:29:06 +0000 (UTC) X-FDA: 79942523892.04.0105936 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf18.hostedemail.com (Postfix) with ESMTP id B6BE51C0003 for ; Fri, 23 Sep 2022 07:29:05 +0000 (UTC) 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 3CD44218FA; Fri, 23 Sep 2022 07:29:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1663918144; 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: in-reply-to:in-reply-to:references:references; bh=rOM18LotnWoAueDS7CKAxKNZg+usqMDivdcE9JRJPBE=; b=dVnRMWYNhplQavDtc54h2Ex/j2jYR77RBKGgq9v2Rjc1hmm4joAkkKC8VCpEp/rjz3GJ3D E2XRU17CR4X2WBeCgaI2Yt3Emris/lMgFiGkurmrvA65OOPU02Kjg7PUOixpnvsGhUOrLK X1I7y+0RI28a/Znu5Spp2d+yb3u9Xq0= 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 2C79913A00; Fri, 23 Sep 2022 07:29:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id JIcMCkBgLWM9bAAAMHmgww (envelope-from ); Fri, 23 Sep 2022 07:29:04 +0000 Date: Fri, 23 Sep 2022 09:29:03 +0200 From: Michal Hocko To: Zhongkun He Cc: hannes@cmpxchg.org, roman.gushchin@linux.dev, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, lizefan.x@bytedance.com, wuyun.abel@bytedance.com Subject: Re: [External] Re: [PATCH] cgroup/cpuset: Add a new isolated mems.policy type. Message-ID: References: <20220904040241.1708-1-hezhongkun.hzk@bytedance.com> <0e5f380b-9201-0f56-9144-ce8449491fc8@bytedance.com> <93d76370-6c43-5560-9a5f-f76a8cc979e0@bytedance.com> <120cb50d-d617-a60a-ec24-915f826318f1@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <120cb50d-d617-a60a-ec24-915f826318f1@bytedance.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663918145; a=rsa-sha256; cv=none; b=qm/9LLLLolbbbDg6jir+exH9zD5YCY7eyj4DSrHb0P25JAT019upLFLvO9WVCN0VNyyi7v sP6keWKNfRZVxj5aPqHDWsROKKTAfH29GqSWBj7CMYkNDMwIKa4YtCzZ2FYzIsb9YwU8c6 Z8UGIqBWRqsmUIkQHja/NLseP1Eikko= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=dVnRMWYN; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf18.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663918145; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=rOM18LotnWoAueDS7CKAxKNZg+usqMDivdcE9JRJPBE=; b=jdEWe3YUbA63jZJiVgIxFvRHTZY5C82PWK2+SaaPGy+zMQtCMYExvD+KpXIgRcw4MsUsSw tSw1AJUv7TX6fjJGtTt0D5FI9uRM5PEsrHX/0O0C81eM/wlPC46k+++a33ri6ybvZuvBkW OnE/sNMjB962tnJw9RiWgNJB9g/R8p8= X-Stat-Signature: dhy1syskriwpdks3jttkqn1xk15yuigq X-Rspamd-Queue-Id: B6BE51C0003 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=dVnRMWYN; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf18.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com X-Rspamd-Server: rspam05 X-Rspam-User: X-HE-Tag: 1663918145-58984 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed 14-09-22 23:10:47, Zhongkun He wrote: > > > > > > > Back to the previous question. > > > > > The question is how to implement that with a sensible semantic. > > > > > > > > Thanks for your analysis and suggestions.It is really difficult to add > > > > policy directly to cgroup for the hierarchical enforcement. It > > > > would be a good idea to add pidfd_set_mempolicy. > > > > > > Are you going to pursue that path? > > > Hi Michal, thanks for your suggestion and reply. > > > > > Are you going to pursue that path? > > > > Yes,I'll give it a try as it makes sense to modify the policy dynamically. > > > > Thanks. > > Hi Michal, i have a question about pidfd_set_mempolicy, it would be better > if you have some suggestions. > > The task_struct of processes and threads are independent. If we change the > mempolicy of the process through pidfd_set_mempolicy, the mempolicy of its > thread will not change. Of course users can set the mempolicy of all threads > by iterating through /proc/tgid/task. > > The question is whether we should override the thread's mempolicy when > setting the process's mempolicy. > > There are two options: > A:Change the process's mempolicy and set that mempolicy to all it's threads. > B:Only change the process's mempolicy in kernel. The mempolicy of the thread > needs to be modified by the user through pidfd_set_mempolicy in > userspace, if necessary. set_mempolicy is a per task_struct operation and so should be pidfd based API as well. If somebody requires a per-thread-group setting then the whole group should be iterated. I do not think we have any precendence where pidfd operation on the thread group leader has side effects on other threads as well. -- Michal Hocko SUSE Labs