Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4254778imm; Mon, 11 Jun 2018 09:18:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL6Ii37pto9RtJUsbkNNdyRNa1eMTywTPdqOII+Qo7ZX10nJ6IfJXPBgv1HNIptKkN9vXe4 X-Received: by 2002:aa7:8004:: with SMTP id j4-v6mr18160022pfi.174.1528733907008; Mon, 11 Jun 2018 09:18:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528733906; cv=none; d=google.com; s=arc-20160816; b=rNC6V0Jfs+5Dh4tzfKMTPZY68lMY9yv7tq1z5y1VQkBCZs4UgeRklUmh1NHqtSRvVC zSINkN0f0fU000aV/N1F2yLuxecELW/cD0ppOwf476qr8MadCANm0RMcrSHvbzMuexjZ sgKuAWgWhjKOjb2y0Zy8KOcIHdSHsUO7V88vDPJQYneobK9QT2y+i/qLhmCJkzNFO63B NodIK1OIHl+3Ora3jAQQ3B/LjEmU/87CzZpsRRDGh/pI1HNteLOQLMI5fZhXt++tCdNH jthkC69gG50GSDNaySfMKBJFEBe8NtfXLjX1EDNzV9HrURWliMX5jWufUcM5K7FT1WI3 JCEg== 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=SEKhh9tEySLT3DK6sNrlXzWkfXE7JM5uLwDQy4eqfzg=; b=AnLV+QArnXWyM9UVbVyN4/h+xGIetc3z5wXMx4D2PfzPvMu7EuG49vZpN40XFEFI+x CAU31SrniLB0bahCxJ4MAVKN+6oN6pQ0y2gbG4VqI0tmamx186MwgF9G6Tv2ZJenNG69 ps+dU5R16il9872o6/nDW5SAxDUH4FNq6+Icx/RNqRLGUeVdIwzxPdzpmTpUE+BufHvv 4ppzAaV8OjsVUT214ROK+MyoZA6HGc6B07bu1fuw1MByigIElBUKfjda7TkjMooJqn2O Qvx4cBH5g/lyUf5yndJtz/B6RET2KsJj6tMN2njL1yo8zEmz1rvWmWlq/zWzbowM8mSy vxIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=RnaMWJcS; 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 m9-v6si13304904pgr.148.2018.06.11.09.18.12; Mon, 11 Jun 2018 09:18:26 -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=RnaMWJcS; 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 S934341AbeFKOWX (ORCPT + 99 others); Mon, 11 Jun 2018 10:22:23 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:45438 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933500AbeFKOGx (ORCPT ); Mon, 11 Jun 2018 10:06:53 -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=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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.17.1