Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp29199924rwd; Wed, 5 Jul 2023 08:30:55 -0700 (PDT) X-Google-Smtp-Source: APBJJlG5I8eTPK/CfCj5szLTCe26J+w48R4tMzRKR7mZRKYnRjA4Izrf0QNOAqkSsaaM8eq7Zx/q X-Received: by 2002:a17:902:eccb:b0:1b8:9b78:df44 with SMTP id a11-20020a170902eccb00b001b89b78df44mr5913862plh.20.1688571055371; Wed, 05 Jul 2023 08:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688571055; cv=none; d=google.com; s=arc-20160816; b=RSYFeL9VLOlJHx8+llVNpOPAxSAoPOmWvilW9va1Ft1OWgLBLB0h+BlO0MvBDEZ5c1 9DBi/TCMrHuWtJad/FYQomkbtDU0UEqvedHHAWdvP4ZiAW3NQjpByENTc+FvDqMNmS22 1OA3fwtgOY+HoMd9faNzQeoGqDaOheb/aTKnk6NKEjDoSHfRvPhrYlKc0tP8JqNJwBpF aJbdQbm5Ojkc3QEhQ/t3yOREqG3vNEc4QqLiDuWI2V1tCLEvHfAb83HBPG+AtDaq54UX X5TEUwNGxHKsgpfd68RZ+MXwkN2kWvGyBuPcK0rjSfCTPp4OiT56u9Hdffnc7E7m0svl /ctg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=UyM5IDrf51eZ/kcZjAxbwOacXO+LNKpyPjbVqqLXG8s=; fh=Fz1Bbx78LbsfglJfwhrSLzDy/f30RJGfcz51A16dyJ8=; b=ldwDylLK7dh2n9o+bHuDziVb/1TCp0DURGs3ypDRwqVWmfbBILz9nyTew34c+EUihB Gb3zIdBfpTqAOQVFKAUPcn8OGzKTjIaMS6Jy2PKD52oonFJWkNbjQrnZsjhXMsK/3KY6 ctoxO3KJfiwW4bq+9o0JEUnMhnC2fQtj+mTHS6bx4AJ2qWCdEb2qYuqfj/B3OrBqorRa eXvfVlzgucLxUE+WY3fcEpnJ8UrY+k7Ca0ml+c/JJlVbdStJwfCv6qh+07OEQVpAm/3Z ReCQmks5m/dwdh8nQxCiKMizvO7+4WUSnuR2L8l8dCEfZw+vDnBrwfb0oee5NWpTUgM0 bs5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Tcoc7i4o; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020a170903018900b001b8918da8cdsi8154987plg.205.2023.07.05.08.30.40; Wed, 05 Jul 2023 08:30:55 -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=@redhat.com header.s=mimecast20190719 header.b=Tcoc7i4o; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232714AbjGEOtv (ORCPT + 99 others); Wed, 5 Jul 2023 10:49:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232706AbjGEOtt (ORCPT ); Wed, 5 Jul 2023 10:49:49 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C70BD1712 for ; Wed, 5 Jul 2023 07:49:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688568546; h=from:from: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; bh=UyM5IDrf51eZ/kcZjAxbwOacXO+LNKpyPjbVqqLXG8s=; b=Tcoc7i4oRiAs2zgWcJekxzgSldm4tRAsbFu8dl2oOsAeHrkfbLRLvEy/OJxi6qh3IJJar7 PxGROIqyXvguySgwFAUkWYd8sljXTHAMP5uy22OePubpdU2DQMDJiLzsGEYUtmXUu8F/NI PbF3BFR7b6xiXDRcALAX84kVsA5V/5E= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-434-pI7A_wqlP9eWF9sY32YdEA-1; Wed, 05 Jul 2023 10:49:03 -0400 X-MC-Unique: pI7A_wqlP9eWF9sY32YdEA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D0CD8185A7A2; Wed, 5 Jul 2023 14:49:02 +0000 (UTC) Received: from [10.22.8.133] (unknown [10.22.8.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67DBF2166B25; Wed, 5 Jul 2023 14:49:02 +0000 (UTC) Message-ID: Date: Wed, 5 Jul 2023 10:49:02 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH] cgroup/cpuset: simplify the percpu kthreads check in update_tasks_cpumask() Content-Language: en-US To: Miaohe Lin Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, tj@kernel.org, hannes@cmpxchg.org, lizefan.x@bytedance.com References: <20230704113049.1019118-1-linmiaohe@huawei.com> <33c2bf85-6def-fce9-9ea7-3b3e80db67b7@huawei.com> From: Waiman Long In-Reply-To: <33c2bf85-6def-fce9-9ea7-3b3e80db67b7@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On 7/5/23 01:56, Miaohe Lin wrote: > On 2023/7/5 11:14, Waiman Long wrote: >> On 7/4/23 07:30, Miaohe Lin wrote: >>> kthread_is_per_cpu() can be called directly without checking whether >>> PF_KTHREAD is set in task->flags. So remove PF_KTHREAD check to make >>> code more concise. >>> >>> Signed-off-by: Miaohe Lin >>> --- >>>   kernel/cgroup/cpuset.c | 2 +- >>>   1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c >>> index 58e6f18f01c1..601c40da8e03 100644 >>> --- a/kernel/cgroup/cpuset.c >>> +++ b/kernel/cgroup/cpuset.c >>> @@ -1230,7 +1230,7 @@ static void update_tasks_cpumask(struct cpuset *cs, struct cpumask *new_cpus) >>>               /* >>>                * Percpu kthreads in top_cpuset are ignored >>>                */ >>> -            if ((task->flags & PF_KTHREAD) && kthread_is_per_cpu(task)) >>> +            if (kthread_is_per_cpu(task)) >>>                   continue; >>>               cpumask_andnot(new_cpus, possible_mask, cs->subparts_cpus); >>>           } else { >> The initial intention was to ignore only percpu kthreads. The current code likely ignore all the kthreads. Removing the PF_KTHREAD flag, however, may introduce unexpected regression at this point. I would like to hold off for now until more investigation are done. > IMHO, the current code will ignore only percpu kthreads: > 1.If PF_KTHREAD is set in task->flags, this patch doesn't make any difference. > 2.If PF_KTHREAD is not set in task->flags, kthread_is_per_cpu will *always return false*. So this patch doesn't make any functional change. > > bool kthread_is_per_cpu(struct task_struct *p) > { > struct kthread *kthread = __to_kthread(p); > if (!kthread) > return false; > .... > } > > static inline struct kthread *__to_kthread(struct task_struct *p) > { > void *kthread = p->worker_private; > if (kthread && !(p->flags & PF_KTHREAD)) > ^^^^^^^^^^^^^^^^^^^^^^ > PF_KTHREAD is not set, so kthread = NULL. > kthread = NULL; > return kthread; > } > > Or am I miss something? Thanks for comment and review. Yes, you are right. I was that conscious when I reviewed the patch last night :-) Reviewed-by: Waiman Long