lkml.org 
[lkml]   [2013]   [Aug]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH-v3 1/4] idr: Percpu ida
On Wed, Aug 21, 2013 at 06:25:58PM +0000, Christoph Lameter wrote:
> On Fri, 16 Aug 2013, Nicholas A. Bellinger wrote:
>
> > + spinlock_t lock;
>
> Remove the spinlock.

As Andrew noted, the spinlock is needed because of tag stealing. (You
don't think I'd stick a spinlock on a percpu data structure without a
real reason, would you?)

> > + unsigned nr_free;
> > + unsigned freelist[];
> > +};
> > +
> > +static inline void move_tags(unsigned *dst, unsigned *dst_nr,
> > + unsigned *src, unsigned *src_nr,
> > + unsigned nr)
> > +{
> > + *src_nr -= nr;
> > + memcpy(dst + *dst_nr, src + *src_nr, sizeof(unsigned) * nr);
> > + *dst_nr += nr;
> > +}
> > +
>
> > +static inline unsigned alloc_local_tag(struct percpu_ida *pool,
> > + struct percpu_ida_cpu *tags)
>
> Pass the __percpu offset and not the tags pointer.

Why? It just changes where the this_cpu_ptr

>
> > +{
> > + int tag = -ENOSPC;
> > +
> > + spin_lock(&tags->lock);
>
> Interupts are already disabled. Drop the spinlock.
>
> > + if (tags->nr_free)
> > + tag = tags->freelist[--tags->nr_free];
>
> You can keep this or avoid address calculation through segment prefixes.
> F.e.
>
> if (__this_cpu_read(tags->nrfree) {
> int n = __this_cpu_dec_return(tags->nr_free);
> tag = __this_cpu_read(tags->freelist[n]);
> }

Can you explain what the point of that change would be? It sounds like
it's preferable to do it that way and avoid this_cpu_ptr() for some
reason, but you're not explaining why.


\
 
 \ /
  Last update: 2013-08-26 22:41    [W:0.160 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site