From patchwork Mon Jun 11 14:06:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10458029 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 CCC3B601A0 for ; Mon, 11 Jun 2018 14:12:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F4302856F for ; Mon, 11 Jun 2018 14:12:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85C102893E; Mon, 11 Jun 2018 14:12:44 +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 CD5ED286D7 for ; Mon, 11 Jun 2018 14:11:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D155A6B02A2; Mon, 11 Jun 2018 10:07:14 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C9DF76B02A3; Mon, 11 Jun 2018 10:07:14 -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 B41926B02A4; Mon, 11 Jun 2018 10:07:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id 68A706B02A2 for ; Mon, 11 Jun 2018 10:07:14 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id x25-v6so10303439pfn.21 for ; Mon, 11 Jun 2018 07:07:14 -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=YZEZhtidxbERQmqpIgTJPIyTZV3rzcBKGQfijbq6eAo=; b=F1TsboZt8pfRD0A6VEuFdiywkYGyxluishzq7YWTrGht0OLZhze4LnvK4YhPkR9pBO 70UMa4dDfQ7ms2/osjnUNz05wzTLcLhop8bPbdzaDIr3SicQKoyzVc6dVIy6eccVrZi2 usI7FOMqkkuW+leZYDIHyN8Twk7z31V3uJYmVu3d0aG/qoUJo2tNyrxB4A5lxNZg82UF TK5szU/QvhKT8dvxs15ZDXFDQoFro+j2SqbA0qkLQIAlYFI8vaLUpgrx92MiVgjT17VU WWVNZTiHr3ooGAjEghtELPLnihFSVe7mzd9fA/SZyDyQXD0Z4Krx+dI8qy/sW+DzEuq0 +YJg== X-Gm-Message-State: APt69E3BnoOxl3ATlL6v66wyG8OWt2X+t3FQO+GhjgKSpOrBuLiyRMpP zHMn3YcAwnVsKUfv4NFM9la0eCCB13uMPIuhPlzppbviGLUE73+D3+Sn0KjmQHRIrgAoHBpGwmm z2+oSup7pCDZ5wd/vD4JTbqgs2gNYQeKJEgo6BbXrvZvlnvaEyAKOMN/v4MybIleO6w== X-Received: by 2002:a62:9652:: with SMTP id c79-v6mr17955070pfe.114.1528726034110; Mon, 11 Jun 2018 07:07:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLJbYJcZBMohjuDg9p5hXko1I1BWxGFQKTA+yg1saaRsQKiE/eiAW7gs+Ikq7sUFSk9oBZ2 X-Received: by 2002:a62:9652:: with SMTP id c79-v6mr17955003pfe.114.1528726033272; Mon, 11 Jun 2018 07:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528726033; cv=none; d=google.com; s=arc-20160816; b=jH+PbViMIIbGMy8V3vSKWuKizkaWVF0wUgc3FNQEvtiPM3+6u/5J3cosrB/SIM336y jCpt3W7E+lOCYvHlPLMnkr6fFw/quv+TaE1TTw6xXkGrRf6Y76T/XirsDrwaUcKX4wuh YH83fPifI8BHcgGVO5RkRHX3U2ojHIgRQG1S/UoXEUAGBLEX9h9UN20snRT6jJ3S4sBn RFRZ3CtZyh2gJFaKrsEeyQkw5sGO6yea4m/jJxzg38cdXQV1i0gRfIqb5c1YpQcLdw6l bp2pfq5hAwj1tNfCDQ4XXPGkG8I79lseAZJXLjExHGx2EigdORIAQ3F45j1T56w6iAcQ JO1Q== 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=YZEZhtidxbERQmqpIgTJPIyTZV3rzcBKGQfijbq6eAo=; b=R+/uCdshTN+ILSXPAf8+KFkOdQJ7m9r/TILolLHHxiXWTy8/L67G9qSpa9mjmKCOa5 tCTEe3q+mTMZJbSXmM+DruWp3oy5YJgShb/eEpZU62qbzfC3C6Cn1UTouASy2GP1TQf5 HNRI+Y/HID67JjLkpXvqMaW6JXI7dWAvjcYVwGAN/dZjZQcPQfZUmzF0uihj4atBk0Mp aodG1363nMPVLYjcdgfXJeKF90DdEeXbqzlTiWPy/Ctd1+2eyk1fzGuV1cx3ikint12h zp3BdZNvDa1mwDoSP5WVACJDwgXgGlsQd4DyRR0u6Pkv46oYz3IlSVZhZBTKvxea7z2Y rkIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=LJNjD8aU; 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 l26-v6si24626318pfe.299.2018.06.11.07.07.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jun 2018 07:07:13 -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=LJNjD8aU; 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=YZEZhtidxbERQmqpIgTJPIyTZV3rzcBKGQfijbq6eAo=; b=LJNjD8aUGTWjXHythh3JGMmev DadDkFu9xiNsI+UxD/Dsb82sgXExm0x9/32u8bsG8kwv4EwcoWDD842fiRDgilchWtqkHQU/8vjSr 3OmSUKv0EUDPaWYsOTbizx8iQyTE02XtMS3ZlzT8KhtjEbjeMyhwANJd8YXmv1GfldWlRqBWMuABn y2BKT6VL3/YvsLoYABSGRcSlYKCPzgnsZxe9m2SXmgO2kBq9KtmegYM0Ajg49E4j3SH3Zrmu/4Zvs eWUms6flEVIJlQbeZZ5VzfYmet+roI8W6iiFGi4kD4NT4peqWhHo5mLGg6mqL2SXafXxpQLkB2jYc UAFgq/gfg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSNTU-00051x-6G; Mon, 11 Jun 2018 14:07:12 +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 64/72] dax: Convert dax_layout_busy_page to XArray Date: Mon, 11 Jun 2018 07:06:31 -0700 Message-Id: <20180611140639.17215-65-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 Instead of using a pagevec, just use the XArray iterators. Add a conditional rescheduling point which probably should have been there in the original. Signed-off-by: Matthew Wilcox --- fs/dax.c | 57 +++++++++++++++++++++----------------------------------- 1 file changed, 21 insertions(+), 36 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 1c9b736147d3..b8ed7bf32ba1 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -621,11 +621,10 @@ static void *grab_mapping_entry(struct address_space *mapping, pgoff_t index, */ struct page *dax_layout_busy_page(struct address_space *mapping) { - pgoff_t indices[PAGEVEC_SIZE]; + XA_STATE(xas, &mapping->i_pages, 0); + void *entry; + unsigned int scanned = 0; struct page *page = NULL; - struct pagevec pvec; - pgoff_t index, end; - unsigned i; /* * In the 'limited' case get_user_pages() for dax is disabled. @@ -636,13 +635,9 @@ struct page *dax_layout_busy_page(struct address_space *mapping) if (!dax_mapping(mapping) || !mapping_mapped(mapping)) return NULL; - pagevec_init(&pvec); - index = 0; - end = -1; - /* * If we race get_user_pages_fast() here either we'll see the - * elevated page count in the pagevec_lookup and wait, or + * elevated page count in the iteration and wait, or * get_user_pages_fast() will see that the page it took a reference * against is no longer mapped in the page tables and bail to the * get_user_pages() slow path. The slow path is protected by @@ -654,36 +649,26 @@ struct page *dax_layout_busy_page(struct address_space *mapping) */ unmap_mapping_range(mapping, 0, 0, 1); - while (index < end && pagevec_lookup_entries(&pvec, mapping, index, - min(end - index, (pgoff_t)PAGEVEC_SIZE), - indices)) { - for (i = 0; i < pagevec_count(&pvec); i++) { - struct page *pvec_ent = pvec.pages[i]; - void *entry; - - index = indices[i]; - if (index >= end) - break; - - if (!xa_is_value(pvec_ent)) - continue; - - xa_lock_irq(&mapping->i_pages); - entry = get_unlocked_mapping_entry(mapping, index, NULL); - if (entry) - page = dax_busy_page(entry); - put_unlocked_mapping_entry(mapping, index, entry); - xa_unlock_irq(&mapping->i_pages); - if (page) - break; - } - pagevec_remove_exceptionals(&pvec); - pagevec_release(&pvec); - index++; - + xas_lock_irq(&xas); + xas_for_each(&xas, entry, ULONG_MAX) { + if (!xa_is_value(entry)) + continue; + if (unlikely(dax_is_locked(entry))) + entry = get_unlocked_entry(&xas); + if (entry) + page = dax_busy_page(entry); + put_unlocked_entry(&xas, entry); if (page) break; + if (++scanned % XA_CHECK_SCHED) + continue; + + xas_pause(&xas); + xas_unlock_irq(&xas); + cond_resched(); + xas_lock_irq(&xas); } + xas_unlock_irq(&xas); return page; } EXPORT_SYMBOL_GPL(dax_layout_busy_page);