Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min operations

2016-02-16 Thread Christoph Lameter
On Sun, 14 Feb 2016, Konstantin Khlebnikov wrote: > Yep, they are just abstraction around cmpxchg, as well as a half of atomic > operations. Probably some architectures could implement this differently. Ok then use this_cpu_cmpxchg and cmpxchg to implement it instead?

Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min operations

2016-02-16 Thread Christoph Lameter
On Sun, 14 Feb 2016, Konstantin Khlebnikov wrote: > Yep, they are just abstraction around cmpxchg, as well as a half of atomic > operations. Probably some architectures could implement this differently. Ok then use this_cpu_cmpxchg and cmpxchg to implement it instead?

Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min operations

2016-02-15 Thread Peter Zijlstra
On Mon, Feb 15, 2016 at 10:50:29AM +, Will Deacon wrote: > Adding Peter and Paul, > > On Sun, Feb 14, 2016 at 12:09:00PM +0300, Konstantin Khlebnikov wrote: > > bool atomic_add_max(atomic_t *var, int add, int max); > > bool atomic_sub_min(atomic_t *var, int sub, int min); > > What are the

Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min operations

2016-02-15 Thread Peter Zijlstra
On Mon, Feb 15, 2016 at 10:50:29AM +, Will Deacon wrote: > Adding Peter and Paul, > > On Sun, Feb 14, 2016 at 12:09:00PM +0300, Konstantin Khlebnikov wrote: > > bool atomic_add_max(atomic_t *var, int add, int max); > > bool atomic_sub_min(atomic_t *var, int sub, int min); > > What are the

Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min operations

2016-02-15 Thread Konstantin Khlebnikov
On Mon, Feb 15, 2016 at 1:50 PM, Will Deacon wrote: > Adding Peter and Paul, > > On Sun, Feb 14, 2016 at 12:09:00PM +0300, Konstantin Khlebnikov wrote: >> bool atomic_add_max(atomic_t *var, int add, int max); >> bool atomic_sub_min(atomic_t *var, int sub, int min); > > What

Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min operations

2016-02-15 Thread Konstantin Khlebnikov
On Mon, Feb 15, 2016 at 1:50 PM, Will Deacon wrote: > Adding Peter and Paul, > > On Sun, Feb 14, 2016 at 12:09:00PM +0300, Konstantin Khlebnikov wrote: >> bool atomic_add_max(atomic_t *var, int add, int max); >> bool atomic_sub_min(atomic_t *var, int sub, int min); > > What are the

Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min operations

2016-02-15 Thread Will Deacon
Adding Peter and Paul, On Sun, Feb 14, 2016 at 12:09:00PM +0300, Konstantin Khlebnikov wrote: > bool atomic_add_max(atomic_t *var, int add, int max); > bool atomic_sub_min(atomic_t *var, int sub, int min); What are the memory-ordering requirements for these? Do you also want

Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min operations

2016-02-15 Thread Will Deacon
Adding Peter and Paul, On Sun, Feb 14, 2016 at 12:09:00PM +0300, Konstantin Khlebnikov wrote: > bool atomic_add_max(atomic_t *var, int add, int max); > bool atomic_sub_min(atomic_t *var, int sub, int min); What are the memory-ordering requirements for these? Do you also want

Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min operations

2016-02-14 Thread Konstantin Khlebnikov
On Sun, Feb 14, 2016 at 7:51 PM, Tejun Heo wrote: > Hello, Konstantin. > > On Sun, Feb 14, 2016 at 12:09:00PM +0300, Konstantin Khlebnikov wrote: >> bool atomic_add_max(atomic_t *var, int add, int max); >> bool atomic_sub_min(atomic_t *var, int sub, int min); >> >> bool this_cpu_add_max(var, add,

Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min operations

2016-02-14 Thread Tejun Heo
Hello, Konstantin. On Sun, Feb 14, 2016 at 12:09:00PM +0300, Konstantin Khlebnikov wrote: > bool atomic_add_max(atomic_t *var, int add, int max); > bool atomic_sub_min(atomic_t *var, int sub, int min); > > bool this_cpu_add_max(var, add, max); > bool this_cpu_sub_min(var, sub, min); > > They

[PATCH RFC] Introduce atomic and per-cpu add-max and sub-min operations

2016-02-14 Thread Konstantin Khlebnikov
bool atomic_add_max(atomic_t *var, int add, int max); bool atomic_sub_min(atomic_t *var, int sub, int min); bool this_cpu_add_max(var, add, max); bool this_cpu_sub_min(var, sub, min); They add/subtract only if result will be not bigger than max/lower that min. Returns true if operation was done

Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min operations

2016-02-14 Thread Tejun Heo
Hello, Konstantin. On Sun, Feb 14, 2016 at 12:09:00PM +0300, Konstantin Khlebnikov wrote: > bool atomic_add_max(atomic_t *var, int add, int max); > bool atomic_sub_min(atomic_t *var, int sub, int min); > > bool this_cpu_add_max(var, add, max); > bool this_cpu_sub_min(var, sub, min); > > They

Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min operations

2016-02-14 Thread Konstantin Khlebnikov
On Sun, Feb 14, 2016 at 7:51 PM, Tejun Heo wrote: > Hello, Konstantin. > > On Sun, Feb 14, 2016 at 12:09:00PM +0300, Konstantin Khlebnikov wrote: >> bool atomic_add_max(atomic_t *var, int add, int max); >> bool atomic_sub_min(atomic_t *var, int sub, int min); >> >> bool

[PATCH RFC] Introduce atomic and per-cpu add-max and sub-min operations

2016-02-14 Thread Konstantin Khlebnikov
bool atomic_add_max(atomic_t *var, int add, int max); bool atomic_sub_min(atomic_t *var, int sub, int min); bool this_cpu_add_max(var, add, max); bool this_cpu_sub_min(var, sub, min); They add/subtract only if result will be not bigger than max/lower that min. Returns true if operation was done