Received: by 10.223.164.202 with SMTP id h10csp663226wrb; Wed, 22 Nov 2017 13:17:02 -0800 (PST) X-Google-Smtp-Source: AGs4zMag2oBXkeEkzzm38LfrtcivI2q/J+G1bTpKcAGNsXZNrvY7Ty69QHFLIGGeWJhbXxBeAzqb X-Received: by 10.98.158.139 with SMTP id f11mr9978571pfk.216.1511385422467; Wed, 22 Nov 2017 13:17:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511385422; cv=none; d=google.com; s=arc-20160816; b=E3FgAygnUsDOIVJWNJ8oMRPyYcbmW3/i+T83y17631b3HGFU6e/KofPppdjbU0vDTU XjfXHNQhy1JsHxftZUszY2YAJtW1XfI9m95o2ATLu6g0EVQoP3ZBwMXpW0hCrrf6dMQa L63plN0bye4PDbTn5mhkOERpfArSHbK6UdjvK2Oy/UeRnFOjMhMAGuHBRW/YvabU6L39 DQE72m6/msZMuLcCq4725Cih0AjZrHsZc7pKB+RdqiykIbIUulCV7sFdQmK2VUkkKknn i46VfFRqiHgATAeCX3eKtsK6LIoA6CA6L5DVtsscaOX37Odb4xeFL+aqIg68e7qwfA9Q pHyg== 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=axQtw04qdkr9zMhZ4hHhcGCAUBpQ8oUtP6krz2RMC18=; b=oqHDu+cGLCdDPTb7J6QWldZXnZYvO5RFvuVl3GZTKSBvnBlEHWSR8zcLxrXeojxB9k sG7NYiRJxQWS5mqmnDHaPRpv/9U0cqnkcnch+HEdZEDIbEgzwuDIslD0EnQNGoqqGagt Y24LDHHZOL2H5ra+L6KVIvYKUZnqf7HH3CdG4eK0Qa7OY+oCBwCp31NHT5tMBtO8QuHP 5Q1TJkb08XDZELmr1K0dRNiYf7TAVROBOvJKoYDw3rA3UzbrV5ecTGW7nG7uac2T+Fri ajMqqvD5haadW7ADiu4g8wCVL5TNpJ8Ndpq1p5bzJXIOp3owNxcdL9qN5/N00Ds7hBud semQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ZaovVfQX; 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 x66si15815017pfi.70.2017.11.22.13.16.50; Wed, 22 Nov 2017 13:17:02 -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=ZaovVfQX; 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 S1752320AbdKVVOc (ORCPT + 77 others); Wed, 22 Nov 2017 16:14:32 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:37485 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751814AbdKVVIT (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=axQtw04qdkr9zMhZ4hHhcGCAUBpQ8oUtP6krz2RMC18=; b=ZaovVfQXHnRZbas1SLqIgMwUf oZnGZnUGR2Mf/h/XvTlfchrOrTmVL/8WzXYQffZk2lH2Q3ua2C4jllwnsRh/t3TfP65IsaWqQqn9l N8wjlZx/3xKV+QLKR78a0b8MHsE3s1lOv3Lyz64W1E7S9odkOrIgM0ppWaaMfXUA+EQsw/ldMbf3W 1hZNAFeMWXUsYMOlAOmWgD8cScqBUo9axZf2cJPn/9gA2V7PLtFR3iL+O2dM0U7RBVbfgpuerb3v+ X49yg43SBXJvOHeh395Ze8rY2jxhcp3gGcetOiJ9I7astO1/G8ZsFIJP4fTiU9UVTsJQL2CH1XqV7 orOb5kFAQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1eHcFm-0007w9-MM; Wed, 22 Nov 2017 21:08:18 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox Subject: [PATCH 37/62] shmem: Convert replace to xarray Date: Wed, 22 Nov 2017 13:07:14 -0800 Message-Id: <20171122210739.29916-38-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 shmem_radix_tree_replace() is renamed to shmem_xa_replace() and converted to use the XArray API. Signed-off-by: Matthew Wilcox --- mm/shmem.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 21bf42f14ee2..f16afa03cfb0 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -321,24 +321,20 @@ void shmem_uncharge(struct inode *inode, long pages) } /* - * Replace item expected in radix tree by a new item, while holding tree lock. + * Replace item expected in xarray by a new item, while holding xa_lock. */ -static int shmem_radix_tree_replace(struct address_space *mapping, +static int shmem_xa_replace(struct address_space *mapping, pgoff_t index, void *expected, void *replacement) { - struct radix_tree_node *node; - void **pslot; + XA_STATE(xas, index); void *item; VM_BUG_ON(!expected); VM_BUG_ON(!replacement); - item = __radix_tree_lookup(&mapping->pages, index, &node, &pslot); - if (!item) - return -ENOENT; + item = xas_load(&mapping->pages, &xas); if (item != expected) return -ENOENT; - __radix_tree_replace(&mapping->pages, node, pslot, - replacement, NULL); + xas_store(&mapping->pages, &xas, replacement); return 0; } @@ -605,8 +601,7 @@ static int shmem_add_to_page_cache(struct page *page, } else if (!expected) { error = radix_tree_insert(&mapping->pages, index, page); } else { - error = shmem_radix_tree_replace(mapping, index, expected, - page); + error = shmem_xa_replace(mapping, index, expected, page); } if (!error) { @@ -635,7 +630,7 @@ static void shmem_delete_from_page_cache(struct page *page, void *radswap) VM_BUG_ON_PAGE(PageCompound(page), page); xa_lock_irq(&mapping->pages); - error = shmem_radix_tree_replace(mapping, page->index, page, radswap); + error = shmem_xa_replace(mapping, page->index, page, radswap); page->mapping = NULL; mapping->nrpages--; __dec_node_page_state(page, NR_FILE_PAGES); @@ -1550,8 +1545,7 @@ static int shmem_replace_page(struct page **pagep, gfp_t gfp, * a nice clean interface for us to replace oldpage by newpage there. */ xa_lock_irq(&swap_mapping->pages); - error = shmem_radix_tree_replace(swap_mapping, swap_index, oldpage, - newpage); + error = shmem_xa_replace(swap_mapping, swap_index, oldpage, newpage); if (!error) { __inc_node_page_state(newpage, NR_FILE_PAGES); __dec_node_page_state(oldpage, NR_FILE_PAGES); -- 2.15.0 From 1585267402693812836@xxx Tue Nov 28 00:26:46 +0000 2017 X-GM-THRID: 1585267402693812836 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread