Re: [PATCH v6 bpf-next 1/9] bpf: introduce bpf_spin_lock

2019-01-31 Thread Alexei Starovoitov
On Thu, Jan 31, 2019 at 11:47:54AM +0100, Peter Zijlstra wrote: > > + local_irq_save(flags); > > + __bpf_spin_lock(lock); > > + this_cpu_write(irqsave_flags, flags); > > __this_cpu_write() sure. will do

Re: [PATCH v6 bpf-next 1/9] bpf: introduce bpf_spin_lock

2019-01-31 Thread Peter Zijlstra
On Wed, Jan 30, 2019 at 09:05:38PM -0800, Alexei Starovoitov wrote: > Introduce 'struct bpf_spin_lock' and bpf_spin_lock/unlock() helpers to let > bpf program serialize access to other variables. > > Example: > struct hash_elem { > int cnt; > struct bpf_spin_lock lock; > }; > struct hash_e

[PATCH v6 bpf-next 1/9] bpf: introduce bpf_spin_lock

2019-01-30 Thread Alexei Starovoitov
Introduce 'struct bpf_spin_lock' and bpf_spin_lock/unlock() helpers to let bpf program serialize access to other variables. Example: struct hash_elem { int cnt; struct bpf_spin_lock lock; }; struct hash_elem * val = bpf_map_lookup_elem(&hash_map, &key); if (val) { bpf_spin_lock(&val->l