Received: by 10.213.65.68 with SMTP id h4csp352558imn; Tue, 13 Mar 2018 06:32:13 -0700 (PDT) X-Google-Smtp-Source: AG47ELvzSUOnZ9leuSLzWAjDXZZNrZHit5cVRq5bE8IbMV6rbqp06jhqY42gZp3pBQw2PPEFVSE3 X-Received: by 2002:a17:902:aa03:: with SMTP id be3-v6mr572308plb.211.1520947933594; Tue, 13 Mar 2018 06:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520947933; cv=none; d=google.com; s=arc-20160816; b=1Aw8ruwYSrePZ6pkmsRrnyOuEdvY5TmTh1r1QX4L3AFdzwIn2rbFrVGDyIITWAFPT3 m0qzhsG9IgB/FbrGmAOoGdPaqJuwu3RH4772uzLwQ2m8XqWzlM92Mp1t2H3rbSLcochF 7ztBl1lrzyCAtwBYR3Eyg5yw/rstfLQUCsbuyP5jvjUUDfgE+eusFjZfBueL3kpb3Vb5 K7/ZY1t/uOV3g8BgDAIraA9qMt5jcs6/FviHn4qzIKJDaWHQdzcBFAkUGiL4KjfOpMWm yQ5NB+we+4/rSAY6ybSa9/2DVdvOA/sbAscem5LvslEQyrqod5DRujsVaqFEq9wYxPzx 6WEA== 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=QIGG0xhBMi69prC5wMNjigBBfQGawNcCDlqjj9zzld0=; b=00herGQ2T4DKehHMj3+flzVv6zEctSr9YX0jPFEUB3gYqJCgd6CpHF/ydMqqEuvEDt H7GuDJEyt8Lo9o2uEmzgkg4kWpi5k1Hx9hwYvmVwAPnUWHLLrvj8SNEAi3xmni2gaac1 rYH+xWdreD8YfYSx8cIMC4vCzqbIC9Knb7Wp+n/LbM9T4xbmmRtGhc9oALCbqCBvwth+ yLmTYOVkIzQ2LMcPGr/Cu6kFrooyJjxHrCQ5xD2y/BaElsQmFlJrR6ovO+oy36KF0OQq CwrnW16ZGHEPAYV+boXWyNwNb9+DHW2/dybheXLel2kqIU6Jzojjrg6MSc2TF4HqRKvI P7VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=mTsFQKSf; 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 x22si135257pfm.321.2018.03.13.06.31.58; Tue, 13 Mar 2018 06:32:13 -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=mTsFQKSf; 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 S932952AbeCMNaD (ORCPT + 99 others); Tue, 13 Mar 2018 09:30:03 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35598 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932694AbeCMN1H (ORCPT ); Tue, 13 Mar 2018 09:27:07 -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=QIGG0xhBMi69prC5wMNjigBBfQGawNcCDlqjj9zzld0=; b=mTsFQKSfryL6UgxSkeuWqwimo xgaigUJEOC+5LOhjigjAZPCBLqdkgW5a6r2AtXMKTznr6sLNsZinnFdpYDN7VkixFMcfGcK5aw7g1 +UpJFiok3qzhxFsRWL4f269oCSodTzEqixVA3qcZkW6x4DKKPEGe3M1NNwMiEoWVrRA2gCfBswQXz fUUM2E58pQwtyBC93W0o6mV7MiEh9zgYHqHrJjzawkAtoAQ7pAWHEvAJskAS9kZxfvt34Rzrt/2bu g66/wrnQVZ74BrUZi9sy3aMlRPOXJWa8qRMESfKb+sKH6Z/LYc+HkSzIZ11DzGnKCy91qydDyZc+S 1bOsy9kcQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1evjxK-0004mp-0g; Tue, 13 Mar 2018 13:27:06 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Ryusuke Konishi , linux-nilfs@vger.kernel.org Subject: [PATCH v9 55/61] fs: Convert writeback to XArray Date: Tue, 13 Mar 2018 06:26:33 -0700 Message-Id: <20180313132639.17387-56-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180313132639.17387-1-willy@infradead.org> References: <20180313132639.17387-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 091577edc497..98e5e08274a2 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_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->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_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