Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751506Ab3IPXFw (ORCPT ); Mon, 16 Sep 2013 19:05:52 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57735 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750953Ab3IPXFt (ORCPT ); Mon, 16 Sep 2013 19:05:49 -0400 Date: Mon, 16 Sep 2013 16:05:47 -0700 From: Andrew Morton To: Josef Bacik Cc: , , , Subject: Re: [PATCH] rwsem: add rwsem_is_contended Message-Id: <20130916160547.371b74f91511a42ac263449e@linux-foundation.org> In-Reply-To: <1377872041-390-1-git-send-email-jbacik@fusionio.com> References: <1377872041-390-1-git-send-email-jbacik@fusionio.com> X-Mailer: Sylpheed 3.2.0beta5 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1685 Lines: 35 On Fri, 30 Aug 2013 10:14:01 -0400 Josef Bacik wrote: > Btrfs uses an rwsem to control access to its extent tree. Threads will hold a > read lock on this rwsem while they scan the extent tree, and if need_resched() > they will drop the lock and schedule. The transaction commit needs to take a > write lock for this rwsem for a very short period to switch out the commit > roots. If there are a lot of threads doing this caching operation we can starve > out the committers which slows everybody out. To address this we want to add > this functionality to see if our rwsem has anybody waiting to take a write lock > so we can drop it and schedule for a bit to allow the commit to continue. > Thanks, > This sounds rather nasty and hacky. Rather then working around a locking shortcoming in a caller it would be better to fix/enhance the core locking code. What would such a change need to do? Presently rwsem waiters are fifo-queued, are they not? So the commit thread will eventually get that lock. Apparently that's not working adequately for you but I don't fully understand what it is about these dynamics which is causing observable problems. > I've cc'ed people who seemed like they may be in charge/familiar with this code, > hopefully I got the right people. > > include/linux/rwsem.h | 1 + > lib/rwsem.c | 17 +++++++++++++++++ This will break CONFIG_RWSEM_GENERIC_SPINLOCK=n? -- 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/