From patchwork Mon Jun 11 14:05:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 10457927 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 D8B2E6020F for ; Mon, 11 Jun 2018 14:08:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C794F28434 for ; Mon, 11 Jun 2018 14:08:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB4BF28475; Mon, 11 Jun 2018 14:08:49 +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 40A7B28434 for ; Mon, 11 Jun 2018 14:08:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 79A786B027E; Mon, 11 Jun 2018 10:06:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7204D6B027F; Mon, 11 Jun 2018 10:06:55 -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 5EE916B0281; Mon, 11 Jun 2018 10:06:55 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f70.google.com (mail-pg0-f70.google.com [74.125.83.70]) by kanga.kvack.org (Postfix) with ESMTP id 126356B027E for ; Mon, 11 Jun 2018 10:06:55 -0400 (EDT) Received: by mail-pg0-f70.google.com with SMTP id g5-v6so6578804pgv.12 for ; Mon, 11 Jun 2018 07:06:55 -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=SEKhh9tEySLT3DK6sNrlXzWkfXE7JM5uLwDQy4eqfzg=; b=oxu6D2RVP707SAOZna5WQ33Mdt33RGORtqjeTQkQzZkO0Naxcei57p1lhV2ynDjSaZ eQerqvbpNGXbcQDOoI1Yc9Jit+JFhlK9T5A3aOau8Foj1/FosCqJRDE7akB8jgZIOzDR VjJ6lKVE+E0hCU9Ivvod2rGDXz6EQrC0HvwQH3nCdvVQyfwULtISD/9hg1QMIxQlzHB3 NdgPMOE8sqj0nSi1qemCdTD4EelShQdNDTKt7uGOcRiHHUd/kCoYiwBclkxDR62zGfSr bd8wL3je+aF/R/hOzrz6w07xzOudIuifOpINOgvbOmpDhTXHxVY8SuOrnSGmNj6b3UEb TQHg== X-Gm-Message-State: APt69E0dj8kogvNCGXnYxWuVGut3CQdIzZMLx7DHZhBN3262Gmrr1z+h 58vFzTyEa7ndjdJtF965xXKzw+3J9HTjrlGHng9JFEuCXZurViuJScJ1nBXKRLRq4AAKbtLuMgv QVqitrETG650w7nkh2ST4cJXDVme4FfkybvPe2CWKFj1mSLbEpH8TczFbfkNTJyBncw== X-Received: by 2002:a17:902:3381:: with SMTP id b1-v6mr19012581plc.248.1528726014760; Mon, 11 Jun 2018 07:06:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKmPlzX9C4H4f0RHYASskLCVI/978FBSb/nfr0C2C+vFuFMspwEO/qvWE9o6mTFB135mwPj X-Received: by 2002:a17:902:3381:: with SMTP id b1-v6mr19012510plc.248.1528726013682; Mon, 11 Jun 2018 07:06:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528726013; cv=none; d=google.com; s=arc-20160816; b=Dcr5dd567HgWSxFBIu5YFCzzFksiBBH3Alb5m9dMVPIw7G76G9vBP1YdsFeWSvoO1c hD1q4/rGNqRzeZqKha1KDUTnhVWgN8MrZoIcY6pVcKnUCs3V2BA7l5dgz7fz8LF8BBzr +SOzzdCmBBYsUmOXTvKu/tc4vzbDk7NgtXLOs7Z4Vs9jpU9JSHq4jrUDp24ix1pU1zeH F/N+bls1vvPq5mghO9838APEs9QEqlJOcI2oAWEfvy87gG8t5Dk1iiBN+Kb6GzT3d7bK /pF+R73uwA0QR8+TjWLrlBlqdWBHazLqWnO5sVQhsVUE3s959BNZ9F/MPny4VLGy4EUP FWJQ== 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=SEKhh9tEySLT3DK6sNrlXzWkfXE7JM5uLwDQy4eqfzg=; b=ViioZfctm1OVegk7zm9jF2PPzOJ11jMPdf7hg4eGQHpUk7gqppM22T1r+KyJT3YM4g mYMqYthhN2X5nZWHoGWwl1BqAPnzSBcsCjOHwXk9OkMTZMd2OvCEZSV+JQf/vld6m8iT eJdnmI3W3SPahpuPlt7+NoGulu+mWkRWgu2SYFlyty3tjPv+juSWHZLLerewt3N0Af0m 96Rg50sd0FNXVijxWUIWmcPMBu2/wAlg7d5pWjyZlZK2CTPB2K2X58jpmJzNuwa4LEHn tiz9SCY44x/ESsyd5RV24SJ7/yE/jZ/G0Hei/rI2TuvKbbEK/2FmvvORO9o1u79cib3Q 23BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=RnaMWJcS; 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 v11-v6si62952812plp.25.2018.06.11.07.06.53 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jun 2018 07:06:53 -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=RnaMWJcS; 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=SEKhh9tEySLT3DK6sNrlXzWkfXE7JM5uLwDQy4eqfzg=; b=RnaMWJcSdqsx60dv3lyYDZitM 5csUaOl0AXVOY8v8s2KM5XzAVAZSMjL6zE3g9K3rTdSwdmAGoCuoIxxTk5GwdGNDtWbvE1rxNMzGk NdT+Nsy4rWu0sDmy3fmNfPNPlMX+1/jwILHUDXy8KgdeUBdPCw2+3oJecaPl9+OUANANTeKXc9rfx nNfD/eqt6Fs2ulrlfonm+hsgvtMprDoqdbpgE28p+ChxnO1REMALI2nusYPRswbx212AvorDUlZzb Iz64YO4A4o8aqYJAgBtn/PftGs/aIIVd2Scb2cO2Ku5ptS/GxvJ0cBy7qcb/vozqyr84iY2yMVK8R pQScC4V4g==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSNTA-0004iC-RQ; Mon, 11 Jun 2018 14:06:52 +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 30/72] radix tree test suite: Convert regression1 to XArray Date: Mon, 11 Jun 2018 07:05:57 -0700 Message-Id: <20180611140639.17215-31-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 Now the page cache lookup is using the XArray, let's convert this regression test from the radix tree API to the XArray so it's testing roughly the same thing it was testing before. Signed-off-by: Matthew Wilcox --- tools/testing/radix-tree/regression1.c | 58 +++++++++----------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/tools/testing/radix-tree/regression1.c b/tools/testing/radix-tree/regression1.c index 0aece092f40e..b4a4a7168986 100644 --- a/tools/testing/radix-tree/regression1.c +++ b/tools/testing/radix-tree/regression1.c @@ -53,12 +53,12 @@ struct page { unsigned long index; }; -static struct page *page_alloc(void) +static struct page *page_alloc(int index) { struct page *p; p = malloc(sizeof(struct page)); p->count = 1; - p->index = 1; + p->index = index; pthread_mutex_init(&p->lock, NULL); return p; @@ -80,53 +80,33 @@ static void page_free(struct page *p) static unsigned find_get_pages(unsigned long start, unsigned int nr_pages, struct page **pages) { - unsigned int i; - unsigned int ret; - unsigned int nr_found; + XA_STATE(xas, &mt_tree, start); + struct page *page; + unsigned int ret = 0; rcu_read_lock(); -restart: - nr_found = radix_tree_gang_lookup_slot(&mt_tree, - (void ***)pages, NULL, start, nr_pages); - ret = 0; - for (i = 0; i < nr_found; i++) { - struct page *page; -repeat: - page = radix_tree_deref_slot((void **)pages[i]); - if (unlikely(!page)) + xas_for_each(&xas, page, ULONG_MAX) { + if (xas_retry(&xas, page)) continue; - if (radix_tree_exception(page)) { - if (radix_tree_deref_retry(page)) { - /* - * Transient condition which can only trigger - * when entry at index 0 moves out of or back - * to root: none yet gotten, safe to restart. - */ - assert((start | i) == 0); - goto restart; - } - /* - * No exceptional entries are inserted in this test. - */ - assert(0); - } - pthread_mutex_lock(&page->lock); - if (!page->count) { - pthread_mutex_unlock(&page->lock); - goto repeat; - } + if (!page->count) + goto unlock; + /* don't actually update page refcount */ pthread_mutex_unlock(&page->lock); /* Has the page moved? */ - if (unlikely(page != *((void **)pages[i]))) { - goto repeat; - } + if (unlikely(page != xas_reload(&xas))) + goto put_page; pages[ret] = page; ret++; + continue; +unlock: + pthread_mutex_unlock(&page->lock); +put_page: + xas_reset(&xas); } rcu_read_unlock(); return ret; @@ -145,12 +125,12 @@ static void *regression1_fn(void *arg) for (j = 0; j < 1000000; j++) { struct page *p; - p = page_alloc(); + p = page_alloc(0); pthread_mutex_lock(&mt_lock); radix_tree_insert(&mt_tree, 0, p); pthread_mutex_unlock(&mt_lock); - p = page_alloc(); + p = page_alloc(1); pthread_mutex_lock(&mt_lock); radix_tree_insert(&mt_tree, 1, p); pthread_mutex_unlock(&mt_lock);