From patchwork Mon Jun 11 14:06:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10458013 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 E59CC601A0 for ; Mon, 11 Jun 2018 14:11:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D54502846D for ; Mon, 11 Jun 2018 14:11:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1B4A2855D; Mon, 11 Jun 2018 14:11:48 +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=unavailable 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 9D6E82846D for ; Mon, 11 Jun 2018 14:11:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F16B76B029A; Mon, 11 Jun 2018 10:07:10 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E74FA6B029B; Mon, 11 Jun 2018 10:07:10 -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 D14B66B029D; Mon, 11 Jun 2018 10:07:10 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f71.google.com (mail-pl0-f71.google.com [209.85.160.71]) by kanga.kvack.org (Postfix) with ESMTP id 8D9106B029A for ; Mon, 11 Jun 2018 10:07:10 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id p91-v6so12108565plb.12 for ; Mon, 11 Jun 2018 07:07:10 -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=rjHUJTTQC6xMfhF+XWu1NEuTxvlVO1pnsA+PiPK/GIM=; b=XS+ijdPSqn56jx0T2RfBJIOM/jX6vXOwXuzJYJv/bGiZ/W6yg+UN45UGtTEQmCDyvh GlezFSHwbIlRW1pX8mSA4HAN+iOwR920BuKCXM7UChVpaIegHhIQFPJgMl9uHC/SDLM8 6PTcUXqs/VSvewA0US+L2Eumjiv+nNhS6JfXEN6DvCbiH8MfxLjXPicivQ0XrkCIEQuL 56585LdAYBxx62oCqADNxZSybRITW8rIn/sCc9ernm8G8fipucJEw0ro99PXwvwZYwk4 DmwEZDwSYweYcimf0gSBaHZiaeSya0e1OkVdff1dZfFLrtqGQDG0TPFx1/AUq2w8Qn1T L+lA== X-Gm-Message-State: APt69E1jh84HMS6bN9B44+cTgpK24HA4mIcbYt0kAGaHolFgbMaEar7e X5YhpUqq0aeIJ3PVyGOmnEEV9NjWHyE8kgKEyrwuadwYPdtnG94S6NeVM4j30ioXuLf49j3p8ZT U9aaUEOQxfu0OAXvZSRyBhfIizqnoXxUkm6KBF4WZ7CKppJwhiLLFwGGop2ey6J4h5A== X-Received: by 2002:a62:d508:: with SMTP id d8-v6mr17868990pfg.128.1528726030272; Mon, 11 Jun 2018 07:07:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI1cP114c8gE2rDiCnpxNn01kFgKMeFEh6lPtcNwcvvxyIqJ6ard5jPuB2XML29F7DE27wF X-Received: by 2002:a62:d508:: with SMTP id d8-v6mr17868917pfg.128.1528726029198; Mon, 11 Jun 2018 07:07:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528726029; cv=none; d=google.com; s=arc-20160816; b=teTLeeoJUc6siDN2FPRITTU29BWd+2t51jJ28+bOqRPwzNzvCmrsCbbN7vQ0kSPBPK KXbBF25IoORW7nQanuPQwBWHA3Sv2+nN0+Kwi/vZt/SmOvNF3+pY5sVulDrJ/Bfaj2oH vQbA2DXvKyjYjfTcvkvyd5F7Bk/ZPSIIqkSCq0Mz68ORuBr7QJNIH7hfA/KF6QvfyfeE y68HWZiDE3LF2bKihoYtkTA+oBDKjG0ephUlN1py8v7EjrYNW7j1zTHLih/2keyf4coj uQJDwbblXvPwHRh4yNFVbBxjaSxDY7GCuec2TnQKw9KPj3bNpvFlngKno3B5xg3KzKXs E49g== 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=rjHUJTTQC6xMfhF+XWu1NEuTxvlVO1pnsA+PiPK/GIM=; b=zUNLZE5EWB3C47E1Rkji9xZOqADgCVIF7gguRHDS130QhnDXdR7txzNIo/f59tF3XY VytsyqLPlgu6mFDj2iSaGYJF3n1ervwX9fE5GcGHPS2m2RHdK5Ho0vyz8iGQkbGAfKXa PVPJw7Nrwz5aPyN19ROF8M7aNUAtgyw8loC5xZ+9100vVW0O62Fpku+vjSXKP53akLHG zuecPG7guWe4Cp6h0k07J8/DAmo0khYTNNXgOG5pYoQobwfmzoDGMd18buL6hnv3nBvK LIQeAYQfofqMd+wHlCaLkz8re7wB2hgjAj1VLRocfLoXZO4OLD/4A/FVA44N1yWfFBA/ w5LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=d459D/BI; 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 o63-v6si5826887pfb.20.2018.06.11.07.07.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jun 2018 07:07:09 -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=d459D/BI; 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=rjHUJTTQC6xMfhF+XWu1NEuTxvlVO1pnsA+PiPK/GIM=; b=d459D/BINZ/8hQdtBQgjnZTqe 8B0BFn+rP17lb2ql24O2/PQ2ziqsZyQpfNTrJ7K0IbkbjUZU8aiz3uPOvVUMCpyhlpAqFibipyRdV jKWPIfmcqxArCJHWPA9XqlUXDNDxoCmCZMaEy1X4eJkR1vXwiUZMEkl2vWwD1/FgkqThaaBTnR3SE f3Ga9cGj+u/hXikWei6NcT+CmiT3dIomCL73a5p0YD/DHp5+u+vvShYEYiGsAETSGW91dcPpjb2SW fXjkF4tAG0tF1nzjDkiHFt4YmiKsLW4TSCSIJSkCImp5/oGEogPP6AUngN/xnxbq9QTE0cETBp4iN gp8Ie5tnQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSNTQ-0004xZ-9L; Mon, 11 Jun 2018 14:07:08 +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 58/72] fs: Convert writeback to XArray Date: Mon, 11 Jun 2018 07:06:25 -0700 Message-Id: <20180611140639.17215-59-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 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);