Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1333520

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

From Tejun Heo <tj@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min operations
Date 2016-02-14 18:00 +0100
Message-ID <r28bF-5jV-11@gated-at.bofh.it> (permalink)
References <r20QO-FA-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 add/subtract only if result will be not bigger than max/lower that min.
> Returns true if operation was done and false otherwise.

If I'm reading the code right, all the above functions do is wrapping
the corresponding cmpxchg implementations.  Given that most use cases
would build further abstractions on top, I'm not sure how useful
providing another layer of abstraction is.  For the most part, we
introduce new per-cpu operations to take advantage of capabilities of
underlying hardware which can't be utilized in a different way (like
the x86 128bit atomic ops).

Thanks.

-- 
tejun

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH RFC] Introduce atomic and per-cpu add-max and sub-min  operations Konstantin Khlebnikov <koct9i@gmail.com> - 2016-02-14 10:10 +0100
  Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min  operations Tejun Heo <tj@kernel.org> - 2016-02-14 18:00 +0100
    Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min operations Konstantin Khlebnikov <koct9i@gmail.com> - 2016-02-14 18:40 +0100
      Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min  operations Christoph Lameter <cl@linux.com> - 2016-02-16 17:20 +0100
  Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min  operations Will Deacon <will.deacon@arm.com> - 2016-02-15 12:00 +0100
    Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min operations Konstantin Khlebnikov <koct9i@gmail.com> - 2016-02-15 12:20 +0100
    Re: [PATCH RFC] Introduce atomic and per-cpu add-max and sub-min  operations Peter Zijlstra <peterz@infradead.org> - 2016-02-15 15:20 +0100

csiph-web