Linux Trace Kernel
 help / color / mirror / Atom feed
* [PATCH v1] ring-buffer: Use is_user_task() in __rb_allocate_pages()
@ 2026-10-16 15:47 Vincent Donnefort
  0 siblings, 0 replies; only message in thread
From: Vincent Donnefort @ 2026-10-16 15:47 UTC (permalink / raw)
  To: rostedt, mhiramat, linux-trace-kernel
  Cc: mathieu.desnoyers, kernel-team, linux-kernel, Vincent Donnefort

Before allocating ring buffer pages, __rb_allocate_pages() checks the
available memory with si_mem_available(). This is however only a rough
estimate and may report memory that can't be used for this allocation.
In the event of an OOM, we don't want to penalise another task with the
OOM killer, so the allocating thread is marked as the OOM origin when it
is a user task.

Checking current->mm is however not sufficient to distinguish user from
kernel tasks. Instead, use is_user_task().

Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
---
 kernel/trace/ring_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 9c4e40847e43..bcc28d50c634 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -2468,7 +2468,7 @@ static int __rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer,
 		if (i < (nr_pages << subbuf_order))
 			return -ENOMEM;
 
-		user_thread = current->mm != NULL;
+		user_thread = is_user_task(current);
 	}
 
 	/*

base-commit: c47a7b11bcb3d45e29723afcf6336866476b1d08
-- 
2.56.0.176.g3575e65682-goog


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-16 15:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-16 15:47 [PATCH v1] ring-buffer: Use is_user_task() in __rb_allocate_pages() Vincent Donnefort

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox