Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp422565lqb; Fri, 24 May 2024 02:34:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUni1H2dG4WaYv7zT1hKmGQju6A6MbRql4lE9kgDY9ZJzuTwCpeTFWY88qvAhsl5VkVkgDMBF+dv5PDP9bNPz0CM49UbygvyepUMo3sUw== X-Google-Smtp-Source: AGHT+IHpT7tLEUWvtvYzdq66oq7zZE7wXnEAWacA7NSDW64E2Z+SxibipTSS1nmRwcgieIBjXfMr X-Received: by 2002:a92:2902:0:b0:36c:8a33:c054 with SMTP id e9e14a558f8ab-3737b2e32demr14028995ab.11.1716543276818; Fri, 24 May 2024 02:34:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716543276; cv=pass; d=google.com; s=arc-20160816; b=bJKMZq1mp/OzBZ6kMq10pKvw4V54E1diQGlpxIub5jfbTkdWYD//YOiRP4cpVByto1 qEZbg/4x3Q8tGI4NLpA3kO4rT83vT0MzeCasAJuoVrUwErrMDHHv/MximmBbu1hYErxH m2tPJWphfbxDvtSQf+gWbZLSfqkQRqFgu4E3d3z9ygV36EIgqoT/WzfV06wDAtoq06V3 15KuXEA92ieX4eaUXIJErldEO7GElqovUgvE2HGsM4UOKTcmVof5rio9mjiISQxvRNHz L22suNCbXqTPF6Zdry9tQNGDtyr6rPwNZKbDrsSKWvO5b1m5YTHD6AZRzlVCmReGbrUl 1drg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=y2H6uPVVJ7Kn3EAXl4cRmHjC9W0/OLxSQk2aIsIQ84E=; fh=dqjoFo9c0lN3wRqwp5phCzwGqBFKsFsqmzK3Fczacb0=; b=iVDUbNkgQrZYxkTWJ1DCvw0tgFlg9na/TLE1X9K7BdXgS1gY20sTGy1Falrz3VgHOT cMwped5iyntSV1DS+D05vP8q7Pms+PfUH837+SFSV4Fv5pUp29JEtsv5oSLAikS5xpUL 9y4CZ8nGrQxerISyZi7+7llRsaDXorFK0m9fw+8pU9id9ubAecp6bkCeRBx14EgsvSGN v3Ekv1bm2jpSw7LuPU7+oF/iHQ1dybrliiKDMJqAANFBNmAxnSwSpJ33PTOxdpZGyh6B R4j6cnE/g8liDuXOzYw1QqWslsg1h0VWVZSJntbbYM1mI/KQ523ZDxS6JvGuBQ7Om6QH pjqA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-188558-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188558-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-682288e7114si974317a12.483.2024.05.24.02.34.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 02:34:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-188558-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-188558-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188558-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C0CFA282CA8 for ; Fri, 24 May 2024 09:34:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD18F8529E; Fri, 24 May 2024 09:34:30 +0000 (UTC) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 797AD84DEB; Fri, 24 May 2024 09:34:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716543270; cv=none; b=GyuiRPtXK0JWbZDCLMygQ2KpsjGMK3xo+PuRNDdinDVpjOfnPiwS0Wu2hQ5mPQvgDQKDIJTPRF7Mu52yYTBFmRO4WPcoWDLoCGbp8XoucA74ikyRaSeqkvDPrE8TV4tfUap5pTTO7vr7J0UVmvwCKbZRqWhUHtWBKblpw2CRNSE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716543270; c=relaxed/simple; bh=TFJHvdM4FlR8aIwPk/1yrjPqD09QYCBjVxerKE0oB5o=; h=Message-ID:Date:MIME-Version:Subject:From:To:CC:References: In-Reply-To:Content-Type; b=qG5wXi8U8sLFRfzuCIj3oIaaNrkK/L4dPo178Tw0+EuUa6GziZu6f6m21HDzNTzTbOT1HaZIsX4V6VPg2o//JpuF59t7MXRRTtIU8O4uOFFsvVcXhX0j4xaDk2Yq/iLE1O3FZlU3mTVzK++L8GC/TUGli8qKAgBd/Sfb29LZLJE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Vm0CK6tBFz1S5c8; Fri, 24 May 2024 17:30:53 +0800 (CST) Received: from dggpeml500023.china.huawei.com (unknown [7.185.36.114]) by mail.maildlp.com (Postfix) with ESMTPS id 070F91A0188; Fri, 24 May 2024 17:34:25 +0800 (CST) Received: from [10.67.110.112] (10.67.110.112) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 24 May 2024 17:34:24 +0800 Message-ID: <462f95c8-514d-6ba2-73ff-c5ae752114a2@huawei.com> Date: Fri, 24 May 2024 17:34:24 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH -next] cgroup/pids: replace can_attach and cancel_attach with attach hook Content-Language: en-US From: xiujianfeng To: , , CC: , References: <20240524091851.1539589-1-xiujianfeng@huawei.com> In-Reply-To: <20240524091851.1539589-1-xiujianfeng@huawei.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500023.china.huawei.com (7.185.36.114) Sorry, it's a mistake, please ignore this patch :( On 2024/5/24 17:18, Xiu Jianfeng wrote: > Currently pids_can_attach() always returns 0 and never fails, so the > can_attach() and cancel_attach() hooks can be replaced by attach(), > since attach() is guaranteed to succeed and don't need to fallback. > > Signed-off-by: Xiu Jianfeng > --- > kernel/cgroup/pids.c | 25 ++----------------------- > 1 file changed, 2 insertions(+), 23 deletions(-) > > diff --git a/kernel/cgroup/pids.c b/kernel/cgroup/pids.c > index 0e5ec7d59b4d..86d06f709957 100644 > --- a/kernel/cgroup/pids.c > +++ b/kernel/cgroup/pids.c > @@ -186,7 +186,7 @@ static int pids_try_charge(struct pids_cgroup *pids, int num) > return -EAGAIN; > } > > -static int pids_can_attach(struct cgroup_taskset *tset) > +static void pids_attach(struct cgroup_taskset *tset) > { > struct task_struct *task; > struct cgroup_subsys_state *dst_css; > @@ -207,26 +207,6 @@ static int pids_can_attach(struct cgroup_taskset *tset) > pids_charge(pids, 1); > pids_uncharge(old_pids, 1); > } > - > - return 0; > -} > - > -static void pids_cancel_attach(struct cgroup_taskset *tset) > -{ > - struct task_struct *task; > - struct cgroup_subsys_state *dst_css; > - > - cgroup_taskset_for_each(task, dst_css, tset) { > - struct pids_cgroup *pids = css_pids(dst_css); > - struct cgroup_subsys_state *old_css; > - struct pids_cgroup *old_pids; > - > - old_css = task_css(task, pids_cgrp_id); > - old_pids = css_pids(old_css); > - > - pids_charge(old_pids, 1); > - pids_uncharge(pids, 1); > - } > } > > /* > @@ -374,8 +354,7 @@ static struct cftype pids_files[] = { > struct cgroup_subsys pids_cgrp_subsys = { > .css_alloc = pids_css_alloc, > .css_free = pids_css_free, > - .can_attach = pids_can_attach, > - .cancel_attach = pids_cancel_attach, > + .attach = pids_attach, > .can_fork = pids_can_fork, > .cancel_fork = pids_cancel_fork, > .release = pids_release,