Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4590493rwl; Tue, 28 Mar 2023 08:46:46 -0700 (PDT) X-Google-Smtp-Source: AKy350ZO5GQMLaPZKO8KNn+mtDsB04S3JdqN+DKCnBcA+ulXd0wCFJMczHKYafDPxoNazYd3PO3s X-Received: by 2002:a17:903:188:b0:19c:f096:bbef with SMTP id z8-20020a170903018800b0019cf096bbefmr19208732plg.49.1680018406611; Tue, 28 Mar 2023 08:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680018406; cv=none; d=google.com; s=arc-20160816; b=a7BZK1aGc6B2qpX7BPMTHvB4yu1FhnkCUXlGf3F1goR1gop9gNlmQNo+2MqagR6/M+ EdiS5rLsA1WNTtmuQTPLvY9ComRq2tg6/TFC5grhfxvudpAMw1wk73zemq7TM5MuxsIS c5rx08O1G9TitM+Wu0vVq2KZmHqnZTfrg9AQ6RYWkaffS8NWd/YEbzIF5PqVxoRs47cG gfu2KrmoV59UOJCV06uMNPVgPw+PALGnOiSTeJLGbTujSYyazf1sVMP4u3TXcGNOgJNk xBPywCkbaVYLTzTU+iG4NAHHcHFDJKBda5ZcDFINwsUNIkq0rYHZJl2yM1yUXI3lduOa 3FAQ== 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=DToZxMIbzKouA77BTPxq+LZsVx5hg7lsRbsCS5tbvKQ=; b=CY0l4UP3MAfVF9pdWV8hn9U4V6hrkZX0gKsRJG8+49zjVSaRwzKiorAfAuEb1SpPm/ NtrCtJdlgA8XkfVCTblN6EpDxPQMCE2Hzn/wDaHmF5krwGhqQ2aSVmCJ/xeFycLvSHSH ykslt3knzlzjf++BXBlejqiuSa9gSYMbVhAnyma7nXkcF0GsJue4nyTbAAZOO0RLybcd 2jN0/r0uN8svKnJF0/vucySqL/WoEk0fta0A5OssCEfPL0kZnvvW2q8f5DQk4KmYetM3 KVs7mt7ryZm3y/QNbk0a/5i1Mo4d1AJPx4uKfloQNXDMovpfuqRFq5JauziktBVOB7p3 scww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CaGmLRhS; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u4-20020a17090341c400b001a1b0a828a8si28421002ple.621.2023.03.28.08.46.33; Tue, 28 Mar 2023 08:46:46 -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=@kernel.org header.s=k20201202 header.b=CaGmLRhS; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233403AbjC1Pnx (ORCPT + 99 others); Tue, 28 Mar 2023 11:43:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233325AbjC1Pnh (ORCPT ); Tue, 28 Mar 2023 11:43:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C122111142; Tue, 28 Mar 2023 08:42:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2FBBC61856; Tue, 28 Mar 2023 15:42:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D76B9C433EF; Tue, 28 Mar 2023 15:41:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680018121; bh=bjTXX9yzs6ldEzyQm2t7OD6dEAou4tttEBMCj7d1qu4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CaGmLRhSoe2tN/e+4Xm68kM9m9ONdejVT4hYPdtwJZHav25P4Glr1fKvju+8rHoTv Ks5VTIw++WHNYpnfjS2KGT3wsn7Pt371wkiy90PmbIxs6rCKUd2H3c/elL02bnMM04 1lewV3w1Xo3Jz6Ybp3Byh2sBZTzShbe/Ny1G7i6cE5JQtAwtpNwmvbtPOykFU8a5OE Gj7RPr4ej+xgNjTg4WuC34Dm+J/SjFesBsV+4mUTUDN1SqPlv4JALXnUNl/eIS2krJ VI/KOhHK7DDkgCCpbSeduub2XAMT1m2XqcVlmwyWY39xkBNOb/mUStiuN9rjiWCaO1 iP0X5N+yIKT5A== Date: Tue, 28 Mar 2023 17:41:56 +0200 From: Christian Brauner To: Tejun Heo , Johannes Weiner Cc: Zefan Li , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, gscrivan@redhat.com Subject: Re: CLONE_INTO_CGROUP probably needs to call controller attach handlers Message-ID: <20230328154156.kcm4nha2jeej74rr@wittgenstein> References: <20230328153943.op62j3sw7qaixdsq@wittgenstein> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230328153943.op62j3sw7qaixdsq@wittgenstein> X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,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 On Tue, Mar 28, 2023 at 05:39:52PM +0200, Christian Brauner wrote: > Hey, > > Giuseppe reported that the the affinity mask isn't updated when a > process is spawned directly into the target cgroup via > CLONE_INTO_CGROUP. However, migrating a process will cause the affinity > mask to be updated (see the repro at [1]. > > I took a quick look and the issue seems to be that we don't call the > various attach handlers during CLONE_INTO_CGROUP whereas we do for > migration. So the solution seems to roughly be that we need to call the > various attach handlers during CLONE_INTO_CGROUP as well when the > parent's cgroups is different from the child cgroup. I think we need to > call all of them, can, cancel and attach. > > The plumbing here might be a bit intricate since the arguments that the > fork handlers take are different from the attach handlers. But note, as Johannes already pointed out somewhere else, that there's probably a lot of code that doesn't apply to the CLONE_INTO_CGROUP case so it might also make sense to just move the missing pieces into the fork handlers.