Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35554122rwd; Mon, 10 Jul 2023 09:03:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlFfV3qn4ugSoXHManRQdUrdV/RbppKZlU4oWTtdIk6imzVJflCcs7ii/bwfMFE+Ww1nncmm X-Received: by 2002:a17:902:b7c1:b0:1b9:e8d9:7e42 with SMTP id v1-20020a170902b7c100b001b9e8d97e42mr1081263plz.69.1689005013471; Mon, 10 Jul 2023 09:03:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689005013; cv=none; d=google.com; s=arc-20160816; b=IHOtRfNUQBxi9GnIoXAH21g5uaPH61gx0KN/c19qj0AaqxVsVClTGbFtp78y+l0sRD AOcW6hZS4F5SflpxxMVMwnq5r0NBekxSJn7Rm0RXe0zPuaw8E1Z8EnPM6VADLPbxmkJi TAu6QFbNxJzVBsDJSXiGS76q5kzUaUxtDx2TntrNBPuz0FDWfRCT+X/PZsuOLEqY091/ cyputOo21ZZWgRyxv/KPb7GdNhEgIJ2UPiWmJ3bo+8Ht1o9ME1JZXonRjN8WI+1cVTtW BNFflcw3IgGK+WCtDo5h/H5rA0zwT3C4O6usXvn3mkexE1sJHQbyMr23B+gAxgEikiyo yocA== 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=F0D7PqDIktc2dtIxI/bE8WlEAjuSUexO7v405cL9P8Q=; fh=DznoBkl4xawvTvQG4LS693DIzidlSW8/AR0rfFu5AQI=; b=Re+Fqk2clDRzmFhZnxzNDMZ1gz8jVP0JB/2vtHkqYsEb5Eoy62h3Wfz1DWfTNdToRe 8rHQyKAqACJZbXNk1k8gYs86rhiGT7xr7X/8zhGUMw3Tqg7BaUbxW/HOA489iF+2uLy+ LhrDVlOjkrQaBoqxGFzs9GueyK6JKYrWkpcBETSbRK02iDQwUToVbA0yOd81bvcI6qe6 OBF/GJT/XK0IySk9exT7Er4TA8i07gltHMcnKP1aGgfVMlCNI2AQeVdBHCId18SCffBX wygfp6vsJu9FKysjAigHmX5OJFyvOT8s/JyZwlX6b9aP6bdWDu2HQTPG38JXNXjSuAbN uHlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UjxRtMV7; 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 y12-20020a17090322cc00b001b886a0c366si74291plg.122.2023.07.10.09.03.18; Mon, 10 Jul 2023 09:03:33 -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=UjxRtMV7; 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 S231624AbjGJPl3 (ORCPT + 99 others); Mon, 10 Jul 2023 11:41:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229848AbjGJPl2 (ORCPT ); Mon, 10 Jul 2023 11:41:28 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7FE3129 for ; Mon, 10 Jul 2023 08:40:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689003639; 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=F0D7PqDIktc2dtIxI/bE8WlEAjuSUexO7v405cL9P8Q=; b=UjxRtMV7Z4eK+0yiYCTKg7uKq/umX8OWTgMmkOkNIwPmpNwDbRP8J+YUnp6J6T65W2UdGU 59K7WXzbL4X64tRe2iUHoC+DDFlFbFlPx4Qo1bP/zrf+Zyb4ZwZFHTBbHsNiiuFck5u/Pl 2GPtWVPU5CWNveZnKrMx5QXoN/MhzRo= 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-633-gsY0jYqTNUyCCf89q1R_CQ-1; Mon, 10 Jul 2023 11:40:37 -0400 X-MC-Unique: gsY0jYqTNUyCCf89q1R_CQ-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 CF55D185A792; Mon, 10 Jul 2023 15:40:36 +0000 (UTC) Received: from [10.22.33.187] (unknown [10.22.33.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67DFB2166B26; Mon, 10 Jul 2023 15:40:36 +0000 (UTC) Message-ID: <74f1906e-fe58-c745-a851-b160374f7acf@redhat.com> Date: Mon, 10 Jul 2023 11:40:36 -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: update parent subparts cpumask while holding css refcnt Content-Language: en-US To: =?UTF-8?Q?Michal_Koutn=c3=bd?= , Miaohe Lin Cc: tj@kernel.org, hannes@cmpxchg.org, lizefan.x@bytedance.com, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230701065049.1758266-1-linmiaohe@huawei.com> From: Waiman Long In-Reply-To: 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_BLOCKED,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/10/23 11:11, Michal Koutný wrote: > Hello. > > On Sat, Jul 01, 2023 at 02:50:49PM +0800, Miaohe Lin wrote: >> --- a/kernel/cgroup/cpuset.c >> +++ b/kernel/cgroup/cpuset.c >> @@ -1806,9 +1806,12 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs, >> cpuset_for_each_child(cp, css, parent) >> if (is_partition_valid(cp) && >> cpumask_intersects(trialcs->cpus_allowed, cp->cpus_allowed)) { >> + if (!css_tryget_online(&cp->css)) >> + continue; >> rcu_read_unlock(); >> update_parent_subparts_cpumask(cp, partcmd_invalidate, NULL, &tmp); >> rcu_read_lock(); >> + css_put(&cp->css); > Apologies for a possibly noob question -- why is RCU read lock > temporarily dropped within the loop? > (Is it only because of callback_lock or cgroup_file_kn_lock (via > notify_partition_change()) on PREEMPT_RT?) > > > > [ > OT question: > cpuset_for_each_child(cp, css, parent) (1) > if (is_partition_valid(cp) && > cpumask_intersects(trialcs->cpus_allowed, cp->cpus_allowed)) { > if (!css_tryget_online(&cp->css)) > continue; > rcu_read_unlock(); > update_parent_subparts_cpumask(cp, partcmd_invalidate, NULL, &tmp); > ... > update_tasks_cpumask(cp->parent) > ... > css_task_iter_start(&cp->parent->css, 0, &it); (2) > ... > rcu_read_lock(); > css_put(&cp->css); > } > > May this touch each task same number of times as its depth within > herarchy? I believe the primary reason is because update_parent_subparts_cpumask() can potential run for quite a while. So we don't want to hold the rcu_read_lock for too long. There may also be a potential that schedule() may be called. Cheers, Longman