From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B191F27703 for ; Wed, 10 Jun 2026 01:13:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781054028; cv=none; b=CmZn7IySV9iwItoIV8oLR+AUZptuDbPhx37GaraI+FgVqiwLwLKb+17J2DF6r86oZDJZYZ9sgM+kmdCnQ42MR6TWX8ts2BwLWqmPjsouKn3ExLSA1E2qVubXZxFTGc55jtZslj97xp/CxraeCjbwerG9eEQIdBj0/7VILJTjdZ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781054028; c=relaxed/simple; bh=6ntCMdtUUQVLjJ/wbsyGaRjhmFVnFJFsOROHsHT3v2k=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=oKIvqgM2qbzlWsoimX1lR4sdcYdT79FiYf+BiHawq9CbSUR+Js0p5VNuSuP7TgwXcR/vALwx6LEOzJ55t11/Tjc5Ozkkq3pRFDs5AFhW834E7KnTpRMJpErAxPipV0MO7FstibVS4ryeUIl/6nLcPaarfihXYa56WoJYCnz+v4U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=ozKOuWnT; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="ozKOuWnT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 376441F00893; Wed, 10 Jun 2026 01:13:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1781054027; bh=5Yh2S7a+Ck+nt6dLdy2ajYrnAckvV99wv5c//vOBy8M=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=ozKOuWnTm7U5BCEqkXbMcAjQzvHt9hc6M5g9U7aIaQ/7eEJ03VwVlKFq/74VrsIs8 obgW43wT3uC9uVxrncRuGgHzO8XZzDPXVZ3ZUw1mj99cW24osZDbKPSHbk8TVT7oPq 2wFT2sEJquRf1nvd11lLQvhmsqlKgUhhyGVB1rck= Date: Tue, 9 Jun 2026 18:13:46 -0700 From: Andrew Morton To: Samuel Moelius Cc: linux-kernel@vger.kernel.org (open list:LIBRARY CODE) Subject: Re: [PATCH] lib: interval_tree_test: validate benchmark parameters Message-Id: <20260609181346.dc7a09e0b23b8bd6847d6454@linux-foundation.org> In-Reply-To: <20260609005446.1241288.1525a5964698.interval-tree-test-small-max-endpoint-div0@trailofbits.com> References: <20260609005446.1241288.1525a5964698.interval-tree-test-small-max-endpoint-div0@trailofbits.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 9 Jun 2026 00:54:47 +0000 Samuel Moelius wrote: > The interval tree runtime test accepts module parameters that are later > used as divisors while generating randomized intervals and while > reporting average timings. For example, max_endpoint=1 makes the > generated interval end value zero and the next modulo operation divides > by that zero value. > > Reject non-positive counts and require max_endpoint to provide at least > one non-zero generated endpoint before the test allocates state or > starts the benchmark. That makes sense, thanks. > --- a/lib/interval_tree_test.c > +++ b/lib/interval_tree_test.c > @@ -311,6 +311,27 @@ static inline int span_iteration_check(void) {return 0; } > > static int interval_tree_test_init(void) > { > + if (nnodes <= 0) { > + pr_warn("nnodes must be positive\n"); > + return -EINVAL; > + } > + if (nsearches <= 0) { > + pr_warn("nsearches must be positive\n"); > + return -EINVAL; > + } > + if (perf_loops <= 0) { > + pr_warn("perf_loops must be positive\n"); > + return -EINVAL; > + } > + if (search_loops <= 0) { > + pr_warn("search_loops must be positive\n"); > + return -EINVAL; > + } > + if (max_endpoint < 2) { > + pr_warn("max_endpoint must be at least 2\n"); > + return -EINVAL; > + } > + > nodes = kmalloc_objs(struct interval_tree_node, nnodes); > if (!nodes) > return -ENOMEM; Perhaps this can be done within the __param macro: #define __param(type, name, init, msg) \ static type name = init; \ module_param(name, type, 0444); \ if (name <= 0) { \ pr_warn(__stringify(name) " must be positive\n"); \ name = init; \ } \ MODULE_PARM_DESC(name, msg); I'll add your patch as-is. If you prefer the above approach, please send along a replacement patch.