Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761974Ab3DBQf2 (ORCPT ); Tue, 2 Apr 2013 12:35:28 -0400 Received: from li9-11.members.linode.com ([67.18.176.11]:58442 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760786Ab3DBQf1 (ORCPT ); Tue, 2 Apr 2013 12:35:27 -0400 Date: Tue, 2 Apr 2013 12:35:14 -0400 From: "Theodore Ts'o" To: Kent Overstreet Cc: linux-kernel@vger.kernel.org, linux-aio@kvack.org, akpm@linux-foundation.org, Zach Brown , Felipe Balbi , Greg Kroah-Hartman , Mark Fasheh , Joel Becker , Rusty Russell , Jens Axboe , Asai Thambi S P , Selvan Mani , Sam Bradshaw , Jeff Moyer , Al Viro , Benjamin LaHaise Subject: Re: [PATCH 25/33] aio: use xchg() instead of completion_lock Message-ID: <20130402163514.GI31577@thunk.org> Mail-Followup-To: Theodore Ts'o , Kent Overstreet , linux-kernel@vger.kernel.org, linux-aio@kvack.org, akpm@linux-foundation.org, Zach Brown , Felipe Balbi , Greg Kroah-Hartman , Mark Fasheh , Joel Becker , Rusty Russell , Jens Axboe , Asai Thambi S P , Selvan Mani , Sam Bradshaw , Jeff Moyer , Al Viro , Benjamin LaHaise References: <1363883754-27966-1-git-send-email-koverstreet@google.com> <1363883754-27966-26-git-send-email-koverstreet@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1363883754-27966-26-git-send-email-koverstreet@google.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1169 Lines: 24 On Thu, Mar 21, 2013 at 09:35:46AM -0700, Kent Overstreet wrote: > So, for sticking kiocb completions on the kioctx ringbuffer, we need a > lock - it unfortunately can't be lockless. > > When the kioctx is shared between threads on different cpus and the rate > of completions is high, this lock sees quite a bit of contention - in > terms of cacheline contention it's the hottest thing in the aio subsystem. > > That means, with a regular spinlock, we're going to take a cache miss to > grab the lock, then another cache miss when we touch the data the lock > protects - if it's on the same cacheline as the lock, other cpus spinning > on the lock are going to be pulling it out from under us as we're using > it. > > So, we use an old trick to get rid of this second forced cache miss - make > the data the lock protects be the lock itself, so we grab them both at > once. Reviewed-by: "Theodore Ts'o" -- 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/