---
name: "idr_preload"
section: "9"
platform: "linux"
package: "linux-manual-4.9"
version: "4.9.228-1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/idr_preload"
---

# idr\_preload(9)

preload for idr\_alloc

## NAME

idr\_preload - preload for **idr\_alloc**

## SYNOPSIS

**void idr\_preload(gfp\_t** *gfp\_mask***);**

## ARGUMENTS

*gfp\_mask*

allocation mask to use for preloading

## DESCRIPTION

Preload per-cpu layer buffer for **idr\_alloc**. Can only be used from process context and each **idr\_preload** invocation should be matched with **idr\_preload\_end**. Note that preemption is disabled while preloaded.

The first **idr\_alloc** in the preloaded section can be treated as if it were invoked with *gfp\_mask* used for preloading. This allows using more permissive allocation masks for idrs protected by spinlocks.

For example, if **idr\_alloc** below fails, the failure can be treated as if **idr\_alloc** were called with GFP\_KERNEL rather than GFP\_NOWAIT.

idr\_preload(GFP\_KERNEL); spin\_lock(lock);

id = idr\_alloc(idr, ptr, start, end, GFP\_NOWAIT);

spin\_unlock(lock); **idr\_preload\_end**; if (id \< 0) error;

## COPYRIGHT
