Index | Thread | Search

From:
Martin Pieuchot <mpi@grenadille.net>
Subject:
pipe_buffer & KERNEL_LOCK()
To:
tech@openbsd.org
Date:
Sun, 20 Oct 2024 11:37:09 +0200

Download raw body.

Thread
It is safe to call km_alloc(9) without KERNEL_LOCK(), ok?

Index: kern/sys_pipe.c
===================================================================
RCS file: /cvs/src/sys/kern/sys_pipe.c,v
diff -u -p -r1.146 sys_pipe.c
--- kern/sys_pipe.c	9 May 2023 14:22:17 -0000	1.146
+++ kern/sys_pipe.c	2 Oct 2024 11:36:27 -0000
@@ -253,9 +253,7 @@ pipe_buffer_realloc(struct pipe *cpipe, 
 	/* buffer should be empty */
 	KASSERT(cpipe->pipe_buffer.cnt == 0);
 
-	KERNEL_LOCK();
 	buffer = km_alloc(size, &kv_any, &kp_pageable, &kd_waitok);
-	KERNEL_UNLOCK();
 	if (buffer == NULL)
 		return (ENOMEM);
 
@@ -767,9 +765,7 @@ pipe_buffer_free(struct pipe *cpipe)
 
 	size = cpipe->pipe_buffer.size;
 
-	KERNEL_LOCK();
 	km_free(cpipe->pipe_buffer.buffer, size, &kv_any, &kp_pageable);
-	KERNEL_UNLOCK();
 
 	cpipe->pipe_buffer.buffer = NULL;