From patchwork Mon Jun 11 14:06:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10457989 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 64EF66020F for ; Mon, 11 Jun 2018 14:10:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 519CE28592 for ; Mon, 11 Jun 2018 14:10:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E646286B8; Mon, 11 Jun 2018 14:10:51 +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 046C1285EE for ; Mon, 11 Jun 2018 14:10:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65CF36B0293; Mon, 11 Jun 2018 10:07:07 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5E7D06B0295; Mon, 11 Jun 2018 10:07:07 -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 463B86B0296; Mon, 11 Jun 2018 10:07:07 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f69.google.com (mail-pg0-f69.google.com [74.125.83.69]) by kanga.kvack.org (Postfix) with ESMTP id F1D986B0293 for ; Mon, 11 Jun 2018 10:07:06 -0400 (EDT) Received: by mail-pg0-f69.google.com with SMTP id k193-v6so6634986pge.3 for ; Mon, 11 Jun 2018 07:07:06 -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=oTHiFdNe4Vn6UitekWmDmg9p/jcGgir3VQorWtPf2OU=; b=eduhrhYgAr5HgWAErGh7qm0upn55BhPvRvsZVcfDRcdZHpzYe04cLd5kmyAizCit5z V4NnIzuClqnC6zGRb3/urpJoGLEpG+Af7s5K3EbECLaGWojM3v+uU3dtM7yaRdItJQfc tKePXIWESXIeRVHNxkOY/lXgqAxR8gMhZbKnB7HsBBE+N4L1BJf+DHh0+ZS8fntMIRWx 7dluU8dV/DUYaR2C6SmwOD5aXTWZ4JmDLwiLehXUNlGjbS/lk3bR0xusMOLwussU5AhJ 4tCv5PkXrnt3DvH0+S35bWCDy7jEODqCaJjXn7gQW5ukV9myLxkTSGSNsIj1MShjNsKW X6cQ== X-Gm-Message-State: APt69E095mwt63JqjHtQkaF1yQjRGfhNNInL25KS0W1nNAjbjtqTfQZA lyCcaiLsAC/oMqaBdLXWPIiIx7bVY7lYPG5rhHJT28WUj04GE4CYRLh19rToL6t25SxBq/M/vT2 15a5/UGTpGS4czkmnuN12ccXHDu/LYJVnunOMlVzvUd0nY6Z2OsEKlXABgU+gV46BHA== X-Received: by 2002:a63:5f0b:: with SMTP id t11-v6mr14824200pgb.79.1528726026665; Mon, 11 Jun 2018 07:07:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLfD0ydpmy/lN2labJhshBLShZGci4hfnLZohVVZeUg4YWPaI9+ciqKrh3XU4G7qbY+cQ4f X-Received: by 2002:a63:5f0b:: with SMTP id t11-v6mr14824159pgb.79.1528726026077; Mon, 11 Jun 2018 07:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528726026; cv=none; d=google.com; s=arc-20160816; b=QtFDFrrxlUNqSYUcG5HIdrm2l964EVguToawpRElMHmSj/wim3O9Q1geKqMDeZRBcS BEr1pxfXgIKd1nWoJsAzl3fVJOXC2gJMR+PW9jP1n7dtXsN4Em8cSncmwYIOfoOBboLP xwy++0BiSYDj6IRxMPFZfRe3R6XSIvKUCu940ZsMbtOOw9s8oGryWxPj6SECNtFImI4d Rwcmasx7wVEIE+rkaoD9vxyeSc4rm50aN/L2Fm2LYVH/1tXcofrLApCtkQFWWjZP6KPn 3GRmiTdMAJoUZCKbmAneWJl5VyMER2tlV9T+blCUmztoiQrwbFJXmE2RK8Gem4sjyVWe my2g== 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=oTHiFdNe4Vn6UitekWmDmg9p/jcGgir3VQorWtPf2OU=; b=sBjQVUw8v6jwXjOCcOoj2ThUS7DZbinHCrziYfPYAjAYsEfypyfKNLQDOvDqeR/mM4 ZOcmbFWJp4pV812mebpaVQjuTtCgD59g+83zpoE5rHIzKYSKARJXq98t5za1BLDlDhZX ntPefsSQnq9qpzSwIEYFrZpINLGgp1rMITqN4oFj7GZdlCIV/6ixm8jBAoQmUCZGqtiK G5Rxe5SkLvQ50EcuYfMnElkWzU+Bil0qbyqkBGSBzyMgPJKq2Z+3Ay91Yeu7gXpBOAA4 qofXHEBjMx2mItYiffg1R860rjlztQ3yrPRd7FtDztI+Ip6mgivPkxt3F+10xyEjJdmU 47UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Voy8qDga; 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 b37-v6si64237330plb.377.2018.06.11.07.07.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jun 2018 07:07:06 -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=Voy8qDga; 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=oTHiFdNe4Vn6UitekWmDmg9p/jcGgir3VQorWtPf2OU=; b=Voy8qDgaiHz4YuIZATm3+m9j7 VmoYUsTWRN+oCLYOpbsfoZuvK6VneyZOgM2YrCokdEjf93cHQtIVgby73oscjYMUVTwJPLKkbMu+Y zNt3zh/2KJBq/JTnmrU3M10/+qZmD5RegS7dqd4un7dYmw7qraGg0o/YpHHHg2BcBuwPQbAwNOIqZ kBgLCBE4UZ+msZFEle9AfKaZlGfsRH2GEkT4zwfj/1EYM+lvcfGy9Jt/UKMmEfftW8HYTuZWuVNoX D35yUymwUPu9MoAAXUgPj49FeRr1nJCRtspS0LtgqpinlxDdPBIYXxQNt9EOW6/7cG+cPc5mPr7Yp C37CYV7Vg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSNTN-0004uW-69; Mon, 11 Jun 2018 14:07:05 +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 52/72] shmem: Convert shmem_partial_swap_usage to XArray Date: Mon, 11 Jun 2018 07:06:19 -0700 Message-Id: <20180611140639.17215-53-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 Simpler code because the xarray takes care of things like the limit and dereferencing the slot. Signed-off-by: Matthew Wilcox --- mm/shmem.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 9dbbdd5dee30..bffb87854852 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -679,29 +679,19 @@ static int shmem_free_swap(struct address_space *mapping, unsigned long shmem_partial_swap_usage(struct address_space *mapping, pgoff_t start, pgoff_t end) { - struct radix_tree_iter iter; - void __rcu **slot; + XA_STATE(xas, &mapping->i_pages, start); struct page *page; unsigned long swapped = 0; rcu_read_lock(); - - radix_tree_for_each_slot(slot, &mapping->i_pages, &iter, start) { - if (iter.index >= end) - break; - - page = radix_tree_deref_slot(slot); - - if (radix_tree_deref_retry(page)) { - slot = radix_tree_iter_retry(&iter); + xas_for_each(&xas, page, end - 1) { + if (xas_retry(&xas, page)) continue; - } - if (xa_is_value(page)) swapped++; if (need_resched()) { - slot = radix_tree_iter_resume(slot, &iter); + xas_pause(&xas); cond_resched_rcu(); } }