All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/media/v4l2-core/v4l2-vp9.c: reduce inlining
@ 2026-11-25  6:08 Andrew Morton
  2026-11-27  3:07 ` Nicolas Dufresne
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2026-11-25  6:08 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media, Andrew Morton, Daniel Almeida

From: Andrew Morton <akpm@linux-foundation.org>
Subject: drivers/media/v4l2-core/v4l2-vp9.c: reduce inlining
Date: Tue May 26 03:14:09 PM PDT 2026

csky allmodconfig, gcc-15.2.0:

drivers/media/v4l2-core/v4l2-vp9.c: In function 'v4l2_vp9_adapt_noncoef_probs':
drivers/media/v4l2-core/v4l2-vp9.c:1834:1: error: the frame size of 1436 bytes is larger than 1280 bytes [-Werror=frame-larger-than=]

The amount of inlining in there is simply nuts.  This patch semi-randomly
uninlines various things and fixes the above.

Ad the .text size reduction is tremendous:

ts:/usr/src/25> size drivers/media/v4l2-core/v4l2-vp9.o
   text	   data	    bss	    dec	    hex	filename
  22450	     36	      0	  22486	   57d6	drivers/media/v4l2-core/v4l2-vp9.o-before
  16144	     36	      0	  16180	   3f34	drivers/media/v4l2-core/v4l2-vp9.o-after

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>

 drivers/media/v4l2-core/v4l2-vp9.c |   30 +++++++++++++--------------
 1 file changed, 15 insertions(+), 15 deletions(-)

--- a/drivers/media/v4l2-core/v4l2-vp9.c~drivers-media-v4l2-core-v4l2-vp9c-reduce-inlining
+++ a/drivers/media/v4l2-core/v4l2-vp9.c
@@ -1582,25 +1582,25 @@ static inline u8 noncoef_merge_prob(u8 p
  *	merge_prob(p[9], c[9], [10])
  */
 
-static inline void merge_probs_variant_a(u8 *p, const u32 *c, u16 count_sat, u32 update_factor)
+static noinline_for_stack void merge_probs_variant_a(u8 *p, const u32 *c, u16 count_sat, u32 update_factor)
 {
 	p[1] = merge_prob(p[1], c[0], c[1] + c[2], count_sat, update_factor);
 	p[2] = merge_prob(p[2], c[1], c[2], count_sat, update_factor);
 }
 
-static inline void merge_probs_variant_b(u8 *p, const u32 *c, u16 count_sat, u32 update_factor)
+static noinline_for_stack void merge_probs_variant_b(u8 *p, const u32 *c, u16 count_sat, u32 update_factor)
 {
 	p[0] = merge_prob(p[0], c[0], c[1], count_sat, update_factor);
 }
 
-static inline void merge_probs_variant_c(u8 *p, const u32 *c)
+static noinline_for_stack void merge_probs_variant_c(u8 *p, const u32 *c)
 {
 	p[0] = noncoef_merge_prob(p[0], c[2], c[1] + c[0] + c[3]);
 	p[1] = noncoef_merge_prob(p[1], c[0], c[1] + c[3]);
 	p[2] = noncoef_merge_prob(p[2], c[1], c[3]);
 }
 
-static void merge_probs_variant_d(u8 *p, const u32 *c)
+static noinline_for_stack void merge_probs_variant_d(u8 *p, const u32 *c)
 {
 	u32 sum = 0, s2;
 
@@ -1624,20 +1624,20 @@ static void merge_probs_variant_d(u8 *p,
 	p[8] = noncoef_merge_prob(p[8], c[6], c[7]);
 }
 
-static inline void merge_probs_variant_e(u8 *p, const u32 *c)
+static noinline_for_stack void merge_probs_variant_e(u8 *p, const u32 *c)
 {
 	p[0] = noncoef_merge_prob(p[0], c[0], c[1] + c[2] + c[3]);
 	p[1] = noncoef_merge_prob(p[1], c[1], c[2] + c[3]);
 	p[2] = noncoef_merge_prob(p[2], c[2], c[3]);
 }
 
-static inline void merge_probs_variant_f(u8 *p, const u32 *c)
+static noinline_for_stack void merge_probs_variant_f(u8 *p, const u32 *c)
 {
 	p[0] = noncoef_merge_prob(p[0], c[0], c[1] + c[2]);
 	p[1] = noncoef_merge_prob(p[1], c[1], c[2]);
 }
 
-static void merge_probs_variant_g(u8 *p, const u32 *c)
+static noinline_for_stack void merge_probs_variant_g(u8 *p, const u32 *c)
 {
 	u32 sum;
 
@@ -1659,12 +1659,12 @@ static void merge_probs_variant_g(u8 *p,
 }
 
 /* 8.4.3 Coefficient probability adaptation process */
-static inline void adapt_probs_variant_a_coef(u8 *p, const u32 *c, u32 update_factor)
+static noinline_for_stack void adapt_probs_variant_a_coef(u8 *p, const u32 *c, u32 update_factor)
 {
 	merge_probs_variant_a(p, c, 24, update_factor);
 }
 
-static inline void adapt_probs_variant_b_coef(u8 *p, const u32 *c, u32 update_factor)
+static noinline_for_stack void adapt_probs_variant_b_coef(u8 *p, const u32 *c, u32 update_factor)
 {
 	merge_probs_variant_b(p, c, 24, update_factor);
 }
@@ -1724,33 +1724,33 @@ static inline void adapt_probs_variant_b
 	merge_probs_variant_b(p, c, 20, 128);
 }
 
-static inline void adapt_probs_variant_c(u8 *p, const u32 *c)
+static noinline_for_stack void adapt_probs_variant_c(u8 *p, const u32 *c)
 {
 	merge_probs_variant_c(p, c);
 }
 
-static inline void adapt_probs_variant_d(u8 *p, const u32 *c)
+static noinline_for_stack void adapt_probs_variant_d(u8 *p, const u32 *c)
 {
 	merge_probs_variant_d(p, c);
 }
 
-static inline void adapt_probs_variant_e(u8 *p, const u32 *c)
+static noinline_for_stack void adapt_probs_variant_e(u8 *p, const u32 *c)
 {
 	merge_probs_variant_e(p, c);
 }
 
-static inline void adapt_probs_variant_f(u8 *p, const u32 *c)
+static noinline_for_stack void adapt_probs_variant_f(u8 *p, const u32 *c)
 {
 	merge_probs_variant_f(p, c);
 }
 
-static inline void adapt_probs_variant_g(u8 *p, const u32 *c)
+static noinline_for_stack void adapt_probs_variant_g(u8 *p, const u32 *c)
 {
 	merge_probs_variant_g(p, c);
 }
 
 /* 8.4.4 Non coefficient probability adaptation process, adapt_prob() */
-static inline u8 adapt_prob(u8 prob, const u32 counts[2])
+static noinline_for_stack u8 adapt_prob(u8 prob, const u32 counts[2])
 {
 	return noncoef_merge_prob(prob, counts[0], counts[1]);
 }
_

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drivers/media/v4l2-core/v4l2-vp9.c: reduce inlining
  2026-11-25  6:08 [PATCH] drivers/media/v4l2-core/v4l2-vp9.c: reduce inlining Andrew Morton
@ 2026-11-27  3:07 ` Nicolas Dufresne
  2026-11-27  3:19   ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Dufresne @ 2026-11-27  3:07 UTC (permalink / raw)
  To: Andrew Morton, Mauro Carvalho Chehab; +Cc: linux-media, Daniel Almeida

[-- Attachment #1: Type: text/plain, Size: 5838 bytes --]


Le mardi 24 novembre 2026 à 22:08 -0800, Andrew Morton a écrit :
> From: Andrew Morton <akpm@linux-foundation.org>
> Subject: drivers/media/v4l2-core/v4l2-vp9.c: reduce inlining

Should be: media: vp9: reduce inlining

The media CI gives you the information of what wasn't right.

> Date: Tue May 26 03:14:09 PM PDT 2026
> 
> csky allmodconfig, gcc-15.2.0:
> 
> drivers/media/v4l2-core/v4l2-vp9.c: In function 'v4l2_vp9_adapt_noncoef_probs':
> drivers/media/v4l2-core/v4l2-vp9.c:1834:1: error: the frame size of 1436 bytes is larger than 1280 bytes [-Werror=frame-larger-than=]
> 
> The amount of inlining in there is simply nuts.  This patch semi-randomly
> uninlines various things and fixes the above.
> 
> Ad the .text size reduction is tremendous:
> 
> ts:/usr/src/25> size drivers/media/v4l2-core/v4l2-vp9.o
>    text	   data	    bss	    dec	    hex	filename
>   22450	     36	      0	  22486	   57d6	drivers/media/v4l2-core/v4l2-vp9.o-before
>   16144	     36	      0	  16180	   3f34	drivers/media/v4l2-core/v4l2-vp9.o-after
> 
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> 
>  drivers/media/v4l2-core/v4l2-vp9.c |   30 +++++++++++++--------------
>  1 file changed, 15 insertions(+), 15 deletions(-)
> 
> --- a/drivers/media/v4l2-core/v4l2-vp9.c~drivers-media-v4l2-core-v4l2-vp9c-reduce-inlining
> +++ a/drivers/media/v4l2-core/v4l2-vp9.c
> @@ -1582,25 +1582,25 @@ static inline u8 noncoef_merge_prob(u8 p
>   *	merge_prob(p[9], c[9], [10])
>   */
>  
> -static inline void merge_probs_variant_a(u8 *p, const u32 *c, u16 count_sat, u32 update_factor)
> +static noinline_for_stack void merge_probs_variant_a(u8 *p, const u32 *c, u16 count_sat, u32 update_factor)
>  {
>  	p[1] = merge_prob(p[1], c[0], c[1] + c[2], count_sat, update_factor);
>  	p[2] = merge_prob(p[2], c[1], c[2], count_sat, update_factor);
>  }
>  
> -static inline void merge_probs_variant_b(u8 *p, const u32 *c, u16 count_sat, u32 update_factor)
> +static noinline_for_stack void merge_probs_variant_b(u8 *p, const u32 *c, u16 count_sat, u32 update_factor)
>  {
>  	p[0] = merge_prob(p[0], c[0], c[1], count_sat, update_factor);
>  }
>  
> -static inline void merge_probs_variant_c(u8 *p, const u32 *c)
> +static noinline_for_stack void merge_probs_variant_c(u8 *p, const u32 *c)
>  {
>  	p[0] = noncoef_merge_prob(p[0], c[2], c[1] + c[0] + c[3]);
>  	p[1] = noncoef_merge_prob(p[1], c[0], c[1] + c[3]);
>  	p[2] = noncoef_merge_prob(p[2], c[1], c[3]);
>  }
>  
> -static void merge_probs_variant_d(u8 *p, const u32 *c)
> +static noinline_for_stack void merge_probs_variant_d(u8 *p, const u32 *c)
>  {
>  	u32 sum = 0, s2;
>  
> @@ -1624,20 +1624,20 @@ static void merge_probs_variant_d(u8 *p,
>  	p[8] = noncoef_merge_prob(p[8], c[6], c[7]);
>  }
>  
> -static inline void merge_probs_variant_e(u8 *p, const u32 *c)
> +static noinline_for_stack void merge_probs_variant_e(u8 *p, const u32 *c)
>  {
>  	p[0] = noncoef_merge_prob(p[0], c[0], c[1] + c[2] + c[3]);
>  	p[1] = noncoef_merge_prob(p[1], c[1], c[2] + c[3]);
>  	p[2] = noncoef_merge_prob(p[2], c[2], c[3]);
>  }
>  
> -static inline void merge_probs_variant_f(u8 *p, const u32 *c)
> +static noinline_for_stack void merge_probs_variant_f(u8 *p, const u32 *c)
>  {
>  	p[0] = noncoef_merge_prob(p[0], c[0], c[1] + c[2]);
>  	p[1] = noncoef_merge_prob(p[1], c[1], c[2]);
>  }
>  
> -static void merge_probs_variant_g(u8 *p, const u32 *c)
> +static noinline_for_stack void merge_probs_variant_g(u8 *p, const u32 *c)
>  {
>  	u32 sum;
>  
> @@ -1659,12 +1659,12 @@ static void merge_probs_variant_g(u8 *p,
>  }
>  
>  /* 8.4.3 Coefficient probability adaptation process */
> -static inline void adapt_probs_variant_a_coef(u8 *p, const u32 *c, u32 update_factor)
> +static noinline_for_stack void adapt_probs_variant_a_coef(u8 *p, const u32 *c, u32 update_factor)
>  {
>  	merge_probs_variant_a(p, c, 24, update_factor);
>  }
>  
> -static inline void adapt_probs_variant_b_coef(u8 *p, const u32 *c, u32 update_factor)
> +static noinline_for_stack void adapt_probs_variant_b_coef(u8 *p, const u32 *c, u32 update_factor)
>  {
>  	merge_probs_variant_b(p, c, 24, update_factor);
>  }
> @@ -1724,33 +1724,33 @@ static inline void adapt_probs_variant_b
>  	merge_probs_variant_b(p, c, 20, 128);
>  }
>  
> -static inline void adapt_probs_variant_c(u8 *p, const u32 *c)
> +static noinline_for_stack void adapt_probs_variant_c(u8 *p, const u32 *c)
>  {
>  	merge_probs_variant_c(p, c);
>  }
>  
> -static inline void adapt_probs_variant_d(u8 *p, const u32 *c)
> +static noinline_for_stack void adapt_probs_variant_d(u8 *p, const u32 *c)
>  {
>  	merge_probs_variant_d(p, c);
>  }
>  
> -static inline void adapt_probs_variant_e(u8 *p, const u32 *c)
> +static noinline_for_stack void adapt_probs_variant_e(u8 *p, const u32 *c)
>  {
>  	merge_probs_variant_e(p, c);
>  }
>  
> -static inline void adapt_probs_variant_f(u8 *p, const u32 *c)
> +static noinline_for_stack void adapt_probs_variant_f(u8 *p, const u32 *c)
>  {
>  	merge_probs_variant_f(p, c);
>  }
>  
> -static inline void adapt_probs_variant_g(u8 *p, const u32 *c)
> +static noinline_for_stack void adapt_probs_variant_g(u8 *p, const u32 *c)
>  {
>  	merge_probs_variant_g(p, c);
>  }
>  
>  /* 8.4.4 Non coefficient probability adaptation process, adapt_prob() */
> -static inline u8 adapt_prob(u8 prob, const u32 counts[2])
> +static noinline_for_stack u8 adapt_prob(u8 prob, const u32 counts[2])
>  {
>  	return noncoef_merge_prob(prob, counts[0], counts[1]);
>  }
> 

Ok, so this is pretty random overall, someone will have to actually write a
proper patch.

Nicolas

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drivers/media/v4l2-core/v4l2-vp9.c: reduce inlining
  2026-11-27  3:07 ` Nicolas Dufresne
@ 2026-11-27  3:19   ` Andrew Morton
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2026-11-27  3:19 UTC (permalink / raw)
  To: Nicolas Dufresne; +Cc: Mauro Carvalho Chehab, linux-media, Daniel Almeida

On Thu, 26 Nov 2026 22:07:55 -0500 Nicolas Dufresne <nicolas@ndufresne.ca> wrote:

> 
> Le mardi 24 novembre 2026 à 22:08 -0800, Andrew Morton a écrit :
> > From: Andrew Morton <akpm@linux-foundation.org>
> > Subject: drivers/media/v4l2-core/v4l2-vp9.c: reduce inlining
> 
> Should be: media: vp9: reduce inlining
> 
> The media CI gives you the information of what wasn't right.

eh.  Please treat my trollpatch as a bug report ;)

> 
> Ok, so this is pretty random overall, someone will have to actually write a
> proper patch.

I said "semi-randomly" :)

Yeah, please do.

Sigh, kernel causes so much self-harm with excessive inlining.  Think
of all the cache misses which result from 10k of additional .text and
~1k of excess stack.

Those misses are so much more expensive than saving a few call/ret
instructions.  We should ban inlining by default unless benchmarking is
provided to demonstrate it benefits!




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-27  3:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  6:08 [PATCH] drivers/media/v4l2-core/v4l2-vp9.c: reduce inlining Andrew Morton
2026-11-27  3:07 ` Nicolas Dufresne
2026-11-27  3:19   ` Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.