Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4587144rwl; Tue, 28 Mar 2023 08:44:09 -0700 (PDT) X-Google-Smtp-Source: AK7set8lYY4fCJ/eCYqdoEYy8/hKNKkaT1qHfCQ/acNaK9hnjvafZ2FBhzJftO3jOMpKRf5HeudP X-Received: by 2002:a05:6a20:be06:b0:d8:f082:437e with SMTP id ge6-20020a056a20be0600b000d8f082437emr16131196pzb.12.1680018249662; Tue, 28 Mar 2023 08:44:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680018249; cv=none; d=google.com; s=arc-20160816; b=nAmf0WHXnV5q2rLsh0ylVkzok0NTJHMezncy5iyN0PHuRQ1ocCBk5UK8zL+3QYWo3n 2hqc9jV3RXNL0DD8pOdVZK3UjV7nrgVlabK2/ulUJm2BmAiCGU7kcMovYQQmx/0BMFzn da/jkeNzi+a41ZAAxECvKWmRE28VVIoicmPlFep1dYlstqRO9tzOZsV8Ag3ouUF+LFId oFHq5H8UqigJn5m5bQtH7FET4A6uvsNmxq+jEmFLexPGDfATts84EFaSgmblufWAhjOR zmCiS571eZJOCBLAUcsGoPDOXDkpz7h1C0jrL6Mism71BMF5Jr/B+nlTSKM25AIevjgN t+zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=bm2MrEPyszxRmD7eWeSEITojITTA3y9rSJopaZVgCJI=; b=Rhspz5DBx2Sx9fF/47TRL9dTz2GbGvyJBz0xq0DoRAieYw6x0P/BTlMM8YXL1jOFkY 99pDJatwoCXVd4V7Lpnf2hD4CqtEeqgoaRg31tcMt1zQOFcEblGnnBF7/6gbSgOHTXGL emlbXrT3lTqfSepAnpuwbUADm7Ru8HJ3Q9f8IjOaOK4m20cyidffMiaiFB53Nuh7p5Yd R7Hkgmlyf6fRCC1Z6mwLsiN3L5+7JHqdXfUn52EmtvjC3L7n3OqB0sMjqziaxU2WQOEo xX9gk9R4C5DH5FRtVmdr8syo4rmwtfEBnMf8sDxGp53LIc8lRchqKSkuVqLWLpN7PoAj 2mNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=begcOk0D; 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 y3-20020a63e243000000b00502aed3b79esi30073470pgj.708.2023.03.28.08.43.56; Tue, 28 Mar 2023 08:44:09 -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=begcOk0D; 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 S233998AbjC1PlR (ORCPT + 99 others); Tue, 28 Mar 2023 11:41:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233362AbjC1PlA (ORCPT ); Tue, 28 Mar 2023 11:41:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEE04E18F; Tue, 28 Mar 2023 08:39:55 -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 ams.source.kernel.org (Postfix) with ESMTPS id 4110EB81BC3; Tue, 28 Mar 2023 15:39:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55D67C433EF; Tue, 28 Mar 2023 15:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680017992; bh=bm2MrEPyszxRmD7eWeSEITojITTA3y9rSJopaZVgCJI=; h=Date:From:To:Cc:Subject:From; b=begcOk0DwzxGyVMLYF8bwQ+eCzvQnXEm8Jj0EsCUgDUd6VADHMrkE4JmDezxj6mW3 iSy7A1uKgLiOMporYuaLWHCy2oHE/KhBBsFoDywqVQ14LvVm7Fywx45VPMRoPhTr4o oogaZbacKQnoG748LJG58XAM1ps0EEuZcOZomgXjt6pbvc/9TdpKBCtUuqdsxshhTx RxnEgFgIoLc5EfzVLUmiyELHH+7pZ/Pvcm5sil1NNouUpD/pHO/Xlj0dM0Yu4jjWmc /7gTw21ScGVCcV5EOVbr9LZXeFWN407R1kJdXnkFo7xfiGfChQ4Jbr10t88zqVQauS sWqNQPoGm6T+Q== Date: Tue, 28 Mar 2023 17:39:43 +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: CLONE_INTO_CGROUP probably needs to call controller attach handlers Message-ID: <20230328153943.op62j3sw7qaixdsq@wittgenstein> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,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 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. Christian [1]: https://paste.centos.org/view/f434fa1a