Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4831465rwl; Mon, 3 Apr 2023 10:09:39 -0700 (PDT) X-Google-Smtp-Source: AKy350bbs9aRqklJLsmtldK3FFt0cZuzP99ZM3wMF+fVGfWATSR6SXRbqaPzqKX+BRqGhcQBa6Lr X-Received: by 2002:a17:902:d101:b0:1a1:c671:8bc9 with SMTP id w1-20020a170902d10100b001a1c6718bc9mr30765955plw.7.1680541778810; Mon, 03 Apr 2023 10:09:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680541778; cv=none; d=google.com; s=arc-20160816; b=UfAAEgoRTSze5H3PI2vn/5vvi+7+pkBHqkFx884Kui+47flypReKk1KIyF9Cg46EoF hj3AS1DKFFSSbB6OewN7nxiv5bqyU/sRaXFn2ZJ8QGNtuJGMFD9KASm8eJecCDa8xPxG 96kz85N3saLC3FtYct5mZBtZyUEaJqPqTX+NtE0jxQ1Yvw1wthUlnkOENbAKi/Mu9p4s WBQAFrFLz/KQ1DYPj31LFJFXR4Ue2iRJ/dX9ptj8arP7NbB+OpEwUbcjcmFupK5ZKjvH ZFWPPzlYBPsE1PPJLVxxAM8CoEcwCBnBtEiLDRQuQRaksMMEsaOzMmKQMAf/i8uU2JQF Me0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=VH+9LfYj7MbhreJ3Szg7MbF/2ha5Mr1B2SE9ELvDJ0M=; b=aY3lh/rg7oc4MXxE6VzsvtLzbAVHmqr9I1WW0AomTBwMeJVx5bJHJNO+2CmWV4sC5/ Qr7ccbBFM4ctpwyF8nin3ok4iL96X9glwkIlAm8qK7xQJEYw2Mn9eyLToUwkp5kJAmbY aCWV426EDn0JpDv8GPJeCcl15VFT7m9b7NwSZwWCLz2xwa//GAiD2at8FdhLlRQSw+b2 ZU3mT1AFQl8qSlQGxl1cjqWVaes5f5Xy//TCrtxfDkFeLPyyaWf9GxhYIC7hv8m0/jR1 CayTRV+p6kqWhN0SH8t2nXJIUkokk9XK4F87eflydmAZDwxcxMOlVCyUxCS+FP9fbsM+ 819g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=kJzshujX; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k1-20020a170902c40100b001a05e6bd125si8977657plk.25.2023.04.03.10.09.06; Mon, 03 Apr 2023 10:09:38 -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=@suse.com header.s=susede1 header.b=kJzshujX; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232772AbjDCQrm (ORCPT + 99 others); Mon, 3 Apr 2023 12:47:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231843AbjDCQrk (ORCPT ); Mon, 3 Apr 2023 12:47:40 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCEB1EC; Mon, 3 Apr 2023 09:47:39 -0700 (PDT) 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 32BF821C7A; Mon, 3 Apr 2023 16:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1680540458; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VH+9LfYj7MbhreJ3Szg7MbF/2ha5Mr1B2SE9ELvDJ0M=; b=kJzshujXHzyGF/fo1Q6O+NTAfxbHv0w+eS/aHfJzJJpZLWjta2sh/QjUpKpd7xOVZOUqAG foWWC1LD1MDZKWlD/2bjPg3adOFbAoTMyJ+y0SS4NM3u17g5KEaAwxlrTcHkXdWZ9eC3Ay +vjsofb4QjlQvBe/hTWTGhpKpwLxZus= 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 071C913416; Mon, 3 Apr 2023 16:47:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CVnSACoDK2RLaQAAMHmgww (envelope-from ); Mon, 03 Apr 2023 16:47:38 +0000 Date: Mon, 3 Apr 2023 18:47:36 +0200 From: Michal =?utf-8?Q?Koutn=C3=BD?= To: Waiman Long Cc: Tejun Heo , Zefan Li , Johannes Weiner , Christian Brauner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Juri Lelli , Dietmar Eggemann , gscrivan@redhat.com Subject: Re: [PATCH 3/3] cgroup/cpuset: Allow only one active attach operation per cpuset Message-ID: <20230403164736.lpjdpzxxnjlpxrqv@blackpad> References: <20230331145045.2251683-1-longman@redhat.com> <20230331145045.2251683-4-longman@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="kmhryddp6pf4i2i3" Content-Disposition: inline In-Reply-To: <20230331145045.2251683-4-longman@redhat.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 --kmhryddp6pf4i2i3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Mar 31, 2023 at 10:50:45AM -0400, Waiman Long wrote: > The current cpuset code uses the global cpuset_attach_old_cs variable > to store the old cpuset value between consecutive cpuset_can_attach() > and cpuset_attach() calls. Since a caller of cpuset_can_attach() may > not need to hold the global cgroup_threadgroup_rwsem, parallel cpuset > attach operations are possible. Do I understand correctly this consequence of the cpuset_attach_task() on the clone path? In that particular case (with CLONE_INTO_CGROUP) cgroup_mutex is taken, so the access the the old_cs variable should still be synchronized with regular migrations that are also under cgroup_mutex. > When there are concurrent cpuset attach operations in progress, > cpuset_attach() may fetch the wrong value from cpuset_attach_old_cs > causing incorrect result. To avoid this problem while still allowing > certain level of parallelism, drop cpuset_attach_old_cs and use a > per-cpuset attach_old_cs value. Also restrict to at most one active > attach operation per cpuset to avoid corrupting the value of the > per-cpuset attach_old_cs value. Secondly, semantically wouldn't a `void *ss_priv[CGROUP_SUBSYS_COUNT]` in struct cgroup_taskset make it simpler wrt the exclusivity guarantees? Thirdly, if my initial assumptino is right -- I'd suggest ordering this before the patch `cgroup/cpuset: Make cpuset_fork() handle CLONE_INTO_CGROUP properly` to spare backporters possible troubles if this is would be a fixup to that. Thanks, Michal --kmhryddp6pf4i2i3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQTrXXag4J0QvXXBmkMkDQmsBEOquQUCZCsDJQAKCRAkDQmsBEOq uS1zAP9TeBgc6NireljK5S1YDI/FdwDZFOk2ok2qCHerVad9/AD/bvO7HggZe7lO MYuH4JuHJxwswQfaPVy7pxI4M5JDtgc= =cc04 -----END PGP SIGNATURE----- --kmhryddp6pf4i2i3--