lkml.org 
[lkml]   [2016]   [Feb]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 1/2] lib/percpu-list: Per-cpu list with associated per-cpu locks
On Wed, Feb 17, 2016 at 12:26:54PM +0100, Peter Zijlstra wrote:
> On Wed, Feb 17, 2016 at 10:10:02PM +1100, Dave Chinner wrote:
> > On Wed, Feb 17, 2016 at 12:00:40PM +0100, Peter Zijlstra wrote:
>
> > > Yeah, that is pretty terrible. Maybe a visitor interface is advisable?
> > >
> > > visit_percpu_list_entries(struct percpu_list *head, void (*visitor)(struct list_head *pos, void *data), void *data)
> > > {
> > > int cpu;
> > >
> > > for_each_possible_cpu(cpu) {
> > > spinlock_t *lock = per_cpu_ptr(&head->lock, cpu);
> > > struct list_head *head = per_cpu_ptr(&head->list, cpu);
> > > struct list_head *pos, *tmp;
> > >
> > > spin_lock(lock);
> > > for (pos = head->next, tmp = pos->next; pos != head; pos = tmp)
> > > visitor(pos, data);
> >
> > I thought about this - it's the same problem as the list_lru walking
> > functions. That is, the visitor has to be able to drop the list lock
> > to do blocking operations, so the lock has to be passed to the
> > visitor/internal loop context somehow, and the way the callers can
> > use it need to be documented.
>
> But you cannot drop the lock and guarantee fwd progress. The moment you
> drop the lock, you have to restart the iteration from the head, since
> any iterator you had might now be pointing into space.

Ah, I see what iterate_bdevs() does. Yes, that's somewhat 'special'. Not
sure it makes sense to craft a generic 'interface' for that.

\
 
 \ /
  Last update: 2016-02-17 12:41    [W:0.060 / U:0.516 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site