Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1634785pxj; Sun, 9 May 2021 00:23:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzF/9vEGYNvJVB0uz9fpm+3KvK3TnDEETSJazCdLk7OpAwh/lWBwzIDF1fBdjLANqFQzQc4 X-Received: by 2002:a17:907:372:: with SMTP id rs18mr19528593ejb.431.1620545027301; Sun, 09 May 2021 00:23:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620545027; cv=none; d=google.com; s=arc-20160816; b=hVUIafyZeOmAx/eBbrEhekqB5RqE+TV/M9y9CPQ1mxVSkNrrgGIVwvsLxhMtO6BrLq hJ70XjJpK+lRULKJTUehsegFov14r8PLkfIBejTCwjHAnJ3wZvNrDlcuftWzgQCQZAPT q8G4XoBM0XxK8ecnbEqtyavkbIp1sOQMZvH49JWRfWdqtB7Pn8CKLZtDJ+PUiqtARsLZ hJ+d6tIDUfgFXeARk7fte3HHNicsvn+ZZsm3aAUoHRAcpVLfbRe535caJXJrbIe5qPW5 /ljPxvssHBHGu0K93Bp1aMz3BmygLKyOMm4vT+SNl7Lt22p90jbtFOsrxbxb7JD6HnKC 6YnQ== 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; bh=eXUE+5ZQfok9t39b/97Fg/w+ZqXTTKWUS3l6waHj4k4=; b=xwHjXwK4yQ+75XYgv20/AEEiwUTSaRPpREiaEjxJ+LvHbfiFqFLNnPCI1Dsd0EJTGO tGZKHweKlDfXET/NndvrWN86qARQsVuXN4rVdDcHO1yugq9i2vKmqn1mmgG4wMoIUsUj s8wJ5Yi8XJtsdcgZQ6LUxQNaYtri2Sq8tenj5PqEG9LvFVVrulFv8Igz+Xv7/yKbYvKZ yptnqC6VbLWz2nNSuuKIFfy0fuECr4Umjt6g0RC5kdw7rslgXcPPlrihBck5UtwIO/ds 1xXK60x6tzzOwh478oT0gB5Y1orthhgOIc38hqp9qry5o/TguAK1s15XHoi2BYoCRb30 0oTg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c16si9888489edv.148.2021.05.09.00.23.23; Sun, 09 May 2021 00:23:47 -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; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229693AbhEIHPE (ORCPT + 99 others); Sun, 9 May 2021 03:15:04 -0400 Received: from mail-lj1-f178.google.com ([209.85.208.178]:43972 "EHLO mail-lj1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbhEIHPE (ORCPT ); Sun, 9 May 2021 03:15:04 -0400 Received: by mail-lj1-f178.google.com with SMTP id w15so16854491ljo.10 for ; Sun, 09 May 2021 00:14:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eXUE+5ZQfok9t39b/97Fg/w+ZqXTTKWUS3l6waHj4k4=; b=uhrd4KhXTuAWuF7XMsWnsGMLeuomIyhWmjcr9ICOBe3GMt9C2pQWyBKqDsj4sP4Qa1 6BdtsmEnxVx+hWn5mYg6uuk62DKIdRhR2EvzG4zdZxn27oOMtcFrmro3+88057zYC5yV mKK+PSeJ3hslEa/BnL5JqbVCjese+v47JqK6itVqdzlH6J8kXXRegpraGF9QrpoJ7iZA qlBWo1lqoLVk06pmPW+ifDvv9AyYTxyCV6gv4ozVcCQ24QpBnrOU+5gox4iYxvsIn4W6 EwZCxpoQ/LZRsNHF9bIFfwZLsP2URtX3L9P4WCE3964MitVo23MJx+S8A7zTI1h6OyB3 n76A== X-Gm-Message-State: AOAM5324i4so+3WbEFnr7WSaTNEc3+/9mDQxxrmP81AP8pPFr50SpNvV izFt2uoDz2bFE/6U7DcWIhK6/Irc0L8RPxPKe00= X-Received: by 2002:a2e:7807:: with SMTP id t7mr14605417ljc.393.1620544439544; Sun, 09 May 2021 00:13:59 -0700 (PDT) MIME-Version: 1.0 References: <20210413155337.644993-1-namhyung@kernel.org> <20210413155337.644993-2-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Sun, 9 May 2021 00:13:48 -0700 Message-ID: Subject: Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups To: Peter Zijlstra 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peter, Thinking about the interface a bit more... On Fri, Apr 16, 2021 at 4:59 AM Peter Zijlstra wrote: > > On Fri, Apr 16, 2021 at 08:22:38PM +0900, Namhyung Kim wrote: > > On Fri, Apr 16, 2021 at 7:28 PM Peter Zijlstra wrote: > > > > > > 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) ]. > > > > Do you mean it'd have separate perf_events per cpu internally? > > From a cpu's perspective, there's nothing changed, right? > > Then it will have the same performance problem as of now. > > Yes, but we'll not end up in ioctl() hell. The interface is sooo much > better. The performance thing just means we need to think harder. So I'd like to have vector support for cgroups but it could be extended later. So open with a flag that it'd accept a vector fd = perf_event_open(.pid=-1, .cpu=N, .flag=VECTOR); Then it'd still need an additional interface (probably ioctl) to set (or append) the vector. ioctl(fd, ADD_VECTOR, { .type = VEC_CGROUP, .nr = N, ... }); Maybe we also need to add FORMAT_VECTOR and use read(v) or friends to read the contents for each entry. It'd be nice if it can have a vector-specific info like cgroup-id in this case. What do you think? Thanks, Namhyung