Received: by 10.213.65.68 with SMTP id h4csp580482imn; Fri, 16 Mar 2018 12:07:43 -0700 (PDT) X-Google-Smtp-Source: AG47ELvW+t8dofSfnow56I5gUbBRF1muXTHr7WytozQuXzmJWsxQKFrXUpbk0b64Lya7VLcr2wve X-Received: by 10.98.129.67 with SMTP id t64mr2474273pfd.137.1521227263142; Fri, 16 Mar 2018 12:07:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521227263; cv=none; d=google.com; s=arc-20160816; b=xf+UYQkHberu1lo49NrxntNUW1AZuGIiYeHOTu6BQo12eLcvdizqPtXzQbK4GsZsQS W1sfj+zRH3Pnyyp2LLZ9QIWPeswp+Ewcff6OJte0b2IDuoMP/cR9BM0tS0WGDnoeO8vM lUlk7bbHXXuPPZ9bTHi+JbzAZwJJc6t073fznoRHlZR74IgUkcCd4nH3wLKI7t5wHvWC 4Imu/q0VHviqvQykAf5UpqG0u0oy1OfHa6dj0Yz8hb+T6bSemMOzR+7UMcQeL/LuXkgl ySVNvnTfbpfLhHY3cLJFqiu8oCCHlCp0k1adsLFZ8I+H92X8NJqfgVAA2lDdILy5M+8u PMuA== 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:arc-authentication-results; bh=RA+CxjyVefq0tqAPZi6/eul5TLvIfvdFGHfK00ingsc=; b=XU15v3jaTh2a+EFESuYUKIOU56cA+XG4FrGZOqhE9oaEK+qJi8NUFzBpbsjrEYAtBe QEhKpAKJZzr1dYEWODwdx18oYTwAvTmJrDfAcYDyaC95iDLY8lUYDuYetq9Cy8Rbx2sa ii3abHP3Ueh/+midAdPHM5NPH03Ft6U2egeQWpbfr24PKwek/HnuwskB79z86V3DSodM itZvtkqo8qqj2FSpumaBsALCqxcEpqP7ayq6ZBy0bgmWec2ZaJFTaSWZAqReVrFRKMIh 6/cn9/9i0ioHODYcxB5OuNmJ8hIAdcTBs41NE6/OX//HYFi7GjiAHHROTeOsiYNTfFHD 3sSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=otooHYdR; 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 a6si5861347pfi.123.2018.03.16.12.07.28; Fri, 16 Mar 2018 12:07:43 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=otooHYdR; 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 S1752948AbeCPTGI (ORCPT + 99 others); Fri, 16 Mar 2018 15:06:08 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:54696 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751905AbeCPTGG (ORCPT ); Fri, 16 Mar 2018 15:06:06 -0400 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=RA+CxjyVefq0tqAPZi6/eul5TLvIfvdFGHfK00ingsc=; b=otooHYdRSb53Nf8Agg0p3Qv+j Q9OctsliD6EWky8KfB3aQgkjA4I6An8BZ5V1VWv3RmurK8ofnNSnxLoqwK49VEHRtdqOuGC7TlwfA pI0GN5LLpcN3b94p2JCFQIeb2W7LTCjxZcEerwKeI6stn9Ziw7JZQxUM3ecWwXUl/m6WykJx2vxs4 Oj/j0+fRlBMVBQguaQON78eWrQ6xsytITVowaRVHATp30ueEZ7uT1LxRozCNXvf6bwRo/qgroIhul 8NL7k6CSCABMryEIIBqugvLcfoUtI4s6DH8tnwyHjJ/H8pojQ/zEtRy05/jbgzv1mJxZermmgo6yP Ugx1ef4lQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1ewug0-00049T-Sd; Fri, 16 Mar 2018 19:06:04 +0000 Date: Fri, 16 Mar 2018 12:06:04 -0700 From: Matthew Wilcox To: Josef Bacik Cc: Andrew Morton , Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Ryusuke Konishi , linux-nilfs@vger.kernel.org Subject: Re: [PATCH v9 09/61] xarray: Replace exceptional entries Message-ID: <20180316190604.GF27498@bombadil.infradead.org> References: <20180313132639.17387-1-willy@infradead.org> <20180313132639.17387-10-willy@infradead.org> <20180316185349.c4ebbwuzlhihec5f@destiny> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180316185349.c4ebbwuzlhihec5f@destiny> 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 Fri, Mar 16, 2018 at 02:53:50PM -0400, Josef Bacik wrote: > On Tue, Mar 13, 2018 at 06:25:47AM -0700, Matthew Wilcox wrote: > > @@ -453,18 +449,14 @@ int ida_get_new_above(struct ida *ida, int start, int *id) > > new += bit; > > if (new < 0) > > return -ENOSPC; > > - if (ebit < BITS_PER_LONG) { > > - bitmap = (void *)((1UL << ebit) | > > - RADIX_TREE_EXCEPTIONAL_ENTRY); > > - radix_tree_iter_replace(root, &iter, slot, > > - bitmap); > > - *id = new; > > - return 0; > > + if (bit < BITS_PER_XA_VALUE) { > > + bitmap = xa_mk_value(1UL << bit); > > + } else { > > + bitmap = this_cpu_xchg(ida_bitmap, NULL); > > + if (!bitmap) > > + return -EAGAIN; > > + __set_bit(bit, bitmap->bitmap); > > } > > - bitmap = this_cpu_xchg(ida_bitmap, NULL); > > - if (!bitmap) > > - return -EAGAIN; > > - __set_bit(bit, bitmap->bitmap); > > radix_tree_iter_replace(root, &iter, slot, bitmap); > > } > > > > This threw me off a bit, but we do *id = new below. Yep. Fortunately, I have a test-suite for the IDA, so I'm relatively sure this works. > > @@ -495,9 +487,9 @@ void ida_remove(struct ida *ida, int id) > > goto err; > > > > bitmap = rcu_dereference_raw(*slot); > > - if (radix_tree_exception(bitmap)) { > > + if (xa_is_value(bitmap)) { > > btmp = (unsigned long *)slot; > > - offset += RADIX_TREE_EXCEPTIONAL_SHIFT; > > + offset += 1; /* Intimate knowledge of the xa_data encoding */ > > if (offset >= BITS_PER_LONG) > > goto err; > > } else { > > Ick. I know. I feel quite ashamed of this code. I do have a rewrite to use the XArray, but I didn't want to include it as part of *this* merge request. And that rewrite decodes the value into an unsigned long, sets the bit, reencodes it as an xa_value and stores it. > > @@ -393,11 +393,11 @@ void ida_check_conv(void) > > for (i = 0; i < 1000000; i++) { > > int err = ida_get_new(&ida, &id); > > if (err == -EAGAIN) { > > - assert((i % IDA_BITMAP_BITS) == (BITS_PER_LONG - 2)); > > + assert((i % IDA_BITMAP_BITS) == (BITS_PER_LONG - 1)); > > assert(ida_pre_get(&ida, GFP_KERNEL)); > > err = ida_get_new(&ida, &id); > > } else { > > - assert((i % IDA_BITMAP_BITS) != (BITS_PER_LONG - 2)); > > + assert((i % IDA_BITMAP_BITS) != (BITS_PER_LONG - 1)); > > Can we just use BITS_PER_XA_VALUE here? Yes! I'll change that. > Reviewed-by: Josef Bacik Thanks!