Received: by 10.192.165.148 with SMTP id m20csp3562496imm; Mon, 7 May 2018 14:36:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp+E5/+biGJ+6tz1gP7EFGeg+nTn2TZyJ5g0JdmeNdogqEjJNuLSbcWB46X1Y8kn9/oHSEg X-Received: by 2002:a65:6395:: with SMTP id h21-v6mr4363288pgv.267.1525728963371; Mon, 07 May 2018 14:36:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525728963; cv=none; d=google.com; s=arc-20160816; b=T0DP1r5BeixqOVxrtt3mj4EUBk3DZMrGDWuhjpLeK/2IhXyJ/8JSzO0ZsZXIflaQ2S r9hFul4Z3uhCKfYzTEXx+78E1XWt9KWBq8NiaH6qp9XUYvwGxw/yDUh6s6ZTk/7ruQp1 l58+EmfzSeBrkoExdM/noIVrEPJDhgb1TSp7tIcWJVOPnsh9s4O1seb+xMS2jytzBJ/v bIPjeoJ+U8XBHv+Qydztgm11jVt8Dao+gUQKF9E+7Dg9nMeKJCGIvhoYlUc3KjiyBZJy Fm53iF2IShz8n7iIBdvhMXVlX5RVLxynsXwbgKgbPh7SKdWjT6NP3AtchkhoZN+Hw6UI EKxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=C/KSbvl4t/0AsQ44MT6jaelL+3H+dmCuCiFX/9STRpw=; b=bc33IJ6eAlOrR29kUYfRa133HaFuNmwJsAzb7cB5T/9wXVSkYuRNelyB8KhaCDylnH 4+yztrS0bEWvXYnb//zuEzO+RVwGaERkqr4aRZhgukmuX6XYGy5n5XX19ltbTdQQ8ktN meAjYswq5sbHd7hJYqkYCbNiIweCdZdFnkjx8csjUyliItFzYPp/SwU49j+77nVQrCKq cLEf55hON0sfkuSz767bB9Q7SV7h3Nkj0A/rVxswlNjpwtIgTNA0E0fiXM+6GBLVqBvX Kh4UnwhzRRp4d9DPIx1oyGJiX19UerzclFO8JuBAciNJwv1Dff1pUwLmUNkx/JVjjq5d 0XHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=C9qXmZcx; 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 e1-v6si22421490ple.428.2018.05.07.14.35.49; Mon, 07 May 2018 14:36:03 -0700 (PDT) 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=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=C9qXmZcx; 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 S1753090AbeEGVen (ORCPT + 99 others); Mon, 7 May 2018 17:34:43 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:35313 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752721AbeEGVel (ORCPT ); Mon, 7 May 2018 17:34:41 -0400 Received: by mail-it0-f68.google.com with SMTP id q72-v6so3656637itc.0 for ; Mon, 07 May 2018 14:34:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=C/KSbvl4t/0AsQ44MT6jaelL+3H+dmCuCiFX/9STRpw=; b=C9qXmZcx1pqPTr83PJdpNXRLyDkHF4CZgPRZAtRsDPXJJvWtlmff5YVWu+yn5wCZDJ E+XaHzzP0XIv+YGHUVl4ma2B7chHth71JjE0AILDo6zfprctzu5dbQt3sYLJgltxkuvh Q0fSiuR/iOKoqPfEUHu99aArFI310GhFLLH9yxe1lLDMNcW8qTwHsMQBQzCSjdknhnoS JD/Mi5CwulXekV9eW++maBpXRd6mM6am4IyzhdPd4XkQwT44HjpINa+j5EQOqMuVTW0q 7/ZrgZAtj/PaZL8ltaN+LwJ/9I4viz/yxYm60KTnPAfXV6RGXPTRp6N2mrWSrS9CJ5Xb 251Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=C/KSbvl4t/0AsQ44MT6jaelL+3H+dmCuCiFX/9STRpw=; b=IaM1kcGjDyMzFAHejAhg8bTy4Sb0r4JcxI8zRrUVduxU/7JIOkVBW7xKhwECz5NSV+ aTDBAFgnlu5BduZ3M5CYgLh2P48ZnchBqBPic7vBbLJk+pxyS5SaicgGb+hEnIXic2Hn UH1SMz7/tgTGbDpZ292v+CkFsYJkFXV4ZEMPez8AaSZnxv8QIW0ydBs1gUCSoZE4O8X+ NUGHsPG5XE49jO117+g8ZNTOndpL+C1Fby43OqAG/VeXJAHZpIBJ0n5Olog8P9xKFar7 1l18s/vdVYrNxhakkwxceHhpW0hnJ8PsBHydkwXooSHdyQxasWdu9sSblFBdeNqlVS8Q 5FxA== X-Gm-Message-State: ALKqPwdVdOSdVwHVJ+/KtVK5Mi7XEQuXbOFUS53BUPVQCTBCtaUQfBeo S5ZD53oqyJXO/mEUx76QhBVf9g== X-Received: by 2002:a24:74d2:: with SMTP id o201-v6mr3638956itc.151.1525728880991; Mon, 07 May 2018 14:34:40 -0700 (PDT) Received: from [192.168.1.167] ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id o137-v6sm10348712ioe.3.2018.05.07.14.34.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 May 2018 14:34:38 -0700 (PDT) Subject: Re: [PATCH] percpu_ida: Use _irqsave() instead of local_irq_save() + spin_lock To: Matthew Wilcox Cc: Andrew Morton , Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org, tglx@linutronix.de, Nicholas Bellinger , Shaohua Li , Kent Overstreet References: <20180504153218.7301-1-bigeasy@linutronix.de> <20180504162216.ae91654b68eddafe38df7d7f@linux-foundation.org> <20180505035154.GB20495@bombadil.infradead.org> <60a88d5f-95eb-ba45-e59c-5a822a3d370b@kernel.dk> <20180505155202.GA29992@bombadil.infradead.org> <20180507134731.GA28974@bombadil.infradead.org> From: Jens Axboe Message-ID: Date: Mon, 7 May 2018 15:34:37 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20180507134731.GA28974@bombadil.infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/7/18 7:47 AM, Matthew Wilcox wrote: > On Sat, May 05, 2018 at 08:52:02AM -0700, Matthew Wilcox wrote: >> init and destroy seem to map to sbitmap_queue_init_node and >> sbitmap_queue_free. percpu_ida_free maps to sbitmap_queue_clear. > > Hmm. > > void sbitmap_queue_clear(struct sbitmap_queue *sbq, unsigned int nr, > unsigned int cpu) > { > sbitmap_clear_bit_unlock(&sbq->sb, nr); > sbq_wake_up(sbq); > if (likely(!sbq->round_robin && nr < sbq->sb.depth)) > *per_cpu_ptr(sbq->alloc_hint, cpu) = nr; > } > EXPORT_SYMBOL_GPL(sbitmap_queue_clear); > > If we free a tag on a CPU other than the one it's allocated on, that seems > like it's going to guarantee a cacheline pingpong. Is the alloc_hint > really that valuable? I'd be tempted to maintain the alloc_hint (if it's > at all valuable) as being just a hint for which word to look at first, > and only update it on allocation, rather than updating it on free. The point is to update it on free, so we know where to start the search. Ideally it'd still be free. Keep in mind that some of this was driven by blk-mq developments, on how to retain fast allocations without adding per-cpu caches (which we can't afford, see previous rant on tag space utilization). On blk-mq, the free is generally on the CPU you allocated, or close to in terms of caching. Even for shared tag cases, I haven't seen any bad behavior from bouncing. Doesn't mean that we could not, but I'd be wary of changing any of it without substantial performance testing. > Then we can drop the 'cpu' argument to sbitmap_queue_clear(), which > would help this conversion because the percpu_ida users don't know what > CPU their tag was allocated on. What you want is something around the sbitmap_queue_{get,clear} that wraps the alloc hint and wait queue mechanism, so the caller doesn't have to deal with it. We don't have that, since the blk-mq mechanism works out better just implementing it. We have things like queue runs that are don't for the failure case. -- Jens Axboe