pipe: Avoid unnecessary priv_check() calls in pipespace_new()

Running out of pipe map KVA is a rare case, so reorder checks
accordingly, presuming that calling priv_check() is more expensive than
the calculation.  In particular, priv_check() might not be cheap to
evaluate if MAC hooks are installed.

Reviewed by:	olce, kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D55378
This commit is contained in:
Mark Johnston
2026-02-21 16:28:49 +00:00
parent 0fa6ce2556
commit fa77660a3c
+2 -2
View File
@@ -592,8 +592,8 @@ pipespace_new(struct pipe *cpipe, int size)
}
vm_map_lock(pipe_map);
if (priv_check(curthread, PRIV_PIPEBUF) != 0 && maxpipekva / 100 *
(100 - pipebuf_reserv) < amountpipekva + size) {
if (maxpipekva / 100 * (100 - pipebuf_reserv) < amountpipekva + size &&
priv_check(curthread, PRIV_PIPEBUF) != 0) {
vm_map_unlock(pipe_map);
chgpipecnt(cpipe->pipe_pair->pp_owner->cr_ruidinfo, -size, 0);
if (cpipe->pipe_buffer.buffer == NULL &&