From patchwork Mon Jun 11 14:05:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10457903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D4A576020F for ; Mon, 11 Jun 2018 14:08:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3421C2040D for ; Mon, 11 Jun 2018 14:08:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2886B28418; Mon, 11 Jun 2018 14:08:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C68672040D for ; Mon, 11 Jun 2018 14:08:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 947CB6B0274; Mon, 11 Jun 2018 10:06:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8D4536B0277; Mon, 11 Jun 2018 10:06:51 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FD476B0279; Mon, 11 Jun 2018 10:06:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f197.google.com (mail-pf0-f197.google.com [209.85.192.197]) by kanga.kvack.org (Postfix) with ESMTP id 062CA6B0274 for ; Mon, 11 Jun 2018 10:06:51 -0400 (EDT) Received: by mail-pf0-f197.google.com with SMTP id e16-v6so10350481pfn.5 for ; Mon, 11 Jun 2018 07:06:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=t6zM/qfm33anwBHTDJRDqef1HwwyX7RB48+ecTyMpRE=; b=h15MdRhabGH12LytO3E5ngXOVhgk+2zEeAtqalaj8lYLbFk6z6i2Rm4dlDoSl6IVF0 C9QjhKwfPh6vHOOi9McOmV0oyN7zDJevSTSAmqlEdf6CihWWDWHR8FvGU3ReIwexJze6 x9BUhwq2kRPLKk1zpZgejFRKCdgHu2oQnvbsbskFjUMTF7sdBmfpwux63yUv1QfSuMVX /Y0sFmUAafOVNI0aJ1Qxtu8/FEXr6hnvloH7BjwvaHzsxx9jqk8N+Y+r/6W57CXXjgic 0pQajsv1liMHGa4zXCsbOnHcgV3UKM03kz+WR4OIGlvnnUrsBCOhZre98pEN8kY+wmBt 4vlg== X-Gm-Message-State: APt69E0QcFfZeph+Cp84sbnNqXYK1jvJBiN9WwvXSaByAFjt50Kai/p+ YtNMUG/ib9MATxd60wvEtDOvFhpf8/H7FuHNnu++IU2bYNjPufCzTbgqkDDnJsAW7S6LNO6K9X1 taWYEJAisQlpLLGhqkUGq8rhiCflN5ylsbXtqHeOU4HAYcrHq5PCucg2uXmfR8bS6zA== X-Received: by 2002:a65:64d3:: with SMTP id t19-v6mr15033818pgv.148.1528726010693; Mon, 11 Jun 2018 07:06:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ4Mee/qDxO/ubAgb9YjvsxWQJzZyNNlkTx2qIvRd1n42Ejuu1pvZ3t1v7uNm1eCulRrhCR X-Received: by 2002:a65:64d3:: with SMTP id t19-v6mr15033764pgv.148.1528726009764; Mon, 11 Jun 2018 07:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528726009; cv=none; d=google.com; s=arc-20160816; b=wz72cRRFpfZp2UCA2Pe7RK0OdopO7E/WB8JrKD/btWqo4/X6QC+cm/ZGz28k0/QTIy aY6bCASfrcBqBYkqMt5qak1p50oW3x0r9/iwZ2g3puOy1gfwa/EGyhlg9Ehfjkmkk+T+ wIcHQqUnK2rinq/yjgm207dNyYyBij84FbigJK0FVaeKfOUQJ+I4GokhNCHdUW0mgW6n BESsBmoExXZ/+FCYLMGrhV24iKRaPgP455KLGPgws+glFln7XqVg2iqGFq4D5R34pjDG D3RaV3DPzKpV5jIYrIflHfeSkjY8SQTegcR+D2tWzoUsGx17aIanEuq8KyziO8BzZ11D 4TGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=t6zM/qfm33anwBHTDJRDqef1HwwyX7RB48+ecTyMpRE=; b=P0V0lCkLfLeZOVM1BiDifKH2ud33uP67jQvW9O7p2Ie2plELmjq1jKFQ/pRDeMmiT7 YT/VHi7ZKmq56XuuL5Bvq7LCv9ieZQQZrERQcHMe8tp2+zkYNyktI8uye7af1rsM30sQ QKCGPgdxaZChcRC00OEEMxJDGmk/5HIwQ4JLfDnI10CYfpDEcbhuO1EYCMNkzMYV6Y06 DZxtyIIAvqpD9bdqWLJDwZW6+9yhlMrPL3kc7V+LUXnTvRwYsf7MUIg3JfuWHdp/Fcnz 0M/zjn4vKP2Zg/nstMbEG0kT4CDZ+dtbuGmkBE89Q+DppdPXEVut06OTgX9stxgZ2j4Y jOsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=FnvKd5k0; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 191-v6si33781491pgh.407.2018.06.11.07.06.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jun 2018 07:06:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=FnvKd5k0; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org 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=t6zM/qfm33anwBHTDJRDqef1HwwyX7RB48+ecTyMpRE=; b=FnvKd5k0mRY3tpyDxpW8zkaxy Qksjm/1NbQtSQqwZvTLuPVg1DPG0IrxfxWhP6XSrUPD1nW+Ie06qfuhi5qeaUQ6fHRtS/gapSRDJt J0L8eNUc0ykFt/OxWaMKcJBLKTZU92R9+qWZlgSkpHd5qnviQBFdlXP6JvLdDCNpv+s4rwhU+XGMf m1I4rA+CccFm6egoeLNhJxcSJTq/yI1LV4uB9vKabAbahlyhMKBoiqjbKOQH2Dk5b17WY0Op8rxPG LP4Qy3PO5A9uGvrp7rUDfDnzVC/5XDEa34VrqjiOfaVIXeQVgcaEFaGevDcUhuIwTCjSY0EKa4wpY ivUTAjmiA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSNT7-0004em-17; Mon, 11 Jun 2018 14:06:49 +0000 From: Matthew Wilcox To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox , Jan Kara , Jeff Layton , Lukas Czerner , Ross Zwisler , Christoph Hellwig , Goldwyn Rodrigues , Nicholas Piggin , Ryusuke Konishi , linux-nilfs@vger.kernel.org, Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH v13 23/72] page cache: Convert find_get_entry to XArray Date: Mon, 11 Jun 2018 07:05:50 -0700 Message-Id: <20180611140639.17215-24-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180611140639.17215-1-willy@infradead.org> References: <20180611140639.17215-1-willy@infradead.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Matthew Wilcox Slightly shorter and simpler code. Signed-off-by: Matthew Wilcox --- mm/filemap.c | 63 +++++++++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 7cdb1d4b8117..6db3d35ff5f6 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1382,47 +1382,40 @@ EXPORT_SYMBOL(page_cache_prev_gap); */ struct page *find_get_entry(struct address_space *mapping, pgoff_t offset) { - void **pagep; + XA_STATE(xas, &mapping->i_pages, offset); struct page *head, *page; rcu_read_lock(); repeat: - page = NULL; - pagep = radix_tree_lookup_slot(&mapping->i_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; - } + xas_reset(&xas); + page = xas_load(&xas); + if (xas_retry(&xas, 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. + */ + 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(&xas))) { + put_page(head); + goto repeat; } out: rcu_read_unlock(); @@ -1453,7 +1446,7 @@ struct page *find_lock_entry(struct address_space *mapping, pgoff_t offset) repeat: page = find_get_entry(mapping, offset); - if (page && !radix_tree_exception(page)) { + if (page && !xa_is_value(page)) { lock_page(page); /* Has the page been truncated? */ if (unlikely(page_mapping(page) != mapping)) {