Page MenuHomeFreeBSD

Support run-time configuration of the PIPE_MINDIRECT threshold.
ClosedPublic

Authored by rwatson on Apr 18 2021, 11:51 AM.

Details

Summary

PIPE_MINDIRECT determines at what (blocking) write size one-copy
optimizations are applied in pipe(2) I/O. That threshold hasn't
been tuned since the 1990s when this code was originally
committed, and allowing run-time reconfiguration will make it
easier to assess whether contemporary microarchitectures would
prefer a different threshold.

(On our local RPi4 baords, the 8k default would ideally be at least
32k, but it's not clear how generalizable that observation is.)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

pipe.h has:

/*
 * PIPE_MINDIRECT MUST be smaller than PIPE_SIZE and MUST be bigger
 * than PIPE_BUF.
 */

Do we need to do any validation of the value?

pipe.h has:

/*
 * PIPE_MINDIRECT MUST be smaller than PIPE_SIZE and MUST be bigger
 * than PIPE_BUF.
 */

Do we need to do any validation of the value?

I wasn't imagining we keep this around indefinitely or that it was a regularly frobbed setting. But adding validation is not difficult, and some other similar-ish sysctls do have such checking (e.g., SB_MAX). The value of PIPE_SIZE might also be interesting to revisit -- or at least its implied use here. MAXPIPESIZE has a more sensible value, and if one's using MAXPIPESIZE, one might as well not bother doing a check as other limits will prevent overflowing that [I believe].

Use a sysctl handler to limit possible values of kern.ipc.pipe_mindirect.

Style nit otherwise looks sensible

sys/kern/sys_pipe.c
273

style(9) is to not rely on implicit boolean conversions, ie != 0 and == NULL

This revision is now accepted and ready to land.Apr 24 2021, 12:51 AM
  • Style fix: Differentiate arbitrary integer values from booleans.
This revision now requires review to proceed.Apr 24 2021, 3:32 PM
This revision is now accepted and ready to land.Apr 24 2021, 4:32 PM