From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 3B1353BBFC4 for ; Wed, 1 Jul 2026 20:19:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782937165; cv=none; b=T70w/jEg4X4vFQ01P4vI+EsI8CmifQYpOT9nZ6iHWo0zXklrajoeE9TZ/H4SFL6WdaL5LiMDX92vrYspOhgTyQ5hwnN1x5NpG9q5DhJlAzrZJ3Krj+uUa9aEDFN40zOT3evPM+gB9WBhiF4DYD/hUNIX/qp/A4MGWAb+cSH/7q0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782937165; c=relaxed/simple; bh=P2XaUmrl//82i1qJCceBWozgG8tYQzAsnfdiZDbolvE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=lJduYNQ1ogf427/Sl2TGqb1B9tFKiHdbnCDahEiNgXQehg573CGMDz2aS/R8++ic9xJ8+7LUWfVSspjYl0AMffDOCHBVkZKDkJ9MZS6WfgygzCm04G8MAlgwtzRI9iEKxc5RPBN7uDyKna+5DOwrpPpMi9j+aLQ+WyYKlj6yHGs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=A+xtj9qG; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="A+xtj9qG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782937162; 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=79DoWJeAeXloYm2n+Rci/dmY81HSXAaiftH5DSNv554=; b=A+xtj9qGSu1PdJb8g7wGxZ3VRVpkM4NTUVef6VMX94C+3weHs4EDIzAirjBe3Sc1JEZ0JH JuqSHIDUGILyxAS+1iYq3zQvp0KoZBBFkrEDEd3rtlwffK3zATv+JXUPHGuMj9JiNi9hHp GYgpZoI2gPaNvUeY299+A3NSDYCgUMA= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-272-kZQShflBM2mh9OFVBVp14A-1; Wed, 01 Jul 2026 16:19:16 -0400 X-MC-Unique: kZQShflBM2mh9OFVBVp14A-1 X-Mimecast-MFC-AGG-ID: kZQShflBM2mh9OFVBVp14A_1782937155 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 53DF41926B8F; Wed, 1 Jul 2026 20:19:14 +0000 (UTC) Received: from [10.2.16.170] (unknown [10.2.16.170]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 019B630001BE; Wed, 1 Jul 2026 20:19:10 +0000 (UTC) Message-ID: Date: Wed, 1 Jul 2026 16:19:09 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH-next v9 03/11] cgroup/cpuset: Prevent race between task attach and cpuset state change To: Ridong Chen , Tejun Heo , Johannes Weiner , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Shuah Khan , Juri Lelli Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Aaron Tomlin , Guopeng Zhang References: <20260630033344.352702-1-longman@redhat.com> <20260630033344.352702-4-longman@redhat.com> Content-Language: en-US From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 On 6/30/26 9:41 PM, Ridong Chen wrote: >> @@ -3246,7 +3268,12 @@ ssize_t cpuset_write_resmask(struct >> kernfs_open_file *of, >>           return -EACCES; >>         buf = strstrip(buf); >> -    cpuset_full_lock(); >> + >> +    /* cpuset_mutex acquired in wait_attach_done_lock() */ >> +    mutex_lock(&cpuset_top_mutex); >> +    cpus_read_lock(); >> +    wait_attach_done_lock(); >> + > > Would it be cleaner to just pass this into cpuset_full_lock() as a flag? > > void cpuset_full_lock(bool wait_attach) > { >       mutex_lock(&cpuset_top_mutex); >       cpus_read_lock(); >       if (wait_attach) >               wait_attach_done_lock(); >       else >               mutex_lock(&cpuset_mutex); > } > Then the two write paths become a single cpuset_full_lock(true). The > downside is the other 6 callers would need cpuset_full_lock(false). > Not sure it's worth it — what do you think? I would like to put wait_attach_done_lock() at places where it will wait for the completion of the attach operation. Putting it inside cpuset_full_lock() will make it harder to find out which operations will need to wait for task attach. So I will keep the code as is. Cheers, Longman