Project

General

Profile

Actions

Feature #14465

closed

Present KM_NOSLEEP_LAZY as documented interface

Added by Dan McDonald 7 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
kernel
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

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.


Related issues

Related to illumos gate - Bug #5253: kmem_alloc/kmem_zalloc won't fail with KM_SLEEPNewJosef Sipek2014-10-23

Actions
Related to illumos gate - Bug #5513: KM_NORMALPRI should be documented in kmem_alloc(9f) and kmem_cache_create(9f) man pagesClosed2015-01-08

Actions
Related to illumos gate - Feature #10704: allocb() should decide about priorityNew2019-04-09

Actions
Actions #1

Updated by Dan McDonald 7 months ago

  • Related to Bug #5253: kmem_alloc/kmem_zalloc won't fail with KM_SLEEP added
Actions #2

Updated by Dan McDonald 7 months ago

  • Related to Bug #5513: KM_NORMALPRI should be documented in kmem_alloc(9f) and kmem_cache_create(9f) man pages added
Actions #3

Updated by Dan McDonald 7 months ago

  • Related to Feature #10704: allocb() should decide about priority added
Actions #4

Updated by Electric Monk 7 months ago

  • Gerrit CR set to 1994
Actions #5

Updated by Dan McDonald 7 months ago

An initial DEBUG build check with wsdiff seems to only show line-numbers for files where line-reduction occurred.

Actions #6

Updated by Joshua M. Clulow 7 months ago

Weak doesn't necessarily feel like the best word here. What about, instead, KM_NOSLEEP_LAZY?

Actions #7

Updated by Dan McDonald 7 months ago

  • Subject changed from Present KM_NOSLEEP_WEAK as documented interface to Present KM_NOSLEEP_LAZY as documented interface

Lazy sounds good. Changing subject and from now on it's KM_NOSLEEP_LAZY.

Actions #8

Updated by Dan McDonald 7 months ago

Tested with wsdiff between non-DEBUG builds. Only .text differences were line number adjustments for VERIFY calls.

Actions #9

Updated by Electric Monk 6 months ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit ca783257c986cddcc674ae22916a6766b98a2d36

commit  ca783257c986cddcc674ae22916a6766b98a2d36
Author: Dan McDonald <danmcd@joyent.com>
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 <andy@omnios.org>
    Approved by: Robert Mustacchi <rm@fingolfin.org>

Actions

Also available in: Atom PDF