Received: by 10.223.185.116 with SMTP id b49csp4138747wrg; Mon, 19 Feb 2018 11:52:28 -0800 (PST) X-Google-Smtp-Source: AH8x224f22vuWmwRocKmJF4yqR63r+9AKUy3NCNuZB+PACcJtasM0R7H6ZE72+0gtlPsnPz/G2N+ X-Received: by 10.101.73.139 with SMTP id r11mr6175924pgs.322.1519069948106; Mon, 19 Feb 2018 11:52:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519069948; cv=none; d=google.com; s=arc-20160816; b=m8JOPfPvvMF6UFPNxSxn8cW5fZmypr0ZBrAj4cSRt8cCynBP00LDIsLfzqjsaAaR4K Us6hXlMwt+uuP1RHmoKHomNfA2xVSuJj4cfcxJOdwsQm70+AvPJkwHORJI/0qN+Qtn/Q hIKbQTgy5VIPgguSHPS2c4fE5M9gajjrxL33BTOeEE2ehg6zmil6pqXhzafNqUNL9WC7 3st5/Xp2bXxg1ROobLTjInRoQbDduqlAhDPNL0TO4l1/H/fATMreV8yD84t7AZLjLTOg OJKGvxJG1Xy72aN1VkAiX4lJyOE0z2SW9+u/AiB9axiNsUVUEulUo1JGCAl2Ua2kxI0m eWsQ== 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=wyq6dOWIrPFZjvVGagqVWLq2Qoz9jWe114/Vi1l2jkg=; b=Vmpu+jfMRCJQ0vizHyDJ+5FMNeMGo3Sbmgmakcf/7pnh7eandSpMyDEEzBWIUHxk7R 3ijhLrd3N9Ms+NXQYzIBaoLPLEwPUEGI2vPqyOfWK9MreK/Jd2SnLj6hzahGg8wdSh6X sxh8l2C+c85YUxqIaLpNwWyUxkcM8JBZG8UZoavXwLKpArhyL4grVN+e4TyYNtTMgxqy gjmJyGbC8QblYNcl4mu/yM+G76EbtuZdG3Jr0FQ5Q/hDbDhoIPtZ5CmvFWZ7AIYCRKuO juFu8cJtkjf/5axChVUemrajZjsLB+mPcmQAriTXcCcIZoSCwVTnSXCoNdetcPEDcRds NVJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=aRPOHq7l; 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 z62si5366383pgd.688.2018.02.19.11.52.14; Mon, 19 Feb 2018 11:52:28 -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=aRPOHq7l; 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 S1753939AbeBSTth (ORCPT + 99 others); Mon, 19 Feb 2018 14:49:37 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:45062 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753818AbeBSTqb (ORCPT ); Mon, 19 Feb 2018 14:46:31 -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=wyq6dOWIrPFZjvVGagqVWLq2Qoz9jWe114/Vi1l2jkg=; b=aRPOHq7lHOvgt3wmsZPu+9LyR 1GAI8lizHbqabhYGysRMVjK5+Udr6mBxhROiOsbv2cegzwjIB+2KGNrcvaGNXVCfq7NB99wPyAE7K L38v9YZigARe1siYSBcgtsYfJHFskmEB7+/6RZgIR3kYFPvfTQI77ZUvjTlwClzHaG5gM7arW3vQ4 +sbdJ1818R2EGnZx6hz10HNJ8KhG6Z5Q5LVx2hp90vUF8fFQjvbtFoy4OzdJg2V/KrkoQJBXgdSNN wv1A9ig5bXOQH59F/XV5LVnDbvHCXpxkWgbt47ZzyjRpUlFEebehryOsg/tbAGtJCN2AxLi8vG8b4 M+ygTqIUw==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1enrOP-0001x4-V8; Mon, 19 Feb 2018 19:46:29 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v7 56/61] fs: Convert writeback to XArray Date: Mon, 19 Feb 2018 11:45:51 -0800 Message-Id: <20180219194556.6575-57-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180219194556.6575-1-willy@infradead.org> References: <20180219194556.6575-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 A couple of short loops. Signed-off-by: Matthew Wilcox --- fs/fs-writeback.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index d5c0e70dbfa8..a937ace7e031 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -339,9 +339,9 @@ static void inode_switch_wbs_work_fn(struct work_struct *work) struct address_space *mapping = inode->i_mapping; struct bdi_writeback *old_wb = inode->i_wb; struct bdi_writeback *new_wb = isw->new_wb; - struct radix_tree_iter iter; + XA_STATE(xas, &mapping->pages, 0); + struct page *page; bool switched = false; - void **slot; /* * By the time control reaches here, RCU grace period has passed @@ -375,25 +375,18 @@ static void inode_switch_wbs_work_fn(struct work_struct *work) * to possibly dirty pages while PAGECACHE_TAG_WRITEBACK points to * pages actually under writeback. */ - radix_tree_for_each_tagged(slot, &mapping->pages, &iter, 0, - PAGECACHE_TAG_DIRTY) { - struct page *page = radix_tree_deref_slot_protected(slot, - &mapping->pages.xa_lock); - if (likely(page) && PageDirty(page)) { + xas_for_each_tag(&xas, page, ULONG_MAX, PAGECACHE_TAG_DIRTY) { + if (PageDirty(page)) { dec_wb_stat(old_wb, WB_RECLAIMABLE); inc_wb_stat(new_wb, WB_RECLAIMABLE); } } - radix_tree_for_each_tagged(slot, &mapping->pages, &iter, 0, - PAGECACHE_TAG_WRITEBACK) { - struct page *page = radix_tree_deref_slot_protected(slot, - &mapping->pages.xa_lock); - if (likely(page)) { - WARN_ON_ONCE(!PageWriteback(page)); - dec_wb_stat(old_wb, WB_WRITEBACK); - inc_wb_stat(new_wb, WB_WRITEBACK); - } + xas_set(&xas, 0); + xas_for_each_tag(&xas, page, ULONG_MAX, PAGECACHE_TAG_WRITEBACK) { + WARN_ON_ONCE(!PageWriteback(page)); + dec_wb_stat(old_wb, WB_WRITEBACK); + inc_wb_stat(new_wb, WB_WRITEBACK); } wb_get(new_wb); -- 2.16.1