lkml.org 
[lkml]   [2007]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] local_t : Documentation
    On Mon, 8 Jan 2007 22:14:46 -0500
    Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> wrote:

    > +* How to use local atomic operations
    > +
    > +#include <linux/percpu.h>
    > +#include <asm/local.h>
    > +
    > +static DEFINE_PER_CPU(local_t, counters) = LOCAL_INIT(0);
    > +
    > +
    > +* Counting
    > +
    > +In preemptible context, use get_cpu_var() and put_cpu_var() around local atomic
    > +operations : it makes sure that preemption is disabled around write access to
    > +the per cpu variable. For instance :
    > +
    > + local_inc(&get_cpu_var(counters));
    > + put_cpu_var(counters);

    Confused. The whole point behind local_t is that we can do
    atomic-wrt-interrupts inc and dec on them.

    Consequently, as atomic-wrt-interrupts means atomic-wrt-preemption, there
    is no need to do a preempt_disable() around local_inc() and local_dec().

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2007-01-09 22:41    [W:0.028 / U:1.140 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site