Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp578442imu; Thu, 20 Dec 2018 01:44:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/WdjBtPMsHYWXNfpR1uC76rMu8O1Je4US8NtcZ5SuKStsslYSQwimb4rF/zR0+VL5LxRSYE X-Received: by 2002:a63:295:: with SMTP id 143mr21940564pgc.362.1545299062037; Thu, 20 Dec 2018 01:44:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545299062; cv=none; d=google.com; s=arc-20160816; b=s/KnX4MFXIzIXisMJDBUCzxPYRQUUK1dsvDGrWuEBrNLS6bMTlQYX071zX/ZVzLfUC baJpcg/VjxB44WWkUgd7wShRZrYlXwzCzBr1cufWpEv6ATOwfOZQ25K6z7VckmpNsByP rKTntj23iZed6iThWIu5GfHMfKiOF8Wcjdo/3JjubJjzASLNyaLqB/V36y/NuE39aCxi IWfO4JuS9tE6pVoFJRTBn8M4l3n62QuLw1L5I2z7vgklnIbxa76TVKYiTZ4joxFIf5ln hzPR8Qzfe939/zRKkkUGOc1c770a8dBJJyUw6F1FHcyCAMgWPXoN4DoWCZ5d0bund2pR jPAQ== 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=eH0OLKeTb4HRFKlIHhrQyxvQg9FSXfN0a2QQdsTzv+Y=; b=VvKJpA1cug9hkgG1QYDxro2Q69bnzI4kjG/SCN/XKXvwuB0SLyKKe8vYkxwHYK9Cx1 65u5LBqkBst54PcSn3Dysp1yqxTHRPDXyU5awAnGGlY8FxsM4HxGzT/zJBCWt6wFgQ6A 64w5DmkJE9STrICBD8/l7SsqBlnwPeyu3MBwR0AG3a1F2O7p1F3HPph54aLE8jXY5DnW pDl5LbR0ChZ1pz0CvXIzjA9PXdiz+NHAInVORU54UFG3rw98qroHBD0Q/7MOtYcnm5vj ZuIJZ8AVxtW7vZcqirO3vtsQjJM3Z72RKuuhfH55LMOyNdYUk6wW9DWuvgqUPNNVK4Rs G+2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=J5U2FjBh; 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 y11si17827558plg.236.2018.12.20.01.44.05; Thu, 20 Dec 2018 01:44:22 -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=J5U2FjBh; 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 S1733259AbeLTJmo (ORCPT + 99 others); Thu, 20 Dec 2018 04:42:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:51502 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731567AbeLTJXO (ORCPT ); Thu, 20 Dec 2018 04:23:14 -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 DE1AF20656; Thu, 20 Dec 2018 09:23:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545297793; bh=mUjuyG5x8O8H2jaaQW6uERta2Ow/KvXx0VcoF348hew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J5U2FjBhd6WgSLEmg7airfPrKQuDM8tA2RBy3TDKkK1S9Hr+Gp5cH5v7crZSKwFTd dMX6/+WvV/lheiUkvNZDza+qbTdw5WRsl9EGVzGYCa3FTIVI6JEJCBml5pvJYkfwjZ KmE1+IUUpZoHMU1Z9kBA1ZrHe/OL2B1xpkTNq92E= 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 06/61] lib/interval_tree_test.c: allow users to limit scope of endpoint Date: Thu, 20 Dec 2018 10:18:06 +0100 Message-Id: <20181220085843.986680797@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 a8ec14d4f6aa8e245efacc992c8ee6ea0464ce2a ] Add a 'max_endpoint' parameter such that users may easily limit the size of the intervals that are randomly generated. Link: http://lkml.kernel.org/r/20170518174936.20265-4-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 | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/interval_tree_test.c b/lib/interval_tree_test.c index bababcf7ffdd..222c8010bda0 100644 --- a/lib/interval_tree_test.c +++ b/lib/interval_tree_test.c @@ -17,6 +17,7 @@ __param(int, nsearches, 100, "Number of searches to the interval tree"); __param(int, search_loops, 1000, "Number of iterations searching the tree"); __param(bool, search_all, false, "Searches will iterate all nodes in the tree"); +__param(uint, max_endpoint, ~0, "Largest value for the interval's endpoint"); static struct rb_root root = RB_ROOT; static struct interval_tree_node *nodes = NULL; @@ -41,18 +42,20 @@ static void init(void) int i; for (i = 0; i < nnodes; i++) { - u32 a = prandom_u32_state(&rnd); - u32 b = prandom_u32_state(&rnd); - if (a <= b) { - nodes[i].start = a; - nodes[i].last = b; - } else { - nodes[i].start = b; - nodes[i].last = a; - } + u32 b = (prandom_u32_state(&rnd) >> 4) % max_endpoint; + u32 a = (prandom_u32_state(&rnd) >> 4) % b; + + nodes[i].start = a; + nodes[i].last = b; } + + /* + * Limit the search scope to what the user defined. + * Otherwise we are merely measuring empty walks, + * which is pointless. + */ for (i = 0; i < nsearches; i++) - queries[i] = prandom_u32_state(&rnd); + queries[i] = (prandom_u32_state(&rnd) >> 4) % max_endpoint; } static int interval_tree_test_init(void) -- 2.19.1