Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2450381imm; Sat, 16 Jun 2018 19:07:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIhgltySd7KVEO6WsbkvZpjMH4umZeRWJsmmKVyVA2HLwHQ+hNGMPSbLk57T2fzoSbqdhrk X-Received: by 2002:a62:db05:: with SMTP id f5-v6mr8007192pfg.123.1529201243634; Sat, 16 Jun 2018 19:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529201243; cv=none; d=google.com; s=arc-20160816; b=FHVQ/5ehwAjhbD3ON5MGcArsHfQu3aylfRg51SoHi85+Y1766O/vgzr2zrfxkH3iLe 0KWGGzoGojIiQNzX0G9+jOfkxcbIpsbOWVPeB1FAqPgRShPX/LRbIvwzB7QHgzQ6pk20 LPaGwuoo1QshxKFJfYS5qrvFpf4iroj/AYh/AOfj7nZnt41rbjUbfTBIMGgQDsVLj8v7 a+asgC+UyF2TRJ18ETXwWz3nuzvrxvInBinrcel55P/XjlgG8ZlbBbRzsj5znD+TSt6p rIi/UwZtGsZS5JXOKcTvMVjJhtzY0emGRQ1Z2A6GQYfPstTHpYIkdU4137AdMCqL8k0p 3wBQ== 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=re5QLa7NMPA59F43fRgtkyRq1k3cHOtuA8XEv+/QF2g=; b=VpkXQTmNdOSmdpP3W+x0EwOpSAcbIxTMZyQRNbvTIoVz4jnGSs6tdjol1jlb+/WVCz VKekt+ZWF+rG0PwVl06LL9ZMs/kEVSiw2jZcnkBBcHZzR9zSqo0vo9uWUKAnvtwkGpZT wiYyb0we1wDqeFCLm8b6Um8HgvP3qQQamD8C+7HHRwGnioe8HzECrgT2E8DHuJTPVbsc jSMT8d9tT8yLHv9UgwhZXUIrWoFJPeYP25URMauauivOEI5eWgn7AI4Nhv8ImKGXxjHD WGHLV7OVCWw+WuTsT4IYfs7vtTSsnMSq5a9/GRzJHd0PSk5wDMJnYRJQW02P+J+aS50o CQaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=AZ4daUTr; 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 v11-v6si9461083pgt.548.2018.06.16.19.07.08; Sat, 16 Jun 2018 19:07:23 -0700 (PDT) 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=AZ4daUTr; 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 S965181AbeFQCFU (ORCPT + 99 others); Sat, 16 Jun 2018 22:05:20 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:60100 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934311AbeFQCB1 (ORCPT ); Sat, 16 Jun 2018 22:01:27 -0400 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=re5QLa7NMPA59F43fRgtkyRq1k3cHOtuA8XEv+/QF2g=; b=AZ4daUTrnhcdk1GtyMlW6qedp p/fcHEetg2PqqMLrTHf3bF2ORsRYJSMyxVt07TemE/1KOxnUuYMGmN6WVCi/oBal7wCbQRakUp1Ew XLiijCQl6etgKvO+fvsy12S3UAtaPvIEElcIQqEOVjVErdOx+H5ZFQMoz8lvEEyOtPL6fndAQ2pRn lTkjx+0kN4n0Lix6mOQZPXro7ZCDC/t9KD22hket09qaZBf0CpjgFO9xIVyes4d8wLVozHbr1Hh9S b2R1KRhYcVsXxEZvysfqm8O00YXpl65p9wTkwkmlNKUH5O7v25bLKROueOOZVZi8G6jLT0k8YWZ5U PWqbdNsog==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUN0M-0001XK-TL; Sun, 17 Jun 2018 02:01:22 +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 v14 59/74] fs: Convert writeback to XArray Date: Sat, 16 Jun 2018 19:00:37 -0700 Message-Id: <20180617020052.4759-60-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180617020052.4759-1-willy@infradead.org> References: <20180617020052.4759-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 471d863958bc..137f241a3ee3 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->i_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->i_pages, &iter, 0, - PAGECACHE_TAG_DIRTY) { - struct page *page = radix_tree_deref_slot_protected(slot, - &mapping->i_pages.xa_lock); - if (likely(page) && PageDirty(page)) { + xas_for_each_tagged(&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->i_pages, &iter, 0, - PAGECACHE_TAG_WRITEBACK) { - struct page *page = radix_tree_deref_slot_protected(slot, - &mapping->i_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_tagged(&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.17.1