Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1362295
| From | Waiman Long <waiman.long@hpe.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v6 1/4] lib/percpu-list: Per-cpu list with associated per-cpu locks |
| Date | 2016-03-22 03:40 +0100 |
| Message-ID | <rfkoG-6ju-1@gated-at.bofh.it> (permalink) |
| References | <re8zg-6xu-5@gated-at.bofh.it> <re8zg-6xu-21@gated-at.bofh.it> <rf4Dg-3Gc-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 03/21/2016 05:49 AM, Jan Kara wrote:
> On Fri 18-03-16 15:44:01, Waiman Long wrote:
>> +static __always_inline bool
>> +__pcpu_list_next_cpu(struct pcpu_list_head *head, struct pcpu_list_state *state)
>> +{
>> + if (state->lock)
>> + spin_unlock(state->lock);
>> +next_cpu:
>> + /*
>> + * for_each_possible_cpu(cpu)
>> + */
>> + state->cpu = cpumask_next(state->cpu, cpu_possible_mask);
>> + if (state->cpu>= nr_cpu_ids)
>> + return false; /* All the per-cpu lists iterated */
>> +
>> + state->head =&per_cpu_ptr(head, state->cpu)->list;
>> + if (list_empty(state->head))
>> + goto next_cpu;
>> +
>> + state->lock =&per_cpu_ptr(head, state->cpu)->lock;
>> + spin_lock(state->lock);
>> + state->curr = list_entry(state->head->next,
>> + struct pcpu_list_node, list);
>> + return true;
> Waiman, I repeat it for the third time as you keep ignoring it: This is
> *racy*. The list for state->cpu can be empty by the time you acquire
> state->lock and thus state->curr will point somewhere around the head of
> the list but definitely not to a list member where it should.
>
> Honza
I am sorry for missing your previous comment. Yes, it is possible that
the list is empty after the lock. So I should have checked for that
before returning. Thanks for reminding me that. I will fix that later on.
Cheers,
Longman
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v6 0/4] vfs: Use per-cpu list for SB's s_inodes list Waiman Long <Waiman.Long@hpe.com> - 2016-03-18 20:50 +0100
[PATCH v6 1/4] lib/percpu-list: Per-cpu list with associated per-cpu locks Waiman Long <Waiman.Long@hpe.com> - 2016-03-18 20:50 +0100
Re: [PATCH v6 1/4] lib/percpu-list: Per-cpu list with associated per-cpu locks Jan Kara <jack@suse.cz> - 2016-03-21 10:50 +0100
Re: [PATCH v6 1/4] lib/percpu-list: Per-cpu list with associated per-cpu locks Waiman Long <waiman.long@hpe.com> - 2016-03-22 03:40 +0100
[PATCH v6 4/4] vfs: Use per-cpu list for superblock's inode list Waiman Long <Waiman.Long@hpe.com> - 2016-03-18 20:50 +0100
[PATCH v6 2/4] fsnotify: Simplify inode iteration on umount Waiman Long <Waiman.Long@hpe.com> - 2016-03-18 20:50 +0100
csiph-web