Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp996467imu; Tue, 11 Dec 2018 10:53:00 -0800 (PST) X-Google-Smtp-Source: AFSGD/Um5OywrZNAjDfEE4q7fT/7/mpfcu168m7iguUPiGQFWyF9US5DniEDioMEM9WjX3kgPY0y X-Received: by 2002:a62:a209:: with SMTP id m9mr17721066pff.218.1544554380222; Tue, 11 Dec 2018 10:53:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544554380; cv=none; d=google.com; s=arc-20160816; b=kX80gNpLr2sYkxhlvc4kG8nzCfD5wgIM+u9Diqt2LWp4reNkW71UPzsmO07NHisqZQ GnFLILjJw6n8yaScR+Tm/jpsxLY9TQDqP6tq4qpx1Y+6GMryJKQHpWGC25to4Kf4qRSt WYj38JrTBLQ7Rdq9LNeNEJavu8arzFKApJV9gvB3CEm6Qe+D/dreQjdmqT7/ZB/8av9o DSskaYdpAiGHb8BkWCY9fP+BW7xrxx7LQVKNRWhjz8cZVHWmtSCW91co/eqnkQ8F6BSw F5rJFw8YivGzMFBCHWeGnQmZTBMhzVna9GTN6YXL+E2pZGiqgSko/jsqFbBEyDXfd24s Lh7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=eV2mEzIcygscaGeKJNUPFqHJIQ+n0eYuHekdmYP67r4=; b=mMYlWQn0xLsDTsN8ktvoO0LzXOT3JMyxIzGJASz0e4zVP2Sd6KpNZ2hHbp36Obi5q6 jrdB2r1bSeNSN4pqSD7aO8By2jp/NUFTuSgtFUbpzCWN5qycMKJ19sPi0c4aS7/BpSDY AAc11D5i4wJoXPyk6IKO+9DODAaHOhSUXzAxEmrqmxcTj5De256R4WyL0Z1i2+Dm82TQ 6rz1gew29EtBdlybJA3SwMfBscvSDx9VeNmnp0hJ9lRg60WEjYi+qTfBPKTlygwbwUtH XWQq/8IyRc39BgforUpbdX3McAEiYyigJnstv1EwTMWG1c7d/5Px53o+GqprIE+0WgMz hpzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="A2/8aka3"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 62si12599764pgb.298.2018.12.11.10.52.45; Tue, 11 Dec 2018 10:53:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="A2/8aka3"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726536AbeLKSvJ (ORCPT + 99 others); Tue, 11 Dec 2018 13:51:09 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:38512 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726329AbeLKSvI (ORCPT ); Tue, 11 Dec 2018 13:51:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=eV2mEzIcygscaGeKJNUPFqHJIQ+n0eYuHekdmYP67r4=; b=A2/8aka3Htk0p1oGKl3IOOueQ P1Lkx+2fmncbv/Pe3nePx4h6Phbj5bLnG0yrmrDanCmJMjUScO3HzZ9Fc5RCCjV2KzE/AnJDKp0TZ +2a8+8V6NVdLwDpsIEBAOep99MFWu+8Aoh4aGw9hVpM9Kn7fcROCerx63izJ2xBriCvcsEB/5FZhv jSYKsDFSmPtk2nNaZ8/LQsehR+TH6WhvWJ3iPu5niyZDlMS70bI+g1mi4iYjxE3UocHjpUA2ebCSV pT/VsDf5ZUFf1V+isOtp2Mx//+hMI+Wx7ZThUbo2PKsviMqAEs5pw3Rk0GxT/UbJ4vZpiVloT9/hw t5GdcvgCA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWn7Z-0000oV-W8; Tue, 11 Dec 2018 18:51:05 +0000 Date: Tue, 11 Dec 2018 10:51:05 -0800 From: Matthew Wilcox To: Jens Axboe Cc: Jeff Moyer , Alexander Viro , Benjamin LaHaise , Andrew Morton , Kees Cook , linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dan Carpenter , kent.overstreet@gmail.com Subject: Re: [PATCH] aio: Convert ioctx_table to XArray Message-ID: <20181211185105.GI6830@bombadil.infradead.org> References: <20181128183531.5139-1-willy@infradead.org> <20181211175156.GF6830@bombadil.infradead.org> <0f77a532-0d88-78bc-b9cc-06bb203a0405@kernel.dk> <6b9a45c4-47a2-4c44-aa7e-6e5e90eff9df@kernel.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6b9a45c4-47a2-4c44-aa7e-6e5e90eff9df@kernel.dk> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 11, 2018 at 11:32:54AM -0700, Jens Axboe wrote: > Don't see any regressions. But if we're fiddling with it anyway, can't > we do something smarter? Make the fast path just index a table, and put > all the big hammers in setup/destroy. We're spending a non-substantial > amount of time doing lookups, that's really no different before and > after the patch. Thanks for checking it out. I think the fast path does just index a table. Until you have more than 64 pointers in the XArray, it's just xa->head->slots[i]. And then up to 4096 pointers, it's xa->head->slots[i >> 6]->slots[i]. It has the advantage that if you only have one kioctx (which is surely many programs using AIO), it's just xa->head, so even better than a table lookup. It'll start to deteriorate after 4096 kioctxs, with one extra indirection for every 6 bits, but by that point, we'd've been straining the memory allocator to allocate a large table anyway.