Received: by 10.213.65.68 with SMTP id h4csp573199imn; Fri, 16 Mar 2018 11:55:31 -0700 (PDT) X-Google-Smtp-Source: AG47ELvR09xkf2xuHkhKZeqd9nQBSQhkQGvcqy5X7t4jXpLVvdAC/1awXDdb444aeqS8l+WCd6fT X-Received: by 10.99.8.4 with SMTP id 4mr2254924pgi.289.1521226531084; Fri, 16 Mar 2018 11:55:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521226531; cv=none; d=google.com; s=arc-20160816; b=LDf1ZuMtPFExGNmRXRIgb0+01r8lnlpZfUepMmjho7/+oQB9myeePeDlDc88h87ize zK0vKj0jR75GzYj5deK0jOi6kDYSnQhS3c1gSxvVkq7JHIRdo4uDhh1/tZdrAdxGnOa2 J+r1+GCbQ1X9iHvI2cqiP/S7eCqVXt70QvpVpsvPBnhUsKPkJ/YegZeSqFSbUxGTv/0i ji2QRLl5CJ//g8sp2gvsHxMvY0DE6TZxVVZ+OPEGbSq6RbblL0WPGvPjKbCNWelIe1ha gPKAIZQAjJNH5GI3xwiIUmB4cP40GNW4bMYBIITcs5cRYXEPqvps59rFwoT59nIQ8hkE 3E1A== 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=CzyD/OYuGRsIGNGBIqvEmvM8o6pjsHHUujjOgnQiJjo=; b=eyF7Vc42O58IdBZxymhbBqQGIUMZyty3PgGqoqie6izqCguLiq8pYLh1L9aDdRCfH9 80Sh+O73MAd8tdKPEgsnle1vb3bIOd7sjqQRSs5RUlLxEfoosGgjwhgW1B2gT3igNfTu xCmGxcg487JgGeisfes3bRQ7SrejC8y3s469B5JAjt/MnRzUVbFzhut/ms6i5A3setJw t7/XhKLvULIqDxPIu0vbZvI6Ulrj0TZvD5nJmwj1L34sauAuXMac73fC484rLoTMjHIk BE6YrJRvaFrT8Ec8rs79S0WJH36DHSlg3vbtRWEVc/26Q6r44DxyaOi1iv8vo77md0GP 2QIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=TEzPTPwx; 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 w22-v6si6580318plq.196.2018.03.16.11.55.13; Fri, 16 Mar 2018 11:55:31 -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=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=TEzPTPwx; 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 S1752266AbeCPSxz (ORCPT + 99 others); Fri, 16 Mar 2018 14:53:55 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:41620 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751729AbeCPSxx (ORCPT ); Fri, 16 Mar 2018 14:53:53 -0400 Received: by mail-qk0-f196.google.com with SMTP id s78so12097061qkl.8 for ; Fri, 16 Mar 2018 11:53:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=CzyD/OYuGRsIGNGBIqvEmvM8o6pjsHHUujjOgnQiJjo=; b=TEzPTPwxVnth8p267AmsTS0Ac4aMkF8k95MhvCWCqQILj81IdGLqFivnUKllUrpp8w +AKghg07cgnPWQzfXu5PHY9oeMrnc2ZUpbSeKumFwQihNItUeHsgw/1Y/MfgDgznOjxP f/0KqdqTzxYQjs5tvVG9zzFPZcWd4Wwh6XGbzMYlrID9vTQxsZEA+6Rdsvr2PWj0GbeX cWQeCKR9pKq9dnJR/Abxz72GlTFT/8yHhsyxEeJDFLjPNwbSQAV0+FLtsh6Zsvuipz3Q nYceEmWJlq2dW+3wmtL28fa6F39OIcFXuuVZhb75dsAZA4FHfYimB0SQTlTowIn9RhHA i21Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=CzyD/OYuGRsIGNGBIqvEmvM8o6pjsHHUujjOgnQiJjo=; b=gAhAQoHkJjbOKhmBRM1kQR6luxrtmJAL/63mGp3vojqoErXPML1udY01iNoP2YgREi C4bmr1N4fVk0/j9iso86QyDjRhrG55gFEZNsh9omRRygcxmwdB7Q2J+4OfYdqq8mXO8y QgSYBWwcHwq7tTUbquriihrxNk7RyADpRvO/T8lIpx6dz9ZuZIwOZ6k3ujmXf3z/DqdS ETL+vrYRBlgMefrKVj9GdjsiCCby6lR4KrPDOdbytngd+d3X2xnTzBw6YTD0RMXvm1Q2 ejC6VCi1BujRbMlFn3VBfKIavjKTcfpoRqb8Tf2tLAn07S8b0xSmuQtF+rFZCTBrPrCj 79YQ== X-Gm-Message-State: AElRT7EGjmCgCF4FDEry+S85jtqGDLPtjlPoEVnAtbePwN5YI/qjFFRs iu1b89QHnk8+zoKDpCJwLMX6Ob07I4E= X-Received: by 10.55.134.135 with SMTP id i129mr4032151qkd.177.1521226432224; Fri, 16 Mar 2018 11:53:52 -0700 (PDT) Received: from localhost (cpe-2606-A000-4381-1201-225-22FF-FEB3-E51A.dyn6.twc.com. [2606:a000:4381:1201:225:22ff:feb3:e51a]) by smtp.gmail.com with ESMTPSA id k5sm6026877qte.18.2018.03.16.11.53.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 16 Mar 2018 11:53:51 -0700 (PDT) Date: Fri, 16 Mar 2018 14:53:50 -0400 From: Josef Bacik To: Matthew Wilcox 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: <20180316185349.c4ebbwuzlhihec5f@destiny> References: <20180313132639.17387-1-willy@infradead.org> <20180313132639.17387-10-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180313132639.17387-10-willy@infradead.org> User-Agent: NeoMutt/20170714 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 13, 2018 at 06:25:47AM -0700, Matthew Wilcox wrote: > From: Matthew Wilcox > > Introduce xarray value entries to replace the radix tree exceptional > entry code. This is a slight change in encoding to allow the use of an > extra bit (we can now store BITS_PER_LONG - 1 bits in a value entry). > It is also a change in emphasis; exceptional entries are intimidating > and different. As the comment explains, you can choose to store values > or pointers in the xarray and they are both first-class citizens. > > Signed-off-by: Matthew Wilcox > --- > arch/powerpc/include/asm/book3s/64/pgtable.h | 4 +- > arch/powerpc/include/asm/nohash/64/pgtable.h | 4 +- > drivers/gpu/drm/i915/i915_gem.c | 17 ++-- > drivers/staging/lustre/lustre/mdc/mdc_request.c | 2 +- > fs/btrfs/compression.c | 2 +- > fs/dax.c | 107 ++++++++++++------------ > fs/proc/task_mmu.c | 2 +- > include/linux/radix-tree.h | 36 ++------ > include/linux/swapops.h | 19 ++--- > include/linux/xarray.h | 54 ++++++++++++ > lib/idr.c | 61 ++++++-------- > lib/radix-tree.c | 21 ++--- > mm/filemap.c | 10 +-- > mm/khugepaged.c | 2 +- > mm/madvise.c | 2 +- > mm/memcontrol.c | 2 +- > mm/mincore.c | 2 +- > mm/readahead.c | 2 +- > mm/shmem.c | 10 +-- > mm/swap.c | 2 +- > mm/truncate.c | 12 +-- > mm/workingset.c | 12 ++- > tools/testing/radix-tree/idr-test.c | 6 +- > tools/testing/radix-tree/linux/radix-tree.h | 1 + > tools/testing/radix-tree/multiorder.c | 47 +++++------ > tools/testing/radix-tree/test.c | 2 +- > 26 files changed, 223 insertions(+), 218 deletions(-) > > > @@ -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. > @@ -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. > @@ -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? Overall looks fine to me, I'm not married to changing any of the nits. Reviewed-by: Josef Bacik Thanks, Josef