Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2705668rdb; Wed, 4 Oct 2023 09:03:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrYY32KvHbpZOH5stadmWO9WTEav1KdwklmqRn55dAVW0yfWOnyv2k20qlS7YpZb+XrjrV X-Received: by 2002:a17:90a:674d:b0:270:1586:b014 with SMTP id c13-20020a17090a674d00b002701586b014mr2795334pjm.28.1696435391451; Wed, 04 Oct 2023 09:03:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696435391; cv=none; d=google.com; s=arc-20160816; b=AEbl/udw1rMYK+hZkfkkopt/SVqBESEQYDK5QQ/tCU8WdM2s0pCsE1V11LyTU2Ob1d BaXKCOxGp/cU+XrBCRfQIDiqXqx7es0aj01A49zO46JWVr/VztO5d9T05HhUVo9HhhV1 KmQ6wKJLIBVTyI6WKG5zrh1XQ86ZD1qI1XoR2GLTnvgYQ+JR9/YuyYu7vvSVv6jdJKEa jeEvL0etSj/E+pd5YYocY18Iwkq145waCv7Bv4gOWKq9HKsS8ef5V9W7x1tj4eGFFBfu 2FDB+OD9OJZ1i0gSPkcEFEOL4L033x3JnVIWSl46e3zIIHyalBoQx+7tY47b4EmF4ETa U4hQ== 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=vt9FHS60uVNYZyxqQgD7PSsuS36ozJibCdDrRmf3YvA=; fh=30P0f+sP5meRe/SzjFEeZX/l6fe+hayG+KHXLtxWZqY=; b=E8yTzEo3K/bqwz0rZyoqmujP/WfyA5yqkNDCZAxtAvChzcqC7vIGyX7T0STKlvMMWB Uka28IcbBR3sd6MoNEUcKx0rJR59JvJe3RSyNiCljTJ4bVKRw8afEy+MhxBFRWdW8WhT WukKdjqWDGwAk8Vd+v2rzlegP02ZNBhzrx1aNXQHkuSn2FqdI1SsDWDihB4i/LmsseP4 HIs6/NlxQ05Hz+Wk+99ZjvzXTh87wTZYy6cTbJTgt/fzPBi/SM/z5QUbW8rN7zCdh6mw vj0YpctUgw2VYDCavkAfB6s6YG+Lyy5l1MfuYTCXWinhNRzVBwinZlAX6jqkqt5cQh0n G8+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=CVDuSnX4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id in24-20020a17090b439800b002768ab837bfsi1782026pjb.48.2023.10.04.09.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 09:03:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=CVDuSnX4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E836881B17AA; Wed, 4 Oct 2023 09:03:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233707AbjJDQCo (ORCPT + 99 others); Wed, 4 Oct 2023 12:02:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233576AbjJDQCn (ORCPT ); Wed, 4 Oct 2023 12:02:43 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DEA9C1; Wed, 4 Oct 2023 09:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=vt9FHS60uVNYZyxqQgD7PSsuS36ozJibCdDrRmf3YvA=; b=CVDuSnX4NbFCGeK/vsh0fZGmfc UiqWRqKjSAc6JsEBY+xwzaJgtxdJ5FsSydYVeYWU/1r37munTBffivlnYjjFahxEuKHF20Qx0R9Sk tXg1kUNQ3/OFmIFPwy0fwNClxT5mYuzde3eKaldXIvh4ylKDEdJCIVAYCCrzxR7mWWFvJPZi6U4oJ YUn1AFxUSMsAIobzelZVC/YA5COXCxknkH6z5SO/oUM+ZlCaaRgkYsnGWjINzkGLExSB+9Rl6MCGr Henu71ipAZtNTPWnbA/ZVG6BGFDqYOvg7Fph5IolXsaRsJY3Jk+CldbcpfEpwVQyzD76gTeFqOMBT Hnpwjnsg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qo4KO-004FRW-Sh; Wed, 04 Oct 2023 16:02:26 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 8B512300392; Wed, 4 Oct 2023 18:02:24 +0200 (CEST) Date: Wed, 4 Oct 2023 18:02:24 +0200 From: Peter Zijlstra To: Namhyung Kim Cc: Ingo Molnar , Mark Rutland , Alexander Shishkin , Arnaldo Carvalho de Melo , LKML , Stephane Eranian , Kan Liang , Ravi Bangoria , stable@vger.kernel.org Subject: Re: [PATCH] perf/core: Introduce cpuctx->cgrp_ctx_list Message-ID: <20231004160224.GB6307@noisy.programming.kicks-ass.net> References: <20231004040844.797044-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231004040844.797044-1-namhyung@kernel.org> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 04 Oct 2023 09:03:09 -0700 (PDT) On Tue, Oct 03, 2023 at 09:08:44PM -0700, Namhyung Kim wrote: > But after the change, it ended up iterating all pmus/events in the cpu > context if there's a cgroup event somewhere on the cpu context. > Unfortunately it includes uncore pmus which have much longer latency to > control. Can you describe the problem in more detail please? We have cgrp as part of the tree key: {cpu, pmu, cgroup, idx}, so it should be possible to find a specific cgroup for a cpu and or skip to the next cgroup on that cpu in O(log n) time. > To fix the issue, I restored a linked list equivalent to cgrp_cpuctx_list > in the perf_cpu_context and link perf_cpu_pmu_contexts that have cgroup > events only. Also add new helpers to enable/disable and does ctx sched > in/out for cgroups. Adding a list and duplicating the whole scheduling infrastructure seems 'unfortunate' at best.