Skip to content
Snippets Groups Projects
  • Avi Kivity's avatar
    63ab89b6
    percpu: per-cpu variables · 63ab89b6
    Avi Kivity authored
    Per-cpu variables can be used from contexts where preemption is disabled
    (such as interrupts) or when migration is impossible (pinned threads) for
    managing data that is replicated for each cpu.
    
    The API is a smart pointer to a variable which resolves to the object's
    location on the current cpu.
    
    Define:
    
       #include <osv/percpu.hh>
    
       PERCPU(int, my_counter);
       PERCPU(foo, my_foo);
    
    Use:
    
       ++*my_counter;
       my_foo->member = 7;
    63ab89b6
    History
    percpu: per-cpu variables
    Avi Kivity authored
    Per-cpu variables can be used from contexts where preemption is disabled
    (such as interrupts) or when migration is impossible (pinned threads) for
    managing data that is replicated for each cpu.
    
    The API is a smart pointer to a variable which resolves to the object's
    location on the current cpu.
    
    Define:
    
       #include <osv/percpu.hh>
    
       PERCPU(int, my_counter);
       PERCPU(foo, my_foo);
    
    Use:
    
       ++*my_counter;
       my_foo->member = 7;