Received: by 10.223.164.202 with SMTP id h10csp664732wrb; Wed, 22 Nov 2017 13:18:42 -0800 (PST) X-Google-Smtp-Source: AGs4zMa6AYdcZRHsglsUy2KJ5zf7I/knyvPxy6JzrAsHKDjVZdYGcLMv1IGlAummTl3ANHT9p1N1 X-Received: by 10.84.241.15 with SMTP id a15mr23305937pll.103.1511385522711; Wed, 22 Nov 2017 13:18:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511385522; cv=none; d=google.com; s=arc-20160816; b=H00M2t14fHRc+V5nOa2074lr5dD35oEUZEKyan3WlmOHan3n19yhKpIJJrgnTq6XPZ a4V+FsWg8jwXdMqa2xF0CB6NcTyL8WzcrX+9jDfS9dNTBAaGkO4xRYet5/rNdqSYBJdg dSctCadvYjm25fLZW3N7frq3MNTyxXecxgzSUzMyuv25wLoizq4glmfZVYg8XFmn2rgH l/osMV7uracisGUDIMCsx7/XSgTUeUWk9HBV8xt+LVXtRv0gL7K/7JMGJAzDiAxHb+Hs b38VbjdaQe2bYS5OqqehWdUAREREe9ZNOuuMifeqd+wMvMieJj4c0n/rxYMOKyZDFxcY 92Xg== 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=FZQid2e6K+YJi6PiaEaoctcRomQYuJ1bbQbmMEIFZpM=; b=zvy6PyeaJ7DmpJe++WzITS1C1jRFBmRgJgeSPJSHyDIs1+E67400OOb5jUok8AJ1pF VdHr0DdCEXyflbA6yUTlsQjlgxJsbrKUZjBL2+NmDXOqXKowQIARmmI2dd5mmF8ZOF64 YNJThUTZULIbvLMr2GdO9TdSnZMpOWrcj8FoVvd6Bsryf+4AYuUnPRmHqqHujpcCihaY W+gO8mJjU53v5qbuLEeaUE8FmQcedtw0P1zyT87kn+9wejdDusn+o+LrGe7CWqGxWjnX bf2XxCKBFeLxoV+dzTr15h4KvdvfeH7Ttfy+qF6BXnYtREM0NxfjrjMjEdvgL3XuIaXU AgZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=bILKfcui; 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 y5si15878860pfd.245.2017.11.22.13.18.31; Wed, 22 Nov 2017 13:18:42 -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=bILKfcui; 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 S1752068AbdKVVOY (ORCPT + 77 others); Wed, 22 Nov 2017 16:14:24 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:60142 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751841AbdKVVIT (ORCPT ); Wed, 22 Nov 2017 16:08:19 -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=FZQid2e6K+YJi6PiaEaoctcRomQYuJ1bbQbmMEIFZpM=; b=bILKfcuiVi00qZDd1aYqC19of zJQXX4eLPPj3vZI81kne7H9CRXHl2RAfR6gJJaoXyH/FlrzeTOFYJW8r6TTR/Kz++0lXEyQP8O2Jl OGtzS+YbsLrXOLM9jz3mFMNrkqC5gGg1fna2ntV1bl0qNCM0jxPqmuTwIzewcdw+3T8u1RvkthFtV vjJLOOvmxcr4U0XcgfSvknWQ4+2Rjn9BGWpEHz8oIrRsvYb+br6DE+sDV9ihP59nbPcDebDvcY837 4rYQ9Wtc1Fu5gdTGouycMK40E4CBiA2vcCjqY7PSDHS4sGUlP+gt6Ow0gJOQkHs+C6PyD1iqe60n3 TLovAaY7Q==; Received: from willy by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1eHcFn-0007wl-2m; Wed, 22 Nov 2017 21:08:19 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox Subject: [PATCH 42/62] vmalloc: Convert to xarray Date: Wed, 22 Nov 2017 13:07:19 -0800 Message-Id: <20171122210739.29916-43-willy@infradead.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171122210739.29916-1-willy@infradead.org> References: <20171122210739.29916-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 The radix tree of vmap blocks is simpler to express as an XArray. Saves a couple of hundred bytes of text and eliminates a user of the radix tree preload API. Signed-off-by: Matthew Wilcox --- mm/vmalloc.c | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 673942094328..cc5de1ee6520 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -821,12 +821,11 @@ struct vmap_block { static DEFINE_PER_CPU(struct vmap_block_queue, vmap_block_queue); /* - * Radix tree of vmap blocks, indexed by address, to quickly find a vmap block + * XArray of vmap blocks, indexed by address, to quickly find a vmap block * in the free path. Could get rid of this if we change the API to return a * "cookie" from alloc, to be passed to free. But no big deal yet. */ -static DEFINE_SPINLOCK(vmap_block_tree_lock); -static RADIX_TREE(vmap_block_tree, GFP_ATOMIC); +static DEFINE_XARRAY(vmap_block_tree); /* * We should probably have a fallback mechanism to allocate virtual memory @@ -865,8 +864,8 @@ static void *new_vmap_block(unsigned int order, gfp_t gfp_mask) struct vmap_block *vb; struct vmap_area *va; unsigned long vb_idx; - int node, err; - void *vaddr; + int node; + void *ret, *vaddr; node = numa_node_id(); @@ -883,13 +882,6 @@ static void *new_vmap_block(unsigned int order, gfp_t gfp_mask) return ERR_CAST(va); } - err = radix_tree_preload(gfp_mask); - if (unlikely(err)) { - kfree(vb); - free_vmap_area(va); - return ERR_PTR(err); - } - vaddr = vmap_block_vaddr(va->va_start, 0); spin_lock_init(&vb->lock); vb->va = va; @@ -902,11 +894,12 @@ static void *new_vmap_block(unsigned int order, gfp_t gfp_mask) INIT_LIST_HEAD(&vb->free_list); vb_idx = addr_to_vb_idx(va->va_start); - spin_lock(&vmap_block_tree_lock); - err = radix_tree_insert(&vmap_block_tree, vb_idx, vb); - spin_unlock(&vmap_block_tree_lock); - BUG_ON(err); - radix_tree_preload_end(); + ret = xa_store(&vmap_block_tree, vb_idx, vb, gfp_mask); + if (IS_ERR(ret)) { + kfree(vb); + free_vmap_area(va); + return ret; + } vbq = &get_cpu_var(vmap_block_queue); spin_lock(&vbq->lock); @@ -923,9 +916,7 @@ static void free_vmap_block(struct vmap_block *vb) unsigned long vb_idx; vb_idx = addr_to_vb_idx(vb->va->va_start); - spin_lock(&vmap_block_tree_lock); - tmp = radix_tree_delete(&vmap_block_tree, vb_idx); - spin_unlock(&vmap_block_tree_lock); + tmp = xa_store(&vmap_block_tree, vb_idx, NULL, GFP_NOWAIT); BUG_ON(tmp != vb); free_vmap_area_noflush(vb->va); @@ -1031,7 +1022,6 @@ static void *vb_alloc(unsigned long size, gfp_t gfp_mask) static void vb_free(const void *addr, unsigned long size) { unsigned long offset; - unsigned long vb_idx; unsigned int order; struct vmap_block *vb; @@ -1045,10 +1035,7 @@ static void vb_free(const void *addr, unsigned long size) offset = (unsigned long)addr & (VMAP_BLOCK_SIZE - 1); offset >>= PAGE_SHIFT; - vb_idx = addr_to_vb_idx((unsigned long)addr); - rcu_read_lock(); - vb = radix_tree_lookup(&vmap_block_tree, vb_idx); - rcu_read_unlock(); + vb = xa_load(&vmap_block_tree, addr_to_vb_idx((unsigned long)addr)); BUG_ON(!vb); vunmap_page_range((unsigned long)addr, (unsigned long)addr + size); -- 2.15.0 From 1584743577507115646@xxx Wed Nov 22 05:40:47 +0000 2017 X-GM-THRID: 1584743577507115646 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread