From mboxrd@z Thu Jan 1 00:00:00 1970 From: Trond Myklebust Subject: Re: [PATCH 5/6] IMA: use rbtree instead of radix tree for inode information cache Date: Wed, 20 Oct 2010 18:47:55 -0400 Message-ID: <1287614875.23812.7.camel@heimdal.trondhjem.org> References: <20101019225813.12396.2564.stgit@paris.rdu.redhat.com> <20101019225839.12396.92630.stgit@paris.rdu.redhat.com> <20101019231747.GC12506@dastard> <1287574269.3488.11.camel@twins> <20101020220557.GN32255@dastard> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Cc: Dave Chinner , Peter Zijlstra , Eric Paris , linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-fsdevel@vger.kernel.org, hch@infradead.org, zohar@us.ibm.com, warthog9@kernel.org, jmorris@namei.org, kyle@mcmartin.ca, hpa@zytor.com, akpm@linux-foundation.org, mingo@elte.hu, viro@zeniv.linux.org.uk To: Linus Torvalds Return-path: Received: from mx2.netapp.com ([216.240.18.37]:40479 "EHLO mx2.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752943Ab0JTWsP convert rfc822-to-8bit (ORCPT ); Wed, 20 Oct 2010 18:48:15 -0400 In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, 2010-10-20 at 15:22 -0700, Linus Torvalds wrote: > On Wed, Oct 20, 2010 at 3:05 PM, Dave Chinner wrote: > > > > /me wanders off to look at converting the xfs buffer cache rbtrees > > to RCU.... > > Look out for livelocks, though. And yes, they can happen. > > So rather than a loop, one option is to do basically > > rcu_read_lock(); > seq = read_seqbegin(); > > .. do lookup .. > > need_lock = read_seqretry(seq); > rcu_read_unlock(); > > if (need_lock) { > get_real_lock(); > > .. do lookup .. > > drop_real_lock(); > } > > which just falls back to a locked access if the rcu model doesn't work. > > Linus That is a really interesting alternative to traditional locking. Could we perhaps document it in Documentation/rbtree.txt? Cheers Trond