Index | Thread | Search

From:
Vitaliy Makkoveev <otto@bsdbox.dev>
Subject:
Re: pipe_buffer & KERNEL_LOCK()
To:
Martin Pieuchot <mpi@grenadille.net>
Cc:
tech@openbsd.org
Date:
Sun, 20 Oct 2024 13:41:11 +0300

Download raw body.

Thread
ok mvs

> On 20 Oct 2024, at 12:37, Martin Pieuchot <mpi@grenadille.net> wrote:
> 
> 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;
>