From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751432AbdJENk6 convert rfc822-to-8bit (ORCPT ); Thu, 5 Oct 2017 09:40:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41906 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751310AbdJENk4 (ORCPT ); Thu, 5 Oct 2017 09:40:56 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A2380C04AC4E 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 v6 6/6] lib/dlock-list: Provide IRQ-safe APIs 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: <1507152007-28753-1-git-send-email-longman@redhat.com> <1507152007-28753-7-git-send-email-longman@redhat.com> <20171004224612.GF13815@linux-80c1.suse> From: Waiman Long Organization: Red Hat Message-ID: <03d94f25-5979-d0a4-97a8-5d07555b47da@redhat.com> Date: Thu, 5 Oct 2017 09:40:53 -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: <20171004224612.GF13815@linux-80c1.suse> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Content-Language: en-US X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 05 Oct 2017 13:40:56 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/04/2017 06:46 PM, Davidlohr Bueso wrote: > On Wed, 04 Oct 2017, Waiman Long wrote: > >> To enable the use of dlock-list in an interrupt handler, the following >> new APIs are provided for a irqsafe dlock-list: >> >> - void dlock_list_unlock_irqsafe(struct dlock_list_iter *) >> - void dlock_list_relock_irqsafe(struct dlock_list_iter *) >> - void dlock_list_add_irqsafe(struct dlock_list_node *, >> struct dlock_list_head *); >> - void dlock_lists_add_irqsafe(struct dlock_list_node *, >> struct dlock_list_heads *) >> - void dlock_lists_del_irqsafe(struct dlock_list_node *) >> >> New macros for irqsafe dlock-list: >> >> - dlist_for_each_entry_irqsafe(pos, iter, member) >> - dlist_for_each_entry_safe_irqsafe(pos, n, iter, member) > > Instead of adding more calls to the api, could we not just use the > irqsave/restore as part of the regular api? > > Thanks, > Davidlohr The irqsave/restore spinlock calls are more expensive in term of performance. I think the spin_lock_irqrestore() is especially bad in a VM as it probably causes a VMexit. So I try to avoid them unless it is absolutely necessary. Another alternative is to specify the dlock-list type at allocation time and use either regular spinlock calls or irqsave/restore calls accordingly. That will add a bit of overhead for users that don't need irq safety, but much less than using irqsave/restore for all. I was using that approach originally, but opt for the current solution for performance reason. I can revert back to my original approach and send out an updated patch. Cheers, Longman