Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp724160imu; Thu, 20 Dec 2018 04:25:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/VoxmV/WKzik9tugWwk7m+xk/06izhnXWw8ktFPOx7inuFM941nZvQZ8c5tvvlO0ps7tpCG X-Received: by 2002:a17:902:7d90:: with SMTP id a16mr22832189plm.249.1545308742704; Thu, 20 Dec 2018 04:25:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545308742; cv=none; d=google.com; s=arc-20160816; b=XXqBLgIXSUINXnhEDYE70UOTvaoqR3VGkIgmEB9UnEZWJab+a4vBTUx5DLNugySsHQ Wv3jX/oAAnjDR9JOPdTh+9Kjoyy7MKQmx4z0Il0GYpaNl7HQUT+8JG6zZ81OWiuhgpZK N1A8pMavcF3b97alRaT92CD79jLflbwEcncuSxJB8zEy6YmtJuy29iS0HmxHC9TiBvI2 Ikz1T8zmTA2C0hLHbzmNzrsJlyidyE4GibJx4ElOiCBnOsiOvdf3YB9Dr6au66NvSl5Z YJoaLqTroZgIo79zJUoz/08ke26AP42FOMUgUP0f/5iwoUww/7rQD+93GIxCsYYUf8bR koCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Qw2m+2vqLfJeZUVGEAtyUHi5QBR33/WCd99L7A3AoiU=; b=XJSomZ+6WFl2WNvJAFtAo7Wh3rrNHdaYtZbp+OeQO26/hcvy3S/EwAshPLGmQNHQUG E/5IIH0x5pqB09SLcuZtRSgyu+uiVHwcKHy7dbVpHhiPC1FMcschzgS5pdw9gAF8MavT BcQY5ILtB7/1Uq7fArcV0fpZsEcgttwpvnrr42cDy++vrgqngz8U1G2WQxhLD/PT23m4 3sX0flXd4UpPFaYgpUNXpyrH7w/OJYXRh84qtLtO3y+TAqCMY9TCfpQ+dmZhCDiterYg nw0l9RQ2GODn7/RYco40DKYFnNHcq0wVIMXUJVqOh56pGQXwIPqSyyVKVCyNgqnxm4Rm 54sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YuttTWDz; 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 b11si18761856pfo.240.2018.12.20.04.25.23; Thu, 20 Dec 2018 04:25:42 -0800 (PST) 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=pass header.i=@kernel.org header.s=default header.b=YuttTWDz; 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 S1731465AbeLTJXG (ORCPT + 99 others); Thu, 20 Dec 2018 04:23:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:49748 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731458AbeLTJXD (ORCPT ); Thu, 20 Dec 2018 04:23:03 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 05A1D20656; Thu, 20 Dec 2018 09:23:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545297782; bh=4WM9bWTzcLOsjQY7SaA/6rPAg8t0vVGHIe+6vArNvhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YuttTWDzrtjljSTc3K6ZxbWzTKMpgSpVAzifp2v7q8AMnnqP71h2vo7gA0AEH1a+b q93sjOXRNfN+xe3k4vpg1xBtDqFXxn0M+Oe5JTT6rNo8A7bUDNX8JPF7cgJruNInyD vyswEUPZxmRMFY7ab9Ua5jgU+h/WwH1XQhdWVEk0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Davidlohr Bueso , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.9 02/61] lib/interval_tree_test.c: make test options module parameters Date: Thu, 20 Dec 2018 10:18:02 +0100 Message-Id: <20181220085843.840433508@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20181220085843.743900603@linuxfoundation.org> References: <20181220085843.743900603@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit a54dae0338b7f01eb0f9c7571fb9b74f791d1c6b ] Allows for more flexible debugging. Link: http://lkml.kernel.org/r/20170518174936.20265-3-dave@stgolabs.net Signed-off-by: Davidlohr Bueso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- lib/interval_tree_test.c | 57 ++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/lib/interval_tree_test.c b/lib/interval_tree_test.c index 245900b98c8e..1093f0496d5e 100644 --- a/lib/interval_tree_test.c +++ b/lib/interval_tree_test.c @@ -1,16 +1,25 @@ #include +#include #include #include +#include #include -#define NODES 100 -#define PERF_LOOPS 100000 -#define SEARCHES 100 -#define SEARCH_LOOPS 10000 +#define __param(type, name, init, msg) \ + static type name = init; \ + module_param(name, type, 0444); \ + MODULE_PARM_DESC(name, msg); + +__param(int, nnodes, 100, "Number of nodes in the interval tree"); +__param(int, perf_loops, 100000, "Number of iterations modifying the tree"); + +__param(int, nsearches, 100, "Number of searches to the interval tree"); +__param(int, search_loops, 10000, "Number of iterations searching the tree"); + static struct rb_root root = RB_ROOT; -static struct interval_tree_node nodes[NODES]; -static u32 queries[SEARCHES]; +static struct interval_tree_node *nodes = NULL; +static u32 *queries = NULL; static struct rnd_state rnd; @@ -29,7 +38,8 @@ search(unsigned long query, struct rb_root *root) static void init(void) { int i; - for (i = 0; i < NODES; i++) { + + for (i = 0; i < nnodes; i++) { u32 a = prandom_u32_state(&rnd); u32 b = prandom_u32_state(&rnd); if (a <= b) { @@ -40,7 +50,7 @@ static void init(void) nodes[i].last = a; } } - for (i = 0; i < SEARCHES; i++) + for (i = 0; i < nsearches; i++) queries[i] = prandom_u32_state(&rnd); } @@ -50,6 +60,16 @@ static int interval_tree_test_init(void) unsigned long results; cycles_t time1, time2, time; + nodes = kmalloc(nnodes * sizeof(struct interval_tree_node), GFP_KERNEL); + if (!nodes) + return -ENOMEM; + + queries = kmalloc(nsearches * sizeof(int), GFP_KERNEL); + if (!queries) { + kfree(nodes); + return -ENOMEM; + } + printk(KERN_ALERT "interval tree insert/remove"); prandom_seed_state(&rnd, 3141592653589793238ULL); @@ -57,39 +77,42 @@ static int interval_tree_test_init(void) time1 = get_cycles(); - for (i = 0; i < PERF_LOOPS; i++) { - for (j = 0; j < NODES; j++) + for (i = 0; i < perf_loops; i++) { + for (j = 0; j < nnodes; j++) interval_tree_insert(nodes + j, &root); - for (j = 0; j < NODES; j++) + for (j = 0; j < nnodes; j++) interval_tree_remove(nodes + j, &root); } time2 = get_cycles(); time = time2 - time1; - time = div_u64(time, PERF_LOOPS); + time = div_u64(time, perf_loops); printk(" -> %llu cycles\n", (unsigned long long)time); printk(KERN_ALERT "interval tree search"); - for (j = 0; j < NODES; j++) + for (j = 0; j < nnodes; j++) interval_tree_insert(nodes + j, &root); time1 = get_cycles(); results = 0; - for (i = 0; i < SEARCH_LOOPS; i++) - for (j = 0; j < SEARCHES; j++) + for (i = 0; i < search_loops; i++) + for (j = 0; j < nsearches; j++) results += search(queries[j], &root); time2 = get_cycles(); time = time2 - time1; - time = div_u64(time, SEARCH_LOOPS); - results = div_u64(results, SEARCH_LOOPS); + time = div_u64(time, search_loops); + results = div_u64(results, search_loops); printk(" -> %llu cycles (%lu results)\n", (unsigned long long)time, results); + kfree(queries); + kfree(nodes); + return -EAGAIN; /* Fail will directly unload the module */ } -- 2.19.1