# Re: \[PATCH v5 10/10\] ring-buffer: Make nr\_pages unsigned int

- From: Vincent Donnefort \<vdonnefort@google.com\>
- Date: 2026-08-14 08:07:30 
- List: linux-trace-kernel
- Page: https://ratatoskr.run/linux-trace-kernel/2026/08/17411517
- Thread: https://ratatoskr.run/sashiko-reviews/2026/08/17410469/t.md

```text
On Thu, Aug 13, 2026 at 09:41:56PM -0400, Steven Rostedt wrote:
> On Thu, 13 Aug 2026 13:55:26 +0000
> sashiko-bot@kernel.org wrote:
> 
> > > @@ -3264,7 +3263,7 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
> > >  			int cpu_id)
> > >  {
> > >  	struct ring_buffer_per_cpu *cpu_buffer;
> > > -	unsigned long nr_pages;
> > > +	unsigned int nr_pages;  
> > 
> > [Severity: Critical]
> > If a huge value is written to buffer_size_kb, could the unsigned
> > difference between nr_pages and cpu_buffer->nr_pages overflow when
> > assigned to the now 32-bit signed cpu_buffer->nr_pages_to_update?
> 
> I agree. I never wanted to limit the size of the ring buffer. If anything,
> I would want to make all references to nr_pages to be long. Otherwise we
> are capping the size of the ring buffer to 8 terabytes per CPU. Yeah, that
> may sound huge, but believe me, in the not so distant future, it may be
> desirable.
> 
> I'm fine with keeping persistent memory and even special case mappings
> limited to MAX_INT pages. But not the ring buffer as a whole.
> 
> -- Steve

So, keeping nr_pages unsigned long everywhere but -E2BIG for the cases where we
are limited to 32-bits, that is persistent buffers, user-mapped buffers and
remotes?

-- 
Vincent
```
