Page MenuHomeFreeBSD

Support run-time configuration of the PIPE_MINDIRECT threshold.
ClosedPublic

Authored by rwatson on Apr 18 2021, 11:51 AM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 8 2024, 7:24 PM
Unknown Object (File)
Feb 8 2024, 7:24 PM
Unknown Object (File)
Feb 8 2024, 7:24 PM
Unknown Object (File)
Jan 18 2024, 3:27 AM
Unknown Object (File)
Dec 23 2023, 10:50 PM
Unknown Object (File)
Dec 23 2023, 9:19 AM
Unknown Object (File)
Dec 13 2023, 6:49 AM
Unknown Object (File)
Dec 12 2023, 1:52 PM
Subscribers

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
Lint Not Applicable
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
274

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