Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2607161rwi; Fri, 21 Oct 2022 06:02:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6wM+ESg0SCaLZXOfCOtcl+z5f1tU5b3RJZyVkFbft9Uhz38/5ncoCcOWJUwvO9D4aRfcAe X-Received: by 2002:a05:6a00:301c:b0:567:6e2c:45f0 with SMTP id ay28-20020a056a00301c00b005676e2c45f0mr15516278pfb.84.1666357330200; Fri, 21 Oct 2022 06:02:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666357330; cv=none; d=google.com; s=arc-20160816; b=yITD8Wb6LSmPkQjDV5bcL7bqU+VKz2po8PGTkEC/BwI8AtBFY809CL45yCkyi6BiUL Z/G4pKU5H7zpJW0P3ypEA0hrMUUlhiGhk6wbdQmWlfSxXULwczYCgLSP68XwbeGJAFvK /fQJAR2a4PYeS1fxDtzliS9coIs3ZbzFxrXaVr6peIvhaxt7BTU11cHQghv/7ke/Lp0m 4QtwJYRmkj27FWdhlhdTmmiEvN2pN+sYfJrd70503MHY6BwCimphCjp+5joZyRzvDMPR cZR4V3eP3hHMiIpj2b2YE/KIQBRrqKPOb2lUhnGk9p72ANJDnX/qUQJtrtHn4XAfKH+t qYnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=H18fgacNDQLgrpVz2xT5w7SDdDDbUEcHj1IYxxrtq/s=; b=B8TzPOJBP12wOSaBafeSL+6ePkPiYwr0E5H3hPFkb5wVTDl4WXvmGFzWxKHK1vK1Ik l1pIp6RjbHhmgTSAGc+AuqCXAnXZguh3ZCJxHJMgTJUkenN2CeC0/KSuusNT/YKlgL35 w6j8TW3Z2028z3aJUxXmr0tU6bBKzPcxQT5J/57gjDa/L3lhUat5AyDqwDdD2yvYk3yE +eMmb3MpZxZpJNqLxwsfbjSioGqTqIwPh+FqoWkvoDsVBtPrW0joOjIp3YN9tJg//s9H l3st0Ja2Wd+tbIinULPiTtSKqTriCRLc8re0vsVHZLKdVEFYJpHE+4SEvl1GCzPh9unR vHUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=NZp3CanJ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q8-20020a170902eb8800b0018175dd2396si23603997plg.274.2022.10.21.06.01.45; Fri, 21 Oct 2022 06:02:10 -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=@google.com header.s=20210112 header.b=NZp3CanJ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229716AbiJUMnK (ORCPT + 99 others); Fri, 21 Oct 2022 08:43:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229596AbiJUMnH (ORCPT ); Fri, 21 Oct 2022 08:43:07 -0400 Received: from mail-yb1-xb2c.google.com (mail-yb1-xb2c.google.com [IPv6:2607:f8b0:4864:20::b2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 918F1357F6 for ; Fri, 21 Oct 2022 05:42:56 -0700 (PDT) Received: by mail-yb1-xb2c.google.com with SMTP id 126so3222916ybw.3 for ; Fri, 21 Oct 2022 05:42:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=H18fgacNDQLgrpVz2xT5w7SDdDDbUEcHj1IYxxrtq/s=; b=NZp3CanJ6NUzRaq6R3kgGsJHZZMPIL+BXN3fL8n5ldwI7gm0BhmSbJOWnEwUqwAEsp 8DNff/mUS+/dhLSiRe9mm/rCitSHu3Zmi8GOG02WaD5w2fg2FN7Y4pNkhZ3EBmug/iSB q0+j2D7mhNSEyuN9RYAz/ZuMqUfxXiswXCc2vHtKYQ7rxHGj4OMG7beikG5npRD+jDm0 ZzdDnT25sBi7B3buZkA9fDkx0aMyo31er2BQmfxMTLe7XdkGIJqyfnwSL97fFeZQqcRj Z/v42mbCV4Eo6hEBiMkK58iyrQHPuQgFVP9otIGDVYwcpEMDqrUFPyp40NYSPCeAy9K+ 16nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=H18fgacNDQLgrpVz2xT5w7SDdDDbUEcHj1IYxxrtq/s=; b=s1ANoDUrW7PTxXZvnj69eDFiJb+vKxrm45Qvs43S4AB1k95tQ9X+HQq+JDNI+4d6VZ RcLHGG0EnBoB2kp/mK8KBzz3Z+0WpCxXtCWEZSAM9wX6gSfQI2XdwHz4qZFVv+bSEvmr oh37gyhV6SPGKA2Gh6Si7K9nNMqsBq0/dbXdX62e6u8hX+dMuUtMCBF1dRouWMtMJ2T9 SNAqiWIaMXPJmY+PUjymNHBVPhrd2eCTWClwnlw0lUOqAPb4auj7t3vfqZrZRPNqT53I NFrB+sPRPCe/L0qUMrrGW0lxyMHCGujm4sPVkd1Ltn4psV4IyrWn0rxF7B8bdG/cgPee Nvpw== X-Gm-Message-State: ACrzQf0Nrb0CA9uohFmAGH+5orVCpUt4jngQNNUzWhfuHVJjJ6pulwKI w7X5zu3wzqXf17fTTIz+gvO3mapReEBqJzKUYkOOuQ== X-Received: by 2002:a25:4a06:0:b0:695:c6a0:c8e1 with SMTP id x6-20020a254a06000000b00695c6a0c8e1mr16534878yba.181.1666356175684; Fri, 21 Oct 2022 05:42:55 -0700 (PDT) MIME-Version: 1.0 References: <81a7b4f6-fbb5-380e-532d-f2c1fc49b515@intel.com> <76bb4dc9-ab7c-4cb6-d1bf-26436c88c6e2@arm.com> <835d769b-3662-7be5-dcdd-804cb1f3999a@arm.com> In-Reply-To: From: Peter Newman Date: Fri, 21 Oct 2022 14:42:44 +0200 Message-ID: Subject: Re: [RFD] resctrl: reassigning a running container's CTRL_MON group To: James Morse Cc: Reinette Chatre , Tony Luck , "Yu, Fenghua" , "Eranian, Stephane" , "linux-kernel@vger.kernel.org" , Thomas Gleixner , Babu Moger , Gaurang Upasani Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Thu, Oct 20, 2022 at 12:39 PM Peter Newman wrote: > > On Wed, Oct 19, 2022 at 3:58 PM James Morse wrote: > > The devil is in the detail, I'm not sure how it serialises with a fork()ing process, I'd > > hope to do better than relying on the kernel walking the list of processes a lot quicker > > than user-space can. > > I wasn't planning to do it any more optimally than the rmdir > implementation today when looking for all tasks impacted by a > CLOSID/RMID deletion. This is probably a separate topic, but I noticed this when looking at how rmdir moves tasks to a new closid/rmid... In rdt_move_group_tasks(), how do we know that a task switching in on another CPU will observe the updated closid and rmid values soon enough? Even on x86, without an smp_mb(), the stores to t->closid and t->rmid could be reordered with the task_curr(t) and task_cpu(t) reads which follow. The original description of this scenario seemed to assume that accesses below would happen in program order: WRITE_ONCE(t->closid, to->closid); WRITE_ONCE(t->rmid, to->mon.rmid); /* * If the task is on a CPU, set the CPU in the mask. * The detection is inaccurate as tasks might move or * schedule before the smp function call takes place. * In such a case the function call is pointless, but * there is no other side effect. */ if (IS_ENABLED(CONFIG_SMP) && mask && task_curr(t)) cpumask_set_cpu(task_cpu(t), mask); If the task concurrently switches in on another CPU, the code above may not observed that it's running, and the CPU running the task may not have observed the updated rmid and closid yet, so it could continue with the old rmid/closid and not get interrupted. -Peter