From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755261AbdJIQLM (ORCPT ); Mon, 9 Oct 2017 12:11:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37942 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754068AbdJIQLJ (ORCPT ); Mon, 9 Oct 2017 12:11:09 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6FCC5C04AC68 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=longman@redhat.com Subject: Re: [PATCH v7 5/6] lib/dlock-list: Enable faster lookup with hashing To: Davidlohr Bueso Cc: Alexander Viro , Jan Kara , Jeff Layton , "J. Bruce Fields" , Tejun Heo , Christoph Lameter , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Andi Kleen , Dave Chinner , Boqun Feng References: <1507229008-20569-1-git-send-email-longman@redhat.com> <1507229008-20569-6-git-send-email-longman@redhat.com> <20171009130827.GC5131@linux-80c1.suse> <95cbbab7-246d-fd42-23e3-19aa5bd8efe5@redhat.com> <20171009160304.GD5131@linux-80c1.suse> From: Waiman Long Organization: Red Hat Message-ID: <477de746-e0b9-1313-c92a-59e87292bfac@redhat.com> Date: Mon, 9 Oct 2017 12:11:07 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <20171009160304.GD5131@linux-80c1.suse> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 09 Oct 2017 16:11:09 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/09/2017 12:03 PM, Davidlohr Bueso wrote: > On Mon, 09 Oct 2017, Waiman Long wrote: > >> On 10/09/2017 09:08 AM, Davidlohr Bueso wrote: >>> On Thu, 05 Oct 2017, Waiman Long wrote: >>> >>>> This patch provides an alternative way of list selection. The caller >>>> can provide a object context which will be hashed to one of the list >>>> in a dlock-list. The object can then be added into that particular >>>> list. Lookup can be done by iterating elements in the provided list >>>> only instead of all the lists in a dlock-list. >>> >>> Unless I'm misusing the api, I could not find a standard way of >>> iterating a _particular_ list head (the one the dlock_list_hash() >>> returned). This is because iterators always want the all the heads. >>> >>> Also, in my particular epoll case I'd need the head->lock _not_ to >>> be dropped after the iteration, and therefore is pretty adhoc. >>> Currently we do: >>> >>> dlist_for_each_entry() { >>> // acquire head->lock for each list >>> } >>> // no locks held >>> dlist_add() >>> >>> I'm thinking perhaps we could have dlist_check_add() which passes a >>> callback to ensure we want to add the node. The function could acquire >>> the head->lock and not release it until the very end. >> >> With the dlock_list_hash(), dlock-list is degenerated into a pool of >> list where one is chosen by hashing. So the regular list iteration >> macros like list_for_each_entry() can then be used. Of course, you have >> to explicitly do the lock and unlock operation. > > Right, which seemed rather asymmetric and fragile, albeit adhoc to epoll. > Particularly not having the iter structure, makes use directly have to > deal with the spinlock, and there goes irq awareness out the window. > Right. We don't need the irq safety support in this case. >> I could also encapsulate it a bit with inlined function like > > Probably not worth it, unless some other use cases came up. This just > bulks the api even more. I am thinking of adding only one more init API. So it is not a significant bulking-up at all. Cheers, Longman