Present KM_NOSLEEP_LAZY as documented interface
Recent inspections of kernel memory allocation have brought to my attention some older bugs relating to the just-before-OpenSolaris-closed KM_NORMALPRI modifier for kmem_alloc(9f) and friends:
#5253 (callers with KM_SLEEP check for returns)
#5513 (document KM_NORMALPI in kmem_alloc(9f) and friends)
#10704 (allocb() should be more aware of priority, and so should its callers)
KM_NORMALPRI is no good by itself, it MUST appear with KM_NOSLEEP. This leads to a lot of: kmem_alloc(size, (KM_NOSLEEP | KM_NORMALPRI)).
This feature-requests proposes some syntactic sugar:
#define KM_NOSLEEP_WEAK (KM_NOSLEEP | KM_NORMALPRI) /* Non-sleeping allocation with no aggressive reclaim */
This is a bit simpler to remember, and would make for a FINE public interface, never mind more readable existing code.
For least-surprise purposes, I check Oracle's public documentation on kmem_alloc() and like us, they have no mention of KM_NORMALPRI, nor any such syntactic sugar.
Updated by Electric Monk 6 months ago
- Status changed from New to Closed
- % Done changed from 0 to 100
commit ca783257c986cddcc674ae22916a6766b98a2d36 Author: Dan McDonald <firstname.lastname@example.org> Date: 2022-02-22T15:44:37.000Z 5513 KM_NORMALPRI should be documented in kmem_alloc(9f) and kmem_cache_create(9f) man pages 14465 Present KM_NOSLEEP_LAZY as documented interface Reviewed by: Andy Fiddaman <email@example.com> Approved by: Robert Mustacchi <firstname.lastname@example.org>