Received: by 10.223.185.116 with SMTP id b49csp4152415wrg; Mon, 19 Feb 2018 12:06:50 -0800 (PST) X-Google-Smtp-Source: AH8x224aN+Gouena5uPGHxOpdEQwIlFYSZRYWmnCnfJt5lmhZ6YcWEN1/CMGFrlV6Cyu3/zx7Y4e X-Received: by 10.98.242.14 with SMTP id m14mr15520194pfh.230.1519070810339; Mon, 19 Feb 2018 12:06:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519070810; cv=none; d=google.com; s=arc-20160816; b=Y07lSr5JFuhupbWPP+zpMPzqpMgxXJTZ2cs0hlJlqKukIkPmbAARbO7NU8GS8NMcAM mQlDakpXTpXHc1J4flcN9Gh7FmE2KZuF2DyoWsETDkzj8FhReALFDGHi6yLWmw34F6Md IKHE6IHIEKxKJwBPIFQMlmScCX/RtppxTRvUE8qjBRb9c1qR+oEuz1feSrdwurRKKgFJ xs9z/9d+xJWH1Owdg2E9+6AruhDvEZ3myUkuA/QFk1YKA3HmZXC1cb1er7/O+jDFi3Xd dhOpppcorEiSo88Mr6FI9Nmh6Xv0LIj/ja63gpYuiMaCFloEQT9/Zd5xfO5OsW3+mukc a33g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=mB1ybkrL5hWXUfnrCurod5/g8/Rjz5bpfVx7rwy041I=; b=OmAG91sQzcrUiVc7uhQ/pt4z7/y2DDJ+WBpydGaWfSzgGwgSfCvJ1sCaHZricnUOMS qYOmvzqttcf76X/5oOiN/CGSJ9ftB7cMmdyZ9XyHF8BDevps+dPkPfofcANyQ/Un+sen tfL5URacbT7M6uQGVDfN5sEjulMh5WJ6/9Iafvex4QnymALphKolSOX1umzC/3ujL80W RCb9t7XblQNd8C6Ctl9kqpey9aqcGqJ6UI9oCApBW6APTxb6MKPSOEfB+AFSHLU+xjP1 xwvw0i1bZ1e57JvvY+k+dwlIxIkGss61kmv+qGhGtyvITWHZaheq98XD6bde7xkuEzdM 61ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=JRKKSw4l; 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 g31-v6si6334909pld.714.2018.02.19.12.06.36; Mon, 19 Feb 2018 12:06:50 -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=JRKKSw4l; 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 S932160AbeBSUFj (ORCPT + 99 others); Mon, 19 Feb 2018 15:05:39 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:44502 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753562AbeBSTqF (ORCPT ); Mon, 19 Feb 2018 14:46:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: 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=mB1ybkrL5hWXUfnrCurod5/g8/Rjz5bpfVx7rwy041I=; b=JRKKSw4laorlYzgBWqaEl01xN PcN7RaxwKDV04OJX13JONHdCz/7Nqr43DOG4QWdbhGKIF0R7M2biIK93RQLnGUQSc8ajW5AtQkUBd njb1RiGDXF3/gvT1VLg9E8LNUsTS6FU02FJgV4u6RtIlYLaK3t1UZBnmfJxTnLvHjOJupwMJOY0cF ugbmn4qjy3L58ocuNeRZAQxIvu0S+nVyaIbCILoAeVXmdH1U0jdZjjwbf0Joh9vWlCWC4ZmzPiwyp nLXARhy+W4AE6rUuntRwiF8Ta2BwEfknOQQWP4LP0525+dKzgDs3bxwFbuNW0MciH0+/2PZWfHYzg ISWxf5c4w==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1enrNz-0001jp-UI; Mon, 19 Feb 2018 19:46:03 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v7 02/61] radix tree: Use bottom four bits of gfp_t for flags Date: Mon, 19 Feb 2018 11:44:57 -0800 Message-Id: <20180219194556.6575-3-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180219194556.6575-1-willy@infradead.org> References: <20180219194556.6575-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox None of these four bits may be used for slab allocations, so we can use them for flags as long as we mask them off before passing them to the slab allocator. Move the IDR flag from the top bits to the bottom bits. Signed-off-by: Matthew Wilcox --- include/linux/idr.h | 3 ++- include/linux/radix-tree.h | 7 ++++--- lib/radix-tree.c | 3 ++- tools/testing/radix-tree/linux/gfp.h | 1 + 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/linux/idr.h b/include/linux/idr.h index 7d6a6313f0ab..913c335054f0 100644 --- a/include/linux/idr.h +++ b/include/linux/idr.h @@ -29,7 +29,8 @@ struct idr { #define IDR_FREE 0 /* Set the IDR flag and the IDR_FREE tag */ -#define IDR_RT_MARKER ((__force gfp_t)(3 << __GFP_BITS_SHIFT)) +#define IDR_RT_MARKER (ROOT_IS_IDR | (__force gfp_t) \ + (1 << (ROOT_TAG_SHIFT + IDR_FREE))) #define IDR_INIT_BASE(base) { \ .idr_rt = RADIX_TREE_INIT(IDR_RT_MARKER), \ diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h index fc55ff31eca7..6c4e2e716dac 100644 --- a/include/linux/radix-tree.h +++ b/include/linux/radix-tree.h @@ -104,9 +104,10 @@ struct radix_tree_node { unsigned long tags[RADIX_TREE_MAX_TAGS][RADIX_TREE_TAG_LONGS]; }; -/* The top bits of gfp_mask are used to store the root tags and the IDR flag */ -#define ROOT_IS_IDR ((__force gfp_t)(1 << __GFP_BITS_SHIFT)) -#define ROOT_TAG_SHIFT (__GFP_BITS_SHIFT + 1) +/* The IDR tag is stored in the low bits of the GFP flags */ +#define ROOT_IS_IDR ((__force gfp_t)4) +/* The top bits of gfp_mask are used to store the root tags */ +#define ROOT_TAG_SHIFT (__GFP_BITS_SHIFT) struct radix_tree_root { gfp_t gfp_mask; diff --git a/lib/radix-tree.c b/lib/radix-tree.c index 0a7ae3288a24..66732e2f9606 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c @@ -146,7 +146,7 @@ static unsigned int radix_tree_descend(const struct radix_tree_node *parent, static inline gfp_t root_gfp_mask(const struct radix_tree_root *root) { - return root->gfp_mask & __GFP_BITS_MASK; + return root->gfp_mask & ((__GFP_BITS_MASK >> 4) << 4); } static inline void tag_set(struct radix_tree_node *node, unsigned int tag, @@ -2285,6 +2285,7 @@ void __init radix_tree_init(void) int ret; BUILD_BUG_ON(RADIX_TREE_MAX_TAGS + __GFP_BITS_SHIFT > 32); + BUILD_BUG_ON(GFP_ZONEMASK != (__force gfp_t)15); radix_tree_node_cachep = kmem_cache_create("radix_tree_node", sizeof(struct radix_tree_node), 0, SLAB_PANIC | SLAB_RECLAIM_ACCOUNT, diff --git a/tools/testing/radix-tree/linux/gfp.h b/tools/testing/radix-tree/linux/gfp.h index e9fff59dfd8a..a72007d9818b 100644 --- a/tools/testing/radix-tree/linux/gfp.h +++ b/tools/testing/radix-tree/linux/gfp.h @@ -18,6 +18,7 @@ #define __GFP_RECLAIM (__GFP_DIRECT_RECLAIM|__GFP_KSWAPD_RECLAIM) +#define GFP_ZONEMASK 0x0fu #define GFP_ATOMIC (__GFP_HIGH|__GFP_ATOMIC|__GFP_KSWAPD_RECLAIM) #define GFP_KERNEL (__GFP_RECLAIM | __GFP_IO | __GFP_FS) #define GFP_NOWAIT (__GFP_KSWAPD_RECLAIM) -- 2.16.1