From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24467C4338F for ; Mon, 26 Jul 2021 16:20:48 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E528360F9E for ; Mon, 26 Jul 2021 16:20:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E528360F9E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=jlekstrand.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E6C8F6FE28; Mon, 26 Jul 2021 16:20:42 +0000 (UTC) Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) by gabe.freedesktop.org (Postfix) with ESMTPS id 008C36EB12 for ; Mon, 26 Jul 2021 16:20:40 +0000 (UTC) Received: by mail-yb1-xb33.google.com with SMTP id g76so15748211ybf.4 for ; Mon, 26 Jul 2021 09:20:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jlekstrand-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=17LuCjRWSa481z+i5/TyQvh9obotD3o34cqh7WaO1oA=; b=ZKRdfCe0Tjlqdxqq8pVINA6iJYzDntqbtEkhLe54OcfYvoQoXfxZjtXEntklHQbvmL rh0p4p33qoU22rqhqWfDJSd9PHpbh8d5tIR/ob0HBP/szl9WYagahWvDHzwDJsOE/6mG jSpBMu1UZZ1MZ4WWKJdKFtDVBC0q0MMeqOhoyPX/RRvEMLiSPiH2s80Go5O8GQRMiYnj mbrg1IDiaEAvQoOwJ+rNxfHvRc1zeJVT+C+viFkYc8aOF+JBjfi02higniPvtdFbZEqx PvZKrpY8hHW44ZJ7dvyACIJErFnBdL6M0X3qwz3fxuu1m64frgiReYYkBildYck2unO0 ycHQ== 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=17LuCjRWSa481z+i5/TyQvh9obotD3o34cqh7WaO1oA=; b=RrVhIcRnW/Zr6BkYhzk5Ljs/t57brUTSQtUAJVpyy6emrXJF2NYOKhI1dhwZXZyqcB Bf+EdB0fIrvT759K0CxZVPB2Z4sA5fJ4YDPVM8kjuVsEw3w7joOI5Ogd3NMkAKgTrAlb 1xC8lNQp8FhugtBE809gFhcVcDtRpAU3pCoWEUP1JEqunDaAwrn2q49jNlXZohiH5twq B00ZCGwZmDm+G5wLP/j35BRTRoBTcV702T+zCyto+7qgRrPB8pFGgKGYk6LG8gbsF3/E uLyGJT+LbjAPvpNyCGvjx53a9ur3nMDVcLGz29F5D+rJWkKoPJlwm2tq/1qsKBD8MqUn cA3Q== X-Gm-Message-State: AOAM530y9QiOG1g/L+W6nkh8enAFoo+OskVy7ybLLHKYGNIhboWdog2D LqhhCM37VZVG/ZqjNkxX2Vc2AwbkBxpm2yOc/eNmJQ== X-Google-Smtp-Source: ABdhPJzPiAMbHdMmpBw/HcIT/6SeWIhu9ViLs8wt2qgUJ+IapVceAEmG0/frT6VYS+1cGZcLJTlNBoYe11UpEPGAmLo= X-Received: by 2002:a25:208b:: with SMTP id g133mr24328330ybg.211.1627316439890; Mon, 26 Jul 2021 09:20:39 -0700 (PDT) MIME-Version: 1.0 References: <20210723192934.1004427-1-daniel.vetter@ffwll.ch> <20210723192934.1004427-4-daniel.vetter@ffwll.ch> <0edb5c4d-1faf-4b24-a21d-fd2e5be6591d@linux.intel.com> <031997ab-5568-9dbd-fcee-b4f820a32632@linux.intel.com> In-Reply-To: <031997ab-5568-9dbd-fcee-b4f820a32632@linux.intel.com> From: Jason Ekstrand Date: Mon, 26 Jul 2021 11:20:28 -0500 Message-ID: To: Tvrtko Ursulin Subject: Re: [Intel-gfx] [PATCH 04/10] drm/i915: move intel_context slab to direct module init/exit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Intel Graphics Development , DRI Development , Daniel Vetter Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Mon, Jul 26, 2021 at 11:08 AM Tvrtko Ursulin wrote: > On 26/07/2021 16:42, Jason Ekstrand wrote: > > On Mon, Jul 26, 2021 at 10:30 AM Jason Ekstrand wrote: > >> > >> On Mon, Jul 26, 2021 at 3:35 AM Tvrtko Ursulin > >> wrote: > >>> > >>> > >>> On 23/07/2021 20:29, Daniel Vetter wrote: > >>>> With the global kmem_cache shrink infrastructure gone there's nothing > >>>> special and we can convert them over. > >>>> > >>>> I'm doing this split up into each patch because there's quite a bit of > >>>> noise with removing the static global.slab_ce to just a > >>>> slab_ce. > >>>> > >>>> Cc: Jason Ekstrand > >>>> Signed-off-by: Daniel Vetter > >>>> --- > >>>> drivers/gpu/drm/i915/gt/intel_context.c | 25 ++++++++----------------- > >>>> drivers/gpu/drm/i915/gt/intel_context.h | 3 +++ > >>>> drivers/gpu/drm/i915/i915_globals.c | 2 -- > >>>> drivers/gpu/drm/i915/i915_globals.h | 1 - > >>>> drivers/gpu/drm/i915/i915_pci.c | 2 ++ > >>>> 5 files changed, 13 insertions(+), 20 deletions(-) > >>>> > >>>> diff --git a/drivers/gpu/drm/i915/gt/intel_context.c b/drivers/gpu/drm/i915/gt/intel_context.c > >>>> index baa05fddd690..283382549a6f 100644 > >>>> --- a/drivers/gpu/drm/i915/gt/intel_context.c > >>>> +++ b/drivers/gpu/drm/i915/gt/intel_context.c > >>>> @@ -7,7 +7,6 @@ > >>>> #include "gem/i915_gem_pm.h" > >>>> > >>>> #include "i915_drv.h" > >>>> -#include "i915_globals.h" > >>>> #include "i915_trace.h" > >>>> > >>>> #include "intel_context.h" > >>>> @@ -15,14 +14,11 @@ > >>>> #include "intel_engine_pm.h" > >>>> #include "intel_ring.h" > >>>> > >>>> -static struct i915_global_context { > >>>> - struct i915_global base; > >>>> - struct kmem_cache *slab_ce; > >>>> -} global; > >>>> +struct kmem_cache *slab_ce; > >> > >> Static? With that, > >> > >> Reviewed-by: Jason Ekstrand > >> > >>>> > >>>> static struct intel_context *intel_context_alloc(void) > >>>> { > >>>> - return kmem_cache_zalloc(global.slab_ce, GFP_KERNEL); > >>>> + return kmem_cache_zalloc(slab_ce, GFP_KERNEL); > >>>> } > >>>> > >>>> static void rcu_context_free(struct rcu_head *rcu) > >>>> @@ -30,7 +26,7 @@ static void rcu_context_free(struct rcu_head *rcu) > >>>> struct intel_context *ce = container_of(rcu, typeof(*ce), rcu); > >>>> > >>>> trace_intel_context_free(ce); > >>>> - kmem_cache_free(global.slab_ce, ce); > >>>> + kmem_cache_free(slab_ce, ce); > >>>> } > >>>> > >>>> void intel_context_free(struct intel_context *ce) > >>>> @@ -410,22 +406,17 @@ void intel_context_fini(struct intel_context *ce) > >>>> i915_active_fini(&ce->active); > >>>> } > >>>> > >>>> -static void i915_global_context_exit(void) > >>>> +void i915_context_module_exit(void) > >>>> { > >>>> - kmem_cache_destroy(global.slab_ce); > >>>> + kmem_cache_destroy(slab_ce); > >>>> } > >>>> > >>>> -static struct i915_global_context global = { { > >>>> - .exit = i915_global_context_exit, > >>>> -} }; > >>>> - > >>>> -int __init i915_global_context_init(void) > >>>> +int __init i915_context_module_init(void) > >>>> { > >>>> - global.slab_ce = KMEM_CACHE(intel_context, SLAB_HWCACHE_ALIGN); > >>>> - if (!global.slab_ce) > >>>> + slab_ce = KMEM_CACHE(intel_context, SLAB_HWCACHE_ALIGN); > >>>> + if (!slab_ce) > >>>> return -ENOMEM; > >>>> > >>>> - i915_global_register(&global.base); > >>>> return 0; > >>>> } > >>>> > >>>> diff --git a/drivers/gpu/drm/i915/gt/intel_context.h b/drivers/gpu/drm/i915/gt/intel_context.h > >>>> index 974ef85320c2..a0ca82e3c40d 100644 > >>>> --- a/drivers/gpu/drm/i915/gt/intel_context.h > >>>> +++ b/drivers/gpu/drm/i915/gt/intel_context.h > >>>> @@ -30,6 +30,9 @@ void intel_context_init(struct intel_context *ce, > >>>> struct intel_engine_cs *engine); > >>>> void intel_context_fini(struct intel_context *ce); > >>>> > >>>> +void i915_context_module_exit(void); > >>>> +int i915_context_module_init(void); > >>>> + > >>>> struct intel_context * > >>>> intel_context_create(struct intel_engine_cs *engine); > >>>> > >>>> diff --git a/drivers/gpu/drm/i915/i915_globals.c b/drivers/gpu/drm/i915/i915_globals.c > >>>> index 3de7cf22ec76..d36eb7dc40aa 100644 > >>>> --- a/drivers/gpu/drm/i915/i915_globals.c > >>>> +++ b/drivers/gpu/drm/i915/i915_globals.c > >>>> @@ -7,7 +7,6 @@ > >>>> #include > >>>> #include > >>>> > >>>> -#include "gem/i915_gem_context.h" > >>>> #include "gem/i915_gem_object.h" > >>>> #include "i915_globals.h" > >>>> #include "i915_request.h" > >>>> @@ -32,7 +31,6 @@ static void __i915_globals_cleanup(void) > >>>> } > >>>> > >>>> static __initconst int (* const initfn[])(void) = { > >>>> - i915_global_context_init, > >>>> i915_global_gem_context_init, > >>>> i915_global_objects_init, > >>>> i915_global_request_init, > >>>> diff --git a/drivers/gpu/drm/i915/i915_globals.h b/drivers/gpu/drm/i915/i915_globals.h > >>>> index d80901ba75e3..60daa738a188 100644 > >>>> --- a/drivers/gpu/drm/i915/i915_globals.h > >>>> +++ b/drivers/gpu/drm/i915/i915_globals.h > >>>> @@ -23,7 +23,6 @@ int i915_globals_init(void); > >>>> void i915_globals_exit(void); > >>>> > >>>> /* constructors */ > >>>> -int i915_global_context_init(void); > >>>> int i915_global_gem_context_init(void); > >>>> int i915_global_objects_init(void); > >>>> int i915_global_request_init(void); > >>>> diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c > >>>> index f9527269e30a..266618157775 100644 > >>>> --- a/drivers/gpu/drm/i915/i915_pci.c > >>>> +++ b/drivers/gpu/drm/i915/i915_pci.c > >>>> @@ -33,6 +33,7 @@ > >>>> #include "i915_active.h" > >>>> #include "i915_buddy.h" > >>>> #include "i915_drv.h" > >>>> +#include "gem/i915_gem_context.h" > >>> > >>> It's a bit ugly to go to a design where i915_pci.c has to include so > >>> many random parts of i915. IMO for a complex driver like i915, > >>> compartmentalizing so much knowledge about the internals was better > >>> inside the globals layer. > >> > >> I agree that i915_pci feels like the wrong place to put this but I > >> don't think that's so much because globals don't belong in i915_pci > >> but because i915_init/exit don't belong there. Maybe, once this is > >> all said and done (or at the start of the series), we should move > >> i915_init/exit to i915_drv.c? Of course, there's a bunch of PCI > >> probing stuff in i915_drv.c so..... yeah.... our organization is > >> pretty busted. > > > > To put a finer point on this, the new "design" is really to have a > > single flat list instead of two, one nested inside the other. There's > > nothing wrong with that at all. The fact that all this stuff now > > lives in i915_pci.c is ugly. But, as I said, that's kind-of an > > accident of history because that's where i915_init() and i915_exit() > > currently live. We should just move the lot to i915_drv.c. > > Hmm.. on one hand it does sounds better to move to i915_drv.c, but is it > just because all these new include directive are so visibly out of place > in i915_pci.c? > > Perhaps we need i915_module.c and then i915_globals is a completely fine > concept. Desired IMO even since we have to avoid globals in general > (multi-gpu) so it sticks out nicely that all that is allowed to be > global has a special place. > > And i915_drv.c can remain being about a driver instance as bound to one GPU. Is i915_drv.c about a single instance bound to a single GPU? If so, then, yeah, maybe not the right place. Maybe a i915_module.c would be better. It's all different shades of shed paint. --Jason > That feels like the best of both worlds to me. > > Regards, > > Tvrtko > > > > >> --Jason > >> > >>> Maybe add a cover letter to explain the perceived pros and cons and > >>> thinking in general? > >>> > >>> Regards, > >>> > >>> Tvrtko > >>> > >>>> #include "i915_perf.h" > >>>> #include "i915_globals.h" > >>>> #include "i915_selftest.h" > >>>> @@ -1297,6 +1298,7 @@ static const struct { > >>>> { i915_check_nomodeset, NULL }, > >>>> { i915_active_module_init, i915_active_module_exit }, > >>>> { i915_buddy_module_init, i915_buddy_module_exit }, > >>>> + { i915_context_module_init, i915_context_module_exit }, > >>>> { i915_globals_init, i915_globals_exit }, > >>>> { i915_mock_selftests, NULL }, > >>>> { i915_pmu_init, i915_pmu_exit }, > >>>> > >>> _______________________________________________ > >>> Intel-gfx mailing list > >>> Intel-gfx@lists.freedesktop.org > >>> https://lists.freedesktop.org/mailman/listinfo/intel-gfx _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx