Skip to content
This repository was archived by the owner on Mar 7, 2021. It is now read-only.
This repository was archived by the owner on Mar 7, 2021. It is now read-only.

Automatically pass the right GFP flags depending on context #259

@geofft

Description

@geofft

@joshtriplett proposed a more ambitious but easier-to-use way to solve the GFP_ flag problem (see also #258): have something like a thread-local variable that tracks what GFP flags you're allowed to use. Then you can just call kmalloc(GFP_AUTO) and have it figure things out for you.

This would be worthwhile in the upstream C code, ultimately, but it seems to make sense to start by implementing it just for Rust, because we can do things like

with_gfp(GFP_ATOMIC, || {
    let g = CriticalSectionGuard();
    let something = Box::new(...);
})

and C doesn't quite have comparable syntax - you'd need to manually put things back when you're out of the critical section.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions