Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4985426pxv; Tue, 6 Jul 2021 14:16:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwB6Drg2IFQj/dfmHzJt5dp8nUzaUH3QPT0ea8yoRy68uQ/Rs8bw0v1Dd6K9s6frxd0bxkr X-Received: by 2002:a17:906:384c:: with SMTP id w12mr20500826ejc.445.1625606202222; Tue, 06 Jul 2021 14:16:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625606202; cv=none; d=google.com; s=arc-20160816; b=YaWcDBYuxK0cpNWq1TVLjH+Dnopa8mXbGmJMAXKPBJw/7tTXV46scpFVidEqu3O0/t nzn7KOGCCOlnKdTAdUo9OMueB5sDonu00HnhMRM2dJeBeN3ROntRhy2q6sAgfKKVcy2C KCQndmaJhHTatrJNjdSqD0JpP+KoWyEssm5vl1hXp0RmyQbAfTZAWGoQwZMpW1ir7DqH mRGeZ7NMFQgk8Wywek1HsMs7E5pKs8LyTjkuZUKf9LRVtjjGXmvY8OFFxgWkdtM1+u0o B5xb+VbIwRF9Umr8zBSk8zyObTm1RIgCIH2sUqW3YDaCAniChr22MsZ5aJ6WYAheMIFH I/qw== 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=xIjT/sBHJXjEFjRplpqxe3dXJOAOtIbCbm1/QruaXLI=; b=nwvrkOUW9muM3eqQjBqvd4FPaCODunuvv9uzWZ+6MzFRFKTuknJd0nnHTu79GCANze eXDmESMYrqxP73XEn+ifPXvbr+ZcK2n6JYiS6KysXEJHXokcHwlJ5rqyMxhg+8ajDGd2 CwljPMYUMyTxFjnM5TkFJ6/tVEqvoIJrfpiTQZXnaLPRyfBBvgYgPm+Zbwv5NpI0zlsY HFpggUv5OdLLAvKuayle+z8x0uXCT+4uuW8hOI58sMuqISvbrXLCymAa3n6G8Wb7hTcz Bqt5gnnPubVF9qmSsiXLmjkTDXjCb1b33sIy4VtPRs4gqD1ef9p4ixMCEczs+pQmsDmm ec+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=RAkqqjXw; 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 ec40si14215420edb.7.2021.07.06.14.16.16; Tue, 06 Jul 2021 14:16:42 -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=@ffwll.ch header.s=google header.b=RAkqqjXw; 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 S229984AbhGFVRx (ORCPT + 99 others); Tue, 6 Jul 2021 17:17:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229879AbhGFVRw (ORCPT ); Tue, 6 Jul 2021 17:17:52 -0400 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6DDDC06175F for ; Tue, 6 Jul 2021 14:15:12 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id w15-20020a056830144fb02904af2a0d96f3so165830otp.6 for ; Tue, 06 Jul 2021 14:15:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=xIjT/sBHJXjEFjRplpqxe3dXJOAOtIbCbm1/QruaXLI=; b=RAkqqjXwrM6iUcf4C2PO/bAO5ZwBDkES0GDc6hW7OW32sQPEYuHYBoBduI250xRAG5 9pkyB5uuCqtDg/p4iXcxbH9Z1QRxnzpRZSe+j2vxeiSmZaE3gP18mJd/xcKjAvHV8bOy btYXsqbfPmrGqfQbmgtQMWJ+Z5w8k1cPFnN3o= 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:content-transfer-encoding; bh=xIjT/sBHJXjEFjRplpqxe3dXJOAOtIbCbm1/QruaXLI=; b=h48UgxFTEMRrTjgf+HbnWudy+GeRWYnNSf9299PY/0GxkfXK4nZVrKdHj0LojsCa/2 KrLMEAGA84/eYtUFz7X7gQrPPmbvSUauK4DWiZKNv4Z0FpHAqrp5FgUV+R4ZrT+HlSsF v9lrV8DcwbfjeujSjwd+HrTIDx1vMopezXWdrbf6ZPXA3tExAEguT+d5Nl9GiakpLRvu aOog3mkUFWKN4EAouY8wrCgE64tPbab68hUtWSURhKHuVoGOQOhTnS7Ts5+cDJI18lr6 AiynzX6oTZEswFnxTqjessnzmfR9Vu8iJC+TsbmRZUwkqxGRwJqieUqqLFAMAyAprd7o fSzw== X-Gm-Message-State: AOAM530A+Qxp0m7sgmaUl2z3ga2DzqWWO/HIocFzX6P0+dmuITP6WwuZ eIEL2F8K2pfJXijDJdCu16VgQrhBotQBv7JBiWCA6A== X-Received: by 2002:a9d:27a4:: with SMTP id c33mr16838523otb.281.1625606112115; Tue, 06 Jul 2021 14:15:12 -0700 (PDT) MIME-Version: 1.0 References: <20210630013421.735092-1-john.stultz@linaro.org> <20210630013421.735092-2-john.stultz@linaro.org> <6a472a24-a40f-1160-70dd-5cb9e9ae85f1@amd.com> In-Reply-To: From: Daniel Vetter Date: Tue, 6 Jul 2021 23:15:00 +0200 Message-ID: Subject: Re: [PATCH v9 1/5] drm: Add a sharable drm page-pool implementation To: John Stultz Cc: =?UTF-8?Q?Christian_K=C3=B6nig?= , lkml , Sumit Semwal , Liam Mark , Chris Goldsworthy , Laura Abbott , Brian Starkey , Hridya Valsaraju , Suren Baghdasaryan , Sandeep Patil , Daniel Mentz , =?UTF-8?Q?=C3=98rjan_Eide?= , Robin Murphy , Ezequiel Garcia , Simon Ser , James Jones , linux-media , dri-devel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 6, 2021 at 11:04 PM John Stultz wrote: > On Wed, Jun 30, 2021 at 11:52 PM Christian K=C3=B6nig > wrote: > > > > Am 01.07.21 um 00:24 schrieb John Stultz: > > > On Wed, Jun 30, 2021 at 2:10 AM Christian K=C3=B6nig > > > wrote: > > >> Am 30.06.21 um 03:34 schrieb John Stultz: > > >>> +static unsigned long page_pool_size; /* max size of the pool */ > > >>> + > > >>> +MODULE_PARM_DESC(page_pool_size, "Number of pages in the drm page = pool"); > > >>> +module_param(page_pool_size, ulong, 0644); > > >>> + > > >>> +static atomic_long_t nr_managed_pages; > > >>> + > > >>> +static struct mutex shrinker_lock; > > >>> +static struct list_head shrinker_list; > > >>> +static struct shrinker mm_shrinker; > > >>> + > > >>> +/** > > >>> + * drm_page_pool_set_max - Sets maximum size of all pools > > >>> + * > > >>> + * Sets the maximum number of pages allows in all pools. > > >>> + * This can only be set once, and the first caller wins. > > >>> + */ > > >>> +void drm_page_pool_set_max(unsigned long max) > > >>> +{ > > >>> + if (!page_pool_size) > > >>> + page_pool_size =3D max; > > >>> +} > > >>> + > > >>> +/** > > >>> + * drm_page_pool_get_max - Maximum size of all pools > > >>> + * > > >>> + * Return the maximum number of pages allows in all pools > > >>> + */ > > >>> +unsigned long drm_page_pool_get_max(void) > > >>> +{ > > >>> + return page_pool_size; > > >>> +} > > >> Well in general I don't think it is a good idea to have getters/sett= ers > > >> for one line functionality, similar applies to locking/unlocking the > > >> mutex below. > > >> > > >> Then in this specific case what those functions do is to aid > > >> initializing the general pool manager and that in turn should absolu= tely > > >> not be exposed. > > >> > > >> The TTM pool manager exposes this as function because initializing t= he > > >> pool manager is done in one part of the module and calculating the > > >> default value for the pages in another one. But that is not somethin= g I > > >> would like to see here. > > > So, I guess I'm not quite clear on what you'd like to see... > > > > > > Part of what I'm balancing here is the TTM subsystem normally sets a > > > global max size, whereas the old ION pool didn't have caps (instead > > > just relying on the shrinker when needed). > > > So I'm trying to come up with a solution that can serve both uses. So > > > I've got this drm_page_pool_set_max() function to optionally set the > > > maximum value, which is called in the TTM initialization path or set > > > the boot argument. But for systems that use the dmabuf system heap, > > > but don't use TTM, no global limit is enforced. > > > > Yeah, exactly that's what I'm trying to prevent. > > > > See if we have the same functionality used by different use cases we > > should not have different behavior depending on what drivers are loaded= . > > > > Is it a problem if we restrict the ION pool to 50% of system memory as > > well? If yes than I would rather drop the limit from TTM and only rely > > on the shrinker there as well. > > Would having the default value as a config option (still overridable > via boot argument) be an acceptable solution? We're also trying to get ttm over to the shrinker model, and a first cut of that even landed, but didn't really work out yet. So maybe just aiming for the shrinker? I do agree this should be consistent across the board, otherwise we're just sharing code but not actually sharing functionality, which is a recipe for disaster because one side will end up breaking the other side's use-case. -Daniel --=20 Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch