Received: by 10.223.164.202 with SMTP id h10csp661982wrb; Wed, 22 Nov 2017 13:15:43 -0800 (PST) X-Google-Smtp-Source: AGs4zMaDcNTjYfy9hpG50rI5a1y/adcZJVhz9hUkIWV8yzJO6cUJ+9xnlnVwodym8VANVs2vjBMj X-Received: by 10.99.120.131 with SMTP id t125mr21923921pgc.81.1511385343003; Wed, 22 Nov 2017 13:15:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511385342; cv=none; d=google.com; s=arc-20160816; b=oWAodR/mLoY3LpUgRKDwH+fsG5rBF1mxsNdDlKoBrJA0QUai89uf15DfKPqOXMS3M2 2cZWHZSNBPDTe17lxppU9EDBIbdKrAIZ5797I7Fmt4Z5eRcS8+iQluxNZidjZBnwOxAI XIz8vLvvzAXluhVi3qKS6UaCK6xNPv1Xy+d93hgiJ0DECgYYtGP3f5580jOR8AFOOvge 1EltfcERFEpzc2/niTf1kldpR3s+4EadScE5mdlljcJ7boguDGktvXo8PhEqxn5YKhng yN1tmpor7F+s3SYgcDmcLWzSiWopmmst6vMpCElnT6jYdRwxkIST/LjVQCV056FItnuw N09A== 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=SEM1BZ+HuBiUNRk4FsAufzALpFA9gYu521QuXuGM6dU=; b=hUFbKL0FS/85ld+RmeOcoZQtcPGhqPIdyXtAQc87K6hQ6HI+DVFo/0ElMlAIXLN/Sv JClzbbYewh8GQR0lRc2DdvDPwj5xMJmajnVUxAPe0rcri4GGKRKTGW/AgjRQZK1A/DwZ LH/GPspl2nDQR7akdqDmr3egyVXmWFsmxpUX1LVW0bxSDdJnhKFDrEVkBhv+V5IYNshU dTwqq0cuNGas1UjpyAqOffYFdITRK/0iT6kpyVgSLtuys6TaIavEpG9Hw+XKQZQpbAOF zaSXBiGYWG/SikAJPlBNp0UJuaACD0+u/D/Ucjn9clQKm4vGzUbZCSmkfWDR5hNZCGYb 8HKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=CKCvaINO; 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 e190si15361176pfe.409.2017.11.22.13.15.31; Wed, 22 Nov 2017 13:15: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=CKCvaINO; 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 S1752340AbdKVVOd (ORCPT + 77 others); Wed, 22 Nov 2017 16:14:33 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:59408 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751808AbdKVVIT (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=SEM1BZ+HuBiUNRk4FsAufzALpFA9gYu521QuXuGM6dU=; b=CKCvaINO50YcGIiQHX691qgcf Sls+G2tbz+KtzaB085Km0y4LuRUAeRmnKIfryiya5zVuEccIhLV696GRrbEwTZtky+DxqHoxQAWnX 0WDxBqL7DLp3m0B8MgKApDTdmBA3t6WHIPChDvq4BK3mtdY+zfRyQirzkdQQ7RKu2eduTN/B6HIdz INyuL07E/ocAxi/8RKckCiNtH3ObfkTdH/qLpVhzOdH6F3vxWQ8Znnw67EckBiwXSOt7I6nAQrG0s pbpaBvRhxq/+XGmtObIuwnjft/U/mWaOUuMb7wvNFu6s+kfjjdu2B+wkqv+WT5VlhgNePMn2v+nsx +/7QLs5hA==; Received: from willy by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1eHcFm-0007w3-Kb; 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 36/62] page cache: Convert find_get_entry to xarray Date: Wed, 22 Nov 2017 13:07:13 -0800 Message-Id: <20171122210739.29916-37-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 Slightly simpler and shorter code. Signed-off-by: Matthew Wilcox --- mm/filemap.c | 56 +++++++++++++++++++++----------------------------------- 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index f60f22867a1a..2172c9f9efb9 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1391,51 +1391,37 @@ EXPORT_SYMBOL(page_cache_prev_hole); */ struct page *find_get_entry(struct address_space *mapping, pgoff_t offset) { - void **pagep; + XA_STATE(xas, offset); struct page *head, *page; rcu_read_lock(); repeat: - page = NULL; - pagep = radix_tree_lookup_slot(&mapping->pages, offset); - if (pagep) { - page = radix_tree_deref_slot(pagep); - if (unlikely(!page)) - goto out; - if (radix_tree_exception(page)) { - if (radix_tree_deref_retry(page)) - goto repeat; - /* - * A shadow entry of a recently evicted page, - * or a swap entry from shmem/tmpfs. Return - * it without attempting to raise page count. - */ - goto out; - } + page = xas_load(&mapping->pages, &xas); + if (!page || xa_is_value(page)) + goto out; - head = compound_head(page); - if (!page_cache_get_speculative(head)) - goto repeat; + head = compound_head(page); + if (!page_cache_get_speculative(head)) + goto repeat; - /* The page was split under us? */ - if (compound_head(page) != head) { - put_page(head); - goto repeat; - } + /* The page was split under us? */ + if (compound_head(page) != head) { + put_page(head); + goto repeat; + } - /* - * Has the page moved? - * This is part of the lockless pagecache protocol. See - * include/linux/pagemap.h for details. - */ - if (unlikely(page != *pagep)) { - put_page(head); - goto repeat; - } + /* + * Has the page moved? + * This is part of the lockless pagecache protocol. See + * include/linux/pagemap.h for details. + */ + if (unlikely(page != xas_reload(&mapping->pages, &xas))) { + put_page(head); + goto repeat; } + out: rcu_read_unlock(); - return page; } EXPORT_SYMBOL(find_get_entry); -- 2.15.0 From 1584777606816938090@xxx Wed Nov 22 14:41:40 +0000 2017 X-GM-THRID: 1584777606816938090 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread