From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Arnd Bergmann <arnd@kernel.org>
Cc: "Jani Nikula" <jani.nikula@linux.intel.com>,
"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
"Tvrtko Ursulin" <tursulin@ursulin.net>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Arnd Bergmann" <arnd@arndb.de>,
"Nitin Gote" <nitin.r.gote@intel.com>,
"Chaitanya Kumar Borah" <chaitanya.kumar.borah@intel.com>,
"Krzysztof Niemiec" <krzysztof.niemiec@intel.com>,
"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"renjun wang" <renjunw0@foxmail.com>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/i915: reduce stack usage in igt_vma_pin1()
Date: Tue, 24 Jun 2025 17:14:25 -0400 [thread overview]
Message-ID: <aFsVMcb79rp8kMpF@intel.com> (raw)
In-Reply-To: <20250620113644.3844552-1-arnd@kernel.org>
On Fri, Jun 20, 2025 at 01:36:38PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The igt_vma_pin1() function has a rather high stack usage, which gets
> in the way of reducing the default warning limit:
>
> In file included from drivers/gpu/drm/i915/i915_vma.c:2285:
> drivers/gpu/drm/i915/selftests/i915_vma.c:257:12: error: stack frame size (1288) exceeds limit (1280) in 'igt_vma_pin1' [-Werror,-Wframe-larger-than]
>
> There are two things going on here:
>
> - The on-stack modes[] array is really large itself and gets constructed
> for every call, using around 1000 bytes itself depending on the configuration.
>
> - The call to i915_vma_pin() gets inlined and adds another 200 bytes for
> the i915_gem_ww_ctx structure since commit 7d1c2618eac5 ("drm/i915: Take
> reservation lock around i915_vma_pin.")
>
> The second one is easy enough to change, by moving the function into the
> appropriate .c file. Since it is already large enough to not always be
> inlined, this seems like a good idea regardless, reducing both the code size
> and the internal stack usage of each of its 67 callers.
indeed way to much for the inline.
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Also pushing to drm-intel-next right now...
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/gpu/drm/i915/i915_vma.c | 20 ++++++++++++++++++++
> drivers/gpu/drm/i915/i915_vma.h | 22 ++--------------------
> 2 files changed, 22 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
> index 632e316f8b05..25e97031d76e 100644
> --- a/drivers/gpu/drm/i915/i915_vma.c
> +++ b/drivers/gpu/drm/i915/i915_vma.c
> @@ -1607,6 +1607,26 @@ int i915_vma_pin_ww(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
> return err;
> }
>
> +int i915_vma_pin(struct i915_vma *vma, u64 size, u64 alignment, u64 flags)
> +{
> + struct i915_gem_ww_ctx ww;
> + int err;
> +
> + i915_gem_ww_ctx_init(&ww, true);
> +retry:
> + err = i915_gem_object_lock(vma->obj, &ww);
> + if (!err)
> + err = i915_vma_pin_ww(vma, &ww, size, alignment, flags);
> + if (err == -EDEADLK) {
> + err = i915_gem_ww_ctx_backoff(&ww);
> + if (!err)
> + goto retry;
> + }
> + i915_gem_ww_ctx_fini(&ww);
> +
> + return err;
> +}
> +
> static void flush_idle_contexts(struct intel_gt *gt)
> {
> struct intel_engine_cs *engine;
> diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h
> index 6a6be8048aa8..14ccbd0636bb 100644
> --- a/drivers/gpu/drm/i915/i915_vma.h
> +++ b/drivers/gpu/drm/i915/i915_vma.h
> @@ -289,26 +289,8 @@ int __must_check
> i915_vma_pin_ww(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
> u64 size, u64 alignment, u64 flags);
>
> -static inline int __must_check
> -i915_vma_pin(struct i915_vma *vma, u64 size, u64 alignment, u64 flags)
> -{
> - struct i915_gem_ww_ctx ww;
> - int err;
> -
> - i915_gem_ww_ctx_init(&ww, true);
> -retry:
> - err = i915_gem_object_lock(vma->obj, &ww);
> - if (!err)
> - err = i915_vma_pin_ww(vma, &ww, size, alignment, flags);
> - if (err == -EDEADLK) {
> - err = i915_gem_ww_ctx_backoff(&ww);
> - if (!err)
> - goto retry;
> - }
> - i915_gem_ww_ctx_fini(&ww);
> -
> - return err;
> -}
> +int __must_check
> +i915_vma_pin(struct i915_vma *vma, u64 size, u64 alignment, u64 flags);
>
> int i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
> u32 align, unsigned int flags);
> --
> 2.39.5
>
next prev parent reply other threads:[~2025-06-24 21:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 11:36 [PATCH] drm/i915: reduce stack usage in igt_vma_pin1() Arnd Bergmann
2025-06-24 21:14 ` Rodrigo Vivi [this message]
2025-06-24 21:26 ` Rodrigo Vivi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aFsVMcb79rp8kMpF@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=airlied@gmail.com \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=chaitanya.kumar.borah@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=krzysztof.niemiec@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nitin.r.gote@intel.com \
--cc=renjunw0@foxmail.com \
--cc=simona@ffwll.ch \
--cc=tursulin@ursulin.net \
--cc=tzimmermann@suse.de \
--cc=ville.syrjala@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).