Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759462Ab3EWUv6 (ORCPT ); Thu, 23 May 2013 16:51:58 -0400 Received: from g6t0185.atlanta.hp.com ([15.193.32.62]:47023 "EHLO g6t0185.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759397Ab3EWUvy (ORCPT ); Thu, 23 May 2013 16:51:54 -0400 Message-ID: <519E8163.8070402@hp.com> Date: Thu, 23 May 2013 16:51:47 -0400 From: Waiman Long User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130109 Thunderbird/10.0.12 MIME-Version: 1.0 To: remaper CC: Alexander Viro , Jeff Layton , Miklos Szeredi , Ian Kent , Sage Weil , Steve French , Trond Myklebust , Eric Paris , linux-fsdevel , linux-kernel , autofs , ceph-devel , linux-cifs , samba-technical , linux-nfs , "Chandramouleeswaran, Aswin" , "Norton, Scott J" , Andi Kleen , Dave Chinner Subject: Re: =?gb18030?Q?=BB=D8=B8=B4=A3=BA=5BPATCH_1/3_v3=5D_dcach?= =?gb18030?Q?e=3A_Don=27t_take_unnecessary_lock_in_d=5Fcount_?= =?gb18030?Q?update?= References: In-Reply-To: Content-Type: text/plain; charset=gb18030; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1122 Lines: 24 On 05/23/2013 05:09 AM, remaper wrote: > maybe you can use the atomic_dec_and_lock(&dentry->d_count,&dentry->d_lock) here, right ? > > ------------------ Origin ------------------ >> The current code takes the dentry's d_lock lock whenever the d_count >> reference count is being updated. In reality, nothing big really >> happens until d_count goes to 0 in dput(). So it is not necessary to >> take the lock if the reference count won't go to 0. Thank for the suggestion. First of all, the d_count field is not an atomic type. Changing it to atomic will require touching quite a large number of source files even though that change won't change the size of the dentry. Secondly, the function internally uses cmpxchg to do its work. There isn't any performance advantage of using it. I also need the count to go in both direction, not just going down. Regards, Longman -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/