Received: by 10.213.65.68 with SMTP id h4csp363210imn; Tue, 13 Mar 2018 06:51:21 -0700 (PDT) X-Google-Smtp-Source: AG47ELtfrQuU7Nb+qtXyIss6Z1nhcrqBIaJiuKVqXB/97uBXp0NMykOvKrkrYpRh9x4JeX5DxZ3x X-Received: by 10.98.72.10 with SMTP id v10mr710850pfa.148.1520949081331; Tue, 13 Mar 2018 06:51:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520949081; cv=none; d=google.com; s=arc-20160816; b=Et2xNWRNy+ByW9PC/GLYYaE+z3a+bVBvWJbVcNihkTqCKCuegUmay6pIhS/VCQKU9G E6wxOf5D4l/P7nm+o43eR6ZCKM7lw9eSz0sKNj34e53fa3iGK0ojxfh/r0LJMjQP1TY0 HFO/hVqds+zmRQ6/IX17WJmXz94GGvS3rj4uB0a8h9NPokt0sRfvuiQ23oPHnMV9MgPo nTWElWMeQcwkBJ5kTizhrdq166CCtCf0bpHxFkdrncgMriiW0tlN9wWdRuommYvVdAUJ Nty+icuKblJ92WxG52AsjNtaPmmrk59defUq/nOm+YIOz371l0YN7eksSXaweNRYPyik nEzw== 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=f0mFIbZmdawc5WccDIk+eKJwMZ3Sl+TFjGUFpf23LaU=; b=qmh7JlPiRXGAYTEpxk83AO0zuQDEUlglPxI9dwI4g5DKlVoSEnSaWeaLNgg3iZwoD1 L9WPqg18loO0KxKNtf6YHMNLhd3B7O2YXesSBRxZNGgBVt5qo1fLKdfx24BW1/K46aQZ YglWb0ojNr17BqO3cRs0gGXja8HYoIeJc0Bc5pvgFPoBGLGru4r30XBbctNBKPcIN4BJ IhbG5PAjzIRslvrPjyrhA4jde1LcyrlahST3Q/HrkMDCQ0FTmOr5Ixeacn9+hq9s0+kW 3jDe0j7g74Us4pKNOY8tYYNnObvjzTkeFNLnmLndG9gM6K45Ksh9rLlulqbTaFtU2wF/ QJEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=l/Fhlg+d; 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 r26si121007pfi.378.2018.03.13.06.51.07; Tue, 13 Mar 2018 06:51:21 -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=l/Fhlg+d; 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 S1752658AbeCMN0r (ORCPT + 99 others); Tue, 13 Mar 2018 09:26:47 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:34962 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751764AbeCMN0n (ORCPT ); Tue, 13 Mar 2018 09:26:43 -0400 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=f0mFIbZmdawc5WccDIk+eKJwMZ3Sl+TFjGUFpf23LaU=; b=l/Fhlg+dQR6MUXMHCth69tkjD mlVL0JlzOwscUAY16xuvKTYSA0WkNaJlvmahVbyuCXrQnNRVIl9mnmHbvwE+mlmDeG1KkdSaAhnAv AcptVMfor9k2JbHKeo4RKo2iWWBxMtE4CJImWSGG3eSe10Kr48MQUD3TX2azJYzdWMniXy4sxaN3M p6nv3f4eXBKuet3FsndMQwo0Qa9/GinB1iqoaWkU0UOq0AFCDFwGvQtWBV7+jGwBPZyMheKSJV6Fi KPDiz9Zo3AGLzCWTh2VS3D+SOT1/3SL/OuYdEHo8AfuqMLBGSHqRnoUKz8de/BU8F94vgFEYYn7M1 diiU2m8zQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1evjwv-0004Yu-Ff; Tue, 13 Mar 2018 13:26:41 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Ryusuke Konishi , linux-nilfs@vger.kernel.org Subject: [PATCH v9 02/61] radix tree: Use GFP_ZONEMASK bits of gfp_t for flags Date: Tue, 13 Mar 2018 06:25:40 -0700 Message-Id: <20180313132639.17387-3-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180313132639.17387-1-willy@infradead.org> References: <20180313132639.17387-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 bits may be used for slab allocations, so we can use them as radix tree flags as long as we mask them off before passing them to the slab allocator. Move the IDR flag from the high bits to the GFP_ZONEMASK bits. Signed-off-by: Matthew Wilcox Acked-by: Jeff Layton --- 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 8e00138d593f..da9e10c827df 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 & ~GFP_ZONEMASK); } 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(ROOT_IS_IDR & ~GFP_ZONEMASK); 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 e3201ccf54c3..32159c08a52e 100644 --- a/tools/testing/radix-tree/linux/gfp.h +++ b/tools/testing/radix-tree/linux/gfp.h @@ -19,6 +19,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