From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-bn3nam01on0100.outbound.protection.outlook.com ([104.47.33.100]:6816 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754409AbcGTWDG (ORCPT ); Wed, 20 Jul 2016 18:03:06 -0400 Message-ID: <578FF50E.8030503@hpe.com> Date: Wed, 20 Jul 2016 18:02:54 -0400 From: Waiman Long MIME-Version: 1.0 To: Tejun Heo CC: Alexander Viro , Jan Kara , Jeff Layton , "J. Bruce Fields" , Christoph Lameter , , , Ingo Molnar , Peter Zijlstra , Andi Kleen , Dave Chinner , Boqun Feng , Scott J Norton , Douglas Hatch Subject: Re: [PATCH v3 1/4] lib/dlock-list: Distributed and lock-protected lists References: <1468604383-40362-1-git-send-email-Waiman.Long@hpe.com> <1468604383-40362-2-git-send-email-Waiman.Long@hpe.com> <20160718233803.GN3078@mtj.duckdns.org> <578E7497.30602@hpe.com> <20160719192333.GP3078@mtj.duckdns.org> In-Reply-To: <20160719192333.GP3078@mtj.duckdns.org> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 07/19/2016 03:23 PM, Tejun Heo wrote: > Hello, > > On Tue, Jul 19, 2016 at 02:42:31PM -0400, Waiman Long wrote: >>>> +int alloc_dlock_list_head(struct dlock_list_head *dlist) >>>> +{ >>>> + struct dlock_list_head dlist_tmp; >>>> + int cpu; >>>> + >>>> + dlist_tmp.head = alloc_percpu(struct dlock_list_head_percpu); >>>> + if (!dlist_tmp.head) >>>> + return -ENOMEM; >>>> + >>>> + for_each_possible_cpu(cpu) { >>>> + struct dlock_list_head_percpu *head; >>>> + >>>> + head = per_cpu_ptr(dlist_tmp.head, cpu); >>>> + INIT_LIST_HEAD(&head->list); >>>> + head->lock = __SPIN_LOCK_UNLOCKED(&head->lock); >>>> + lockdep_set_class(&head->lock,&dlock_list_key); >>>> + } >>>> + >>>> + dlist->head = dlist_tmp.head; >>> Just use dlist->head directly or use local __perpcu head pointer? >> I just don't want to expose the structure to world until it is fully >> initialized. If you think I am over-cautious, I can use dlist->head as >> suggested. > I don't think it makes any actual difference. No strong opinion > either way. Just use local __percpu head pointer then? I have run sparse on dlock_list.c. There is no need to use the __percpu tag here. The head gets assigned the result of per_cpu_ptr() which has no __percpu annotation. I actually got sparse warning if I used the __percpu tag. Cheers, Longman