Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1106677iob; Wed, 4 May 2022 14:54:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQtMFhPAizBuD4t2hxOAUt1DSe7iO6CkPUjVQ27+KyToLG1a+R3cA6VlSeg4JQrzjbzIMO X-Received: by 2002:a50:f69b:0:b0:425:e693:5d1f with SMTP id d27-20020a50f69b000000b00425e6935d1fmr25735605edn.272.1651701292635; Wed, 04 May 2022 14:54:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651701292; cv=none; d=google.com; s=arc-20160816; b=fdvuu8RwPQjSBugCMWRha39tnDcxjZ494rEPw8znPBKlPQiuoCEUXEOZtR4jiwlJFh hqS5om5OUehLPUbSIQkWfDkRMarMlS+D+YV7xGJBgNTY8eG0GVGW9mraWG068V8jQJAq CcowAuEc1NlAcsps930w19gYqmfbnP2uj/+XKYtrWIf9/yBQ4N6Gv6/zpi0oz1DbgBdx mXyHgQV6nafaRkrLd2Gk4Eh2CDYWQT3Pcbdfpyy2rOzBEKPDpr87s8lgxAi06V8b9Ifc eOjRWMpbOgSzVL8gQrAbmhb1VdpFJtTBpMGjg0uuiN4TnZYeB7Sf7/qdo8Vwkr6wu0Aq 1tdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=53tRH3Jax00x2MRGmAnmpVFoogtTBVaQBwRaJB/MSqI=; b=AGyXuOCoE/4jrx7k1Wa0o2DjuypuO6Eyo8HMjiS0qBiZuPeWsDQ668ubJ7IELdjUpB hN/zidqYCD6RICPbyZ34IL+Mvf77QmbEm+0ATCF5Dfj7RaX+ES53tDnuIwwYVWBrfsWQ rJQlE7MTNCNIMKt4BGsSlxfnj1NNek4fatF6WSfV7slNIMFwKOig/wQ+OtaP3rFWbbLX MX8GqaiSMdtd9d2zncljtnnrpi3cwytJAxH7FEMtwXE+s+l3x1cBEJNsNw6vdyRW3pVk qNtDcL5onpzYkwrMxuzfwIitRJOC9RNUZx4JbStc70Ljs6WwjN5Tj1nMJ2ZbIqDDspCj psBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="ZpE/QIW7"; 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 y18-20020a056402359200b00427e70ce407si5408179edc.196.2022.05.04.14.54.29; Wed, 04 May 2022 14:54:52 -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="ZpE/QIW7"; 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 S240519AbiEDSFe (ORCPT + 99 others); Wed, 4 May 2022 14:05:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376311AbiEDSFM (ORCPT ); Wed, 4 May 2022 14:05:12 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C7D96A01F for ; Wed, 4 May 2022 10:19:35 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id kq17so4181780ejb.4 for ; Wed, 04 May 2022 10:19:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=53tRH3Jax00x2MRGmAnmpVFoogtTBVaQBwRaJB/MSqI=; b=ZpE/QIW7kna1o4IhzQQmp2637K1w9UcjrBWQkFmB3KeaXGJhRew5Qrrm4nVBxQuM5K WxvhUYOlh8rWIuTX2aM0865lrsFa3LgNJmonYVw5QJ5TWtJ8GDZTmeKTt6ABumWC0QC1 ab5RGTAVBbqKEoK4b/TnHXAunRyIDb4UtS/WiYRpJvoKPoGFBe/xxsjE1LJ0+w1IU9lY PawaTzdNF1YTKYIh5MvHjBCSHId3sE7LkENrHud89JTEUmJh7bVKtkqT2eRSPldXBLZc Hy/1AeX5w6TUxiRTh+7aDA0ELWkG6xjnd2RXfENi04bsD7m5bd6YKUkx+vX1cIkHwdrw TrCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=53tRH3Jax00x2MRGmAnmpVFoogtTBVaQBwRaJB/MSqI=; b=NW5R7N+Jh2og3ERLOF7amqez/ybOWOlqZblUaVOYbIxRMo8TY6Nb1S3/a9mZ4v4/xU dwJAxYbboKuow2XNze8lD2BeUoq62hM5bMw5lKzQmCmD1QsWF9IBqnU7a1wkKOtX90uh l/RNF/3ruAnPLmUaNaKiYKq9lJYmbrwLVYTWR3dVBO0OYwlR1KDlLu9zOuXcFceh8tbh ArMvE5PMZfBV1wbTrvuLjfLIuqen7SS8x4ZOyyHd3LKAJYYDLUaeuoFojrPQGCgBugMV Db4VmCZuimXmk5EYcq7GTfb+WjDrQgCzkrb0rIU7loEEDcV6HltgPco97gAwrCQn+pU2 feBg== X-Gm-Message-State: AOAM531yaJG7CC7+qYeO5ZvcJMCsA87MuhnWb8WhWe8brqp6aRH6W2mE QJ5lkOvQPy6Z1K69lacg8Chy3oeEdIwN88pg6Osqvg== X-Received: by 2002:a17:907:971e:b0:6f3:ff27:ebf7 with SMTP id jg30-20020a170907971e00b006f3ff27ebf7mr21159148ejc.159.1651684771561; Wed, 04 May 2022 10:19:31 -0700 (PDT) MIME-Version: 1.0 References: <20220502231944.3891435-1-tjmercier@google.com> <20220502231944.3891435-3-tjmercier@google.com> <20220504122558.GB24172@blackbody.suse.cz> In-Reply-To: <20220504122558.GB24172@blackbody.suse.cz> From: "T.J. Mercier" Date: Wed, 4 May 2022 10:19:20 -0700 Message-ID: Subject: Re: [PATCH v6 2/6] cgroup: gpu: Add a cgroup controller for allocator attribution of GPU memory To: =?UTF-8?Q?Michal_Koutn=C3=BD?= Cc: Tejun Heo , Zefan Li , Johannes Weiner , Daniel Vetter , Hridya Valsaraju , =?UTF-8?Q?Christian_K=C3=B6nig?= , John Stultz , Todd Kjos , Carlos Llamas , Suren Baghdasaryan , Kalesh Singh , Kenny.Ho@amd.com, Shuah Khan , kernel-team@android.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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, T_SCC_BODY_TEXT_LINE,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 Wed, May 4, 2022 at 5:26 AM Michal Koutn=C3=BD wrote: > > Hello. > > On Mon, May 02, 2022 at 11:19:36PM +0000, "T.J. Mercier" wrote: > > This patch adds APIs to: > > -allow a device to register for memory accounting using the GPU cgroup > > controller. > > -charge and uncharge allocated memory to a cgroup. > > Is this API for separately built consumers? > The respective functions should be exported (EXPORT_SYMBOL_GPL) if I > haven't missed anything. > As the only users are dmabuf heaps and dmabuf, and those cannot be built as modules I did not export the symbols here. However these definitely would need to be exported to support use by modules, and I have had to do that in one of my device test trees for this change. Should I export these now for this series? > > +#ifdef CONFIG_CGROUP_GPU > > + /* The GPU cgroup controller data structure */ > > +struct gpucg { > > + struct cgroup_subsys_state css; > > + > > + /* list of all resource pools that belong to this cgroup */ > > + struct list_head rpools; > > +}; > > + > > +/* A named entity representing bucket of tracked memory. */ > > +struct gpucg_bucket { > > + /* list of various resource pools in various cgroups that the buc= ket is part of */ > > + struct list_head rpools; > > + > > + /* list of all buckets registered for GPU cgroup accounting */ > > + struct list_head bucket_node; > > + > > + /* string to be used as identifier for accounting and limit setti= ng */ > > + const char *name; > > +}; > > Do these struct have to be defined "publicly"? > I.e. the driver code could just work with gpucg and gpucg_bucket > pointers. > > > +int gpucg_register_bucket(struct gpucg_bucket *bucket, const char *nam= e) > > ...and the registration function would return a pointer to newly > (internally) allocated gpucg_bucket. > No, except maybe the gpucg_bucket name which I can add an accessor function for. Won't this mean depending on LTO for potential inlining of the functions currently implemented in the header? I'm happy to make this change, but I wonder why some parts of the kernel take this approach and others do not. > Regards, > Michal