From patchwork Mon Jun 11 14:06:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10457939 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 BB1686020F for ; Mon, 11 Jun 2018 14:09:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A954628451 for ; Mon, 11 Jun 2018 14:09:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DA642846F; Mon, 11 Jun 2018 14:09:09 +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 3988828451 for ; Mon, 11 Jun 2018 14:09:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 21C506B0282; Mon, 11 Jun 2018 10:06:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1A5DF6B0283; Mon, 11 Jun 2018 10:06:58 -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 F37AB6B0284; Mon, 11 Jun 2018 10:06:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f70.google.com (mail-pg0-f70.google.com [74.125.83.70]) by kanga.kvack.org (Postfix) with ESMTP id AA1116B0282 for ; Mon, 11 Jun 2018 10:06:57 -0400 (EDT) Received: by mail-pg0-f70.google.com with SMTP id t5-v6so6575104pgt.18 for ; Mon, 11 Jun 2018 07:06:57 -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=Uf6g1DCKoZTcsIod4MBFbPjjHdDF87hOdzkkZTr2U34=; b=Eld4WVwyFxcfvEThMbrkq3uL5j+7iAEvq8RjsARNEeuaKF75UWyoE1z4lJaHSvSbx/ Vd6Ll1EI/eexl1EX9kGYKac+pd18PDv/oYdzt4mb+dXi9QZwxKgvGe44Y3q3MF5YuhJL Y3pePqAcBTYa0tyI9P7Dd8BotYr/XbxZ+aNYxKKZKJ5FJ13O5N64S9ltGHL2drs6kgIk 8DSaY6KdNm+kI3ETzqqG/dW9iZS65SJ0l+dEo0iR2EaDdXslBKA82BQmGQjDvC9ix43F e7BdNjMO4BT/eZDcWNqQFFNbXUhvvvMrHnFmp5xl8QXc5SGEFsMy9c2wBcI/Ru6FXRUD KSMA== X-Gm-Message-State: APt69E1J3PWiKd/ct5NRonmQrbhCG6S3z2Xeo8fywd082bovIt4a0a3L 0l0Nbd1Ak+Onh2yo51S9eGb9Y/5xq9g8nV2/qCflgPCFlDCryw9DQayInlQ0CvQgUjHAZD5jZjN 0S4SV65HLSCfa3av3Y5EaTxhTZ2+xOjZM7Fm+hSHmOnZxqejuh73yhAXNuYHhrsDMDA== X-Received: by 2002:a17:902:9a98:: with SMTP id w24-v6mr19101660plp.9.1528726017389; Mon, 11 Jun 2018 07:06:57 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKoB7Okbp9cvs0LO7q/6bz5eWWK34oqqlllE/A/TPnWw+pt1cdNJLCtrvl4/UVxs8xpXjxE X-Received: by 2002:a17:902:9a98:: with SMTP id w24-v6mr19101602plp.9.1528726016429; Mon, 11 Jun 2018 07:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528726016; cv=none; d=google.com; s=arc-20160816; b=cwnsGQk1xd72r6DdE8eZ5VImiTfABqJ9HEmJVrldUQ6XeH0fR7YYh/RYVPIZuJBLjD KLKZToWgvVVp0YBV8pJTaoOTSUgEgvjgD1Zq37JAGYb+w0gTLE23KMwoFlKnD9GOc/BL M/B/C6A1Og8rCeu6vZ1xTcUmKNNyQhMAaxmHgCXI5npGpihZnOxg77rLCAMeiNDL25k/ e7r0JpBqHUZIH46xdtkTLT6UXmYhnU+069H0kBDzuAisVQLEm6zJyncEqpGfh2VbaDgr idBy4IDIJAnfYTdUkGt7YGW00NJSlDUX+1mt9k4z3UpphM2nzHpAEMeGs91/U/j0DAcA fyDA== 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=Uf6g1DCKoZTcsIod4MBFbPjjHdDF87hOdzkkZTr2U34=; b=tcF62YHs/u5gFN2RsqAZ8kH2sb70fowDjCkVdEjv8r23CL2j5Qbm9i0aUwRMAJZkaS bglThhokgvX2FqZqbqXESEe2od1aoX3dp3djLeAGDt85/2QsoM1SumnwRQXup3+YF5Ae zeKgVTADzvydNHwu/kHRezLcYM8F9T107bzhJtJb5Jo2RPUZruIztV1HmnHUUqmoDKoF Ws3b9couzOx/EYTl4NqUu+dDjlUU0sLHZgv/HW9EEkBKLrKFVu3oVrojg4/i9Zb9LyL4 9AGjdEV0QcucqLzyuFBkR2P4TSDlIXV6I72zPv2iriEPxgF4JHKauL3Tgk0lYoHMjKK1 DPkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=o+RFy7+6; 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 b3-v6si43659821pls.119.2018.06.11.07.06.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jun 2018 07:06:56 -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=o+RFy7+6; 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=Uf6g1DCKoZTcsIod4MBFbPjjHdDF87hOdzkkZTr2U34=; b=o+RFy7+6TUUhlW2A8nui01xxd /Glab80k/TZGU2wA0JpNNAQlgTl8vnyVOsvoxO7vVfQwTIwqVY91UvDdxk2wAZbHjjMfZee0aDYL/ 61ehSv+o8e31ex3K+xGOPK56//Ua44BCMImv3rfWrI/DEuU4J5a8hUuKduiSa3e2oSZq+nY6DluE1 yU7SBK1e+qHo5FJkdSEVmlBUg/ZP5vEVJIAGGg7pCHS0mJaDGdACPJ7jneyhdTOsBABxSWYP3KKD6 zcsPVVPOSBRln7DGa5appg0Tz7uwMk9jxqAlB5/WIsDFr92Lg1HQ38Ttudtxb8Ms5uOFJ9p0w+crE p3MpYxtfg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSNTD-0004kE-Ie; Mon, 11 Jun 2018 14:06:55 +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 36/72] mm: Convert truncate to XArray Date: Mon, 11 Jun 2018 07:06:03 -0700 Message-Id: <20180611140639.17215-37-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 This is essentially xa_cmpxchg() with the locking handled above us, and it doesn't have to handle replacing a NULL entry. Signed-off-by: Matthew Wilcox --- mm/truncate.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/mm/truncate.c b/mm/truncate.c index ed778555c9f3..45d68e90b703 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -33,15 +33,12 @@ static inline void __clear_shadow_entry(struct address_space *mapping, pgoff_t index, void *entry) { - struct radix_tree_node *node; - void **slot; + XA_STATE(xas, &mapping->i_pages, index); - if (!__radix_tree_lookup(&mapping->i_pages, index, &node, &slot)) + xas_set_update(&xas, workingset_update_node); + if (xas_load(&xas) != entry) return; - if (*slot != entry) - return; - __radix_tree_replace(&mapping->i_pages, node, slot, NULL, - workingset_update_node); + xas_store(&xas, NULL); mapping->nrexceptional--; } @@ -738,10 +735,10 @@ int invalidate_inode_pages2_range(struct address_space *mapping, index++; } /* - * For DAX we invalidate page tables after invalidating radix tree. We + * For DAX we invalidate page tables after invalidating page cache. We * could invalidate page tables while invalidating each entry however * that would be expensive. And doing range unmapping before doesn't - * work as we have no cheap way to find whether radix tree entry didn't + * work as we have no cheap way to find whether page cache entry didn't * get remapped later. */ if (dax_mapping(mapping)) {