Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp257815pxb; Fri, 16 Apr 2021 05:06:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSEj9uaHnkpCUs1+y9eqf+gm1TEqoWf8/TfRQTDtrK2h3oSD4RmdRO3Eu4UIwPPc5dK2jv X-Received: by 2002:a17:907:98e5:: with SMTP id ke5mr8033832ejc.438.1618574770137; Fri, 16 Apr 2021 05:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618574770; cv=none; d=google.com; s=arc-20160816; b=NuaumnYbZBsY25VyrW9t6iyf6towaH8pQGSx3MXHsZuyXYwDNlz8Uvkv5e2eWOV9Qw gi26jWBCnVYQOjctLVnO4CUf4eOC29dnJw1S2+VvcsXL+aQKq/8OvHz2bkInbKCi3l+y mLOosOFH+BfSKAjVwuHaK8KDUlarRnECkRgbDFVZ0Qk/F0aMPWaO6FiiQ0d5inoZIraL Ix+QaQbwQ0IPoaO4r0wj9r1dq8llnEh5tKM4USBAV0g2Qj9+H9u+AlS9hh3vlG3xSFyY FzmrEjBnVlzw4L/CeGBMGBYuUTuj15FChhwjGd/MHCJHenlMaKA/Ltn/kfs7QPuuvtCS 8GIg== 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=CWrS5XSLYo4ciqDUEjhD1jnthccxk9YJcxF+IcCqVhY=; b=VPcpgRbst2gnefXa02rRcmdt7c0Gs1gu2Z0XsOdePeNQbnu+VcY5gyDp+6R25IHd/I EJQR92aaY0+Zv+fg/s7FWB80OCdhx/0uOLsb4/RvWB1A4jWpkWcKvHpB19/sjSO8vohG dyhxtMAG7LaUmxyUO2X2j2QqWT3cLkik4v0502hryyuh+DIGgFabDJaPxZS6qT7vYRlI 4dEbdvhgNMUTygKI0i9/GI6Xu3A742q1jJ1S5UgayCl89ycQ75TJNJAtJb3O66/Zse9v i7Qan91brLW5eFvvqnPXXeph6bFeZMv2rH6oUUK5ykjRbdlOrTOdbGryYCxZ3Um91Ur0 Yj0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ADPdO0Bx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d20si4855198edc.51.2021.04.16.05.05.47; Fri, 16 Apr 2021 05:06:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ADPdO0Bx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234914AbhDPK27 (ORCPT + 99 others); Fri, 16 Apr 2021 06:28:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229719AbhDPK26 (ORCPT ); Fri, 16 Apr 2021 06:28:58 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63F27C061574 for ; Fri, 16 Apr 2021 03:28:29 -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=CWrS5XSLYo4ciqDUEjhD1jnthccxk9YJcxF+IcCqVhY=; b=ADPdO0BxVbJOyovTHpfTPOoKum gDDMTFcJNFsxXDMtyOJAmVgqMEGklqUx97H8S4cC071lxCG66pLtoWaEitLNB6SrAmdckWFLrSCHA kSkWP5ztBXQS+YVREZ3kPWqCxmY9jFUUEtABuSGUNyIOQ79NTeYlVVJA5kq7MS6YFVUh9c2gIxfWL eGIalbTXqZTUlbHSGFGuBz1xnT0rPe5hBNZPcUWnqn50zPyf9NppjoEBXNZKTMguqswD+NjhpVXQL cqnALhnG+ZsKt1Laxzz0wojtxtvASN44/j4+pmWlvVoPmTYgknNMLsIJnDq8UROox0XnQytdQ/vAu K9eqFn+g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lXLhd-009omq-H4; Fri, 16 Apr 2021 10:28:00 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 3B426300212; Fri, 16 Apr 2021 12:27:56 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 043DD200C8D28; Fri, 16 Apr 2021 12:27:55 +0200 (CEST) Date: Fri, 16 Apr 2021 12:27:55 +0200 From: Peter Zijlstra To: Namhyung Kim Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Jiri Olsa , Mark Rutland , Alexander Shishkin , LKML , Stephane Eranian , Andi Kleen , Ian Rogers , Song Liu , Tejun Heo , kernel test robot , Thomas Gleixner Subject: Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups Message-ID: References: <20210413155337.644993-1-namhyung@kernel.org> <20210413155337.644993-2-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 16, 2021 at 11:29:30AM +0200, Peter Zijlstra wrote: > > So I think we've had proposals for being able to close fds in the past; > > while preserving groups etc. We've always pushed back on that because of > > the resource limit issue. By having each counter be a filedesc we get a > > natural limit on the amount of resources you can consume. And in that > > respect, having to use 400k fds is things working as designed. > > > > Anyway, there might be a way around this.. So how about we flip the whole thing sideways, instead of doing one event for multiple cgroups, do an event for multiple-cpus. Basically, allow: perf_event_open(.pid=fd, cpu=-1, .flag=PID_CGROUP); Which would have the kernel create nr_cpus events [the corrolary is that we'd probably also allow: (.pid=-1, cpu=-1) ]. Output could be done by adding FORMAT_PERCPU, which takes the current read() format and writes a copy for each CPU event. (p)read(v)() could be used to explode or partial read that. This gets rid of the nasty variadic nature of the 'get-me-these-n-cgroups'. While still getting rid of the n*m fd issue you're facing.