From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de ([195.135.220.15]:59614 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751598AbdJINIk (ORCPT ); Mon, 9 Oct 2017 09:08:40 -0400 Date: Mon, 9 Oct 2017 06:08:27 -0700 From: Davidlohr Bueso To: Waiman Long 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 Subject: Re: [PATCH v7 5/6] lib/dlock-list: Enable faster lookup with hashing Message-ID: <20171009130827.GC5131@linux-80c1.suse> References: <1507229008-20569-1-git-send-email-longman@redhat.com> <1507229008-20569-6-git-send-email-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <1507229008-20569-6-git-send-email-longman@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, 05 Oct 2017, Waiman Long wrote: >Insertion and deletion is relatively cheap and mostly contention >free for dlock-list. Lookup, on the other hand, can be rather costly >because all the lists in a dlock-list will have to be iterated. > >Currently dlock-list insertion is based on the cpu that the task is >running on. So a given object can be inserted into any one of the >lists depending on what the current cpu is. > >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. Thanks, Davidlohr