From patchwork Fri Feb 10 21:15:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: andrey.konovalov@linux.dev X-Patchwork-Id: 13136456 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 259ACC636D4 for ; Fri, 10 Feb 2023 21:17:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA58D6B018C; Fri, 10 Feb 2023 16:17:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 969966B018E; Fri, 10 Feb 2023 16:17:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8323F6B018F; Fri, 10 Feb 2023 16:17:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 734286B018C for ; Fri, 10 Feb 2023 16:17:18 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 3E9474125F for ; Fri, 10 Feb 2023 21:17:18 +0000 (UTC) X-FDA: 80452642956.15.515A509 Received: from out-223.mta1.migadu.com (out-223.mta1.migadu.com [95.215.58.223]) by imf22.hostedemail.com (Postfix) with ESMTP id 4A52DC0012 for ; Fri, 10 Feb 2023 21:17:15 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=c+1AHXrK; spf=pass (imf22.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.223 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676063836; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=GEKMsp8Q42qNZP01Wy8jBcM+2lagQkM9mc2pThcVWag=; b=J2GKq+85mhHVsqS9SQ90lveMPuQ4c/LkKt/rW8YAjehcUZusm/LNJGxHuqsABympRedvdI 9I6we8xEaf8rloFbjMeYbHP2YJ7TOPN38NjAPYToK1clKYAvJ2yuiARj2+9IZSceyeAgEo IaZsqbEuqTwFMJ7K2XUReM9cIgDTC6Y= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=c+1AHXrK; spf=pass (imf22.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.223 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676063836; a=rsa-sha256; cv=none; b=kZQeFbyqiQGdIwaAlycxPUIgWKpe1d1Riv21bV5PWtVzxlqdH27Ut/GGkuO514JvG1xtzX 8EozSUwVS34vIXbZz7vmjqlTTqQ7nfMj4MTiGXItkc1Ex6lcwSSOzgcADR8y7gwzeE4yKs aeOCW7Fdow5ZmrSwlzmb0/49GdpEwI0= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1676063834; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GEKMsp8Q42qNZP01Wy8jBcM+2lagQkM9mc2pThcVWag=; b=c+1AHXrKHUEP1+bsNrE9ZwOjSb/qQQiGk2OxmWYCZ8OMAfHwDap2ap2QjPrAyQKgJaVNpk t5NCczUJqVa0kDs1WFAq8iet967tqgR9YBckizmQ28+6qrCOK9T0sdvJgs3Uvs6IURwelC 6z3t4aQyjMsr+yK+IdYsE2bJpkl5puw= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH v2 08/18] lib/stackdepot: rename hash table constants and variables Date: Fri, 10 Feb 2023 22:15:56 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Stat-Signature: 33fhufm5w63jgoies1mcuaf7th9zuisc X-Rspam-User: X-Rspamd-Queue-Id: 4A52DC0012 X-Rspamd-Server: rspam06 X-HE-Tag: 1676063835-597769 X-HE-Meta: U2FsdGVkX1+dAFhYK7YNF4ahvYxLuhquQoX5poMS3k00crGuS4yYRL1wMYvoWIagPBLDlV2jR/BJVDzGiF8wB0dxZB8LRjRnT3zKYiYHGJmFd7zSSSR2H0z5ocytwfHl4kc98EaGHOBb1JcZKI/QFvnze5q9Fi60xSodcY3dyaQ+KRPy/ufsS845ylWIYmG5y0x1ziskXXS+N60y2ilddAMQA96qW8cHC7MR6J7ov28ntARJJ8iVY4/DaaQb5KO7zCrAHoRjR8obS1SA1COfBfsLHO+NDP5Cms9w/40fVUEWwr3ux4YUvvDUDssJML/hRXalS5/zOJHZsF8cPkCdXx+3gUV7Kl/jjNwzIiyg08qny6+PqYdxJ/L1W4Xu2iZZc0aKzQY/x/IaqrSHl7izFzjN8OK+Kvl4Su0ZH8gkHi1hZ5VWyWX8Reg6rwlIbdMEhg3QSkJR+pZ9/1zebp58K+9FAzqsL8u8dMOvsoOSY8PRn6ZrdwM/DhWpaniVmMWfTCH8lJiZkkN+FigRYV+L+4Ojn7INtR8wGzyF8fFVQ0OFSBqzHwabendFHKJ8y0Tn2xyXzGXA64u/z84z7XN9QD8fYEfS0HPEDFAkXtZEjTJWkFl8TMCMbfsMH1vjJ0WcGzIApu5wHCkzr3K2F1WlapeldSjtbqpmAVPWyHHTusAPbvqj9N6u9/AI5f7ZFKI/NOA+F27UvexcjgdgqfZemP2cZXUSj9ngq/Ay3CtEd4BnA6LV5Cf1bnsDJx/49/GRDmRwP8B3HvT5fvNR3yz+HWJuvU3fMiW7ZfkpP+Rc+0fcYQ4Jz2MDDsVIAJUb8REBwe60VODh7X0KmPQujQDMagLDVLbngc/0B2jQovBMMidR1XOgTt2KOauuSo6xV0ypE/D8NX1zWp0SfiE4rmwxJalZXB4Zy4a4k8gywLQ63mxJZCf7HNxt0fFai85qrTtqykHhVdWLsVAOmKY8kSd fvUs7O5v 7BKyWLfUAnAJFeKEHwLSQo6DCQEY0JTv5KgktA+VCZNCq6+K7DPtU+JasKkgENLpC7vDYAaZtFa/g/gv8BpJsQHnC32X6S1Vlnksu 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: From: Andrey Konovalov Give more meaningful names to hash table-related constants and variables: 1. Rename STACK_HASH_SCALE to STACK_HASH_TABLE_SCALE to point out that it is related to scaling the hash table. 2. Rename STACK_HASH_ORDER_MIN/MAX to STACK_BUCKET_NUMBER_ORDER_MIN/MAX to point out that it is related to the number of hash table buckets. 3. Rename stack_hash_order to stack_bucket_number_order for the same reason as #2. No functional changes. Signed-off-by: Andrey Konovalov Reviewed-by: Alexander Potapenko --- Changes v1->v2: - Rename STACK_HASH_SCALE to STACK_HASH_TABLE_SCALE. --- lib/stackdepot.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index de1afe3fb24d..d1ab53197353 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -76,17 +76,17 @@ static bool __stack_depot_early_init_requested __initdata = IS_ENABLED(CONFIG_ST static bool __stack_depot_early_init_passed __initdata; /* Use one hash table bucket per 16 KB of memory. */ -#define STACK_HASH_SCALE 14 +#define STACK_HASH_TABLE_SCALE 14 /* Limit the number of buckets between 4K and 1M. */ -#define STACK_HASH_ORDER_MIN 12 -#define STACK_HASH_ORDER_MAX 20 +#define STACK_BUCKET_NUMBER_ORDER_MIN 12 +#define STACK_BUCKET_NUMBER_ORDER_MAX 20 /* Initial seed for jhash2. */ #define STACK_HASH_SEED 0x9747b28c /* Hash table of pointers to stored stack traces. */ static struct stack_record **stack_table; /* Fixed order of the number of table buckets. Used when KASAN is enabled. */ -static unsigned int stack_hash_order; +static unsigned int stack_bucket_number_order; /* Hash mask for indexing the table. */ static unsigned int stack_hash_mask; @@ -137,28 +137,28 @@ int __init stack_depot_early_init(void) * in fuzzing scenarios, which leads to a large number of different * stack traces being stored in stack depot. */ - if (kasan_enabled() && !stack_hash_order) - stack_hash_order = STACK_HASH_ORDER_MAX; + if (kasan_enabled() && !stack_bucket_number_order) + stack_bucket_number_order = STACK_BUCKET_NUMBER_ORDER_MAX; if (!__stack_depot_early_init_requested || stack_depot_disabled) return 0; /* - * If stack_hash_order is not set, leave entries as 0 to rely on the - * automatic calculations performed by alloc_large_system_hash. + * If stack_bucket_number_order is not set, leave entries as 0 to rely + * on the automatic calculations performed by alloc_large_system_hash. */ - if (stack_hash_order) - entries = 1UL << stack_hash_order; + if (stack_bucket_number_order) + entries = 1UL << stack_bucket_number_order; pr_info("allocating hash table via alloc_large_system_hash\n"); stack_table = alloc_large_system_hash("stackdepot", sizeof(struct stack_record *), entries, - STACK_HASH_SCALE, + STACK_HASH_TABLE_SCALE, HASH_EARLY | HASH_ZERO, NULL, &stack_hash_mask, - 1UL << STACK_HASH_ORDER_MIN, - 1UL << STACK_HASH_ORDER_MAX); + 1UL << STACK_BUCKET_NUMBER_ORDER_MIN, + 1UL << STACK_BUCKET_NUMBER_ORDER_MAX); if (!stack_table) { pr_err("hash table allocation failed, disabling\n"); stack_depot_disabled = true; @@ -181,13 +181,13 @@ int stack_depot_init(void) goto out_unlock; /* - * Similarly to stack_depot_early_init, use stack_hash_order + * Similarly to stack_depot_early_init, use stack_bucket_number_order * if assigned, and rely on automatic scaling otherwise. */ - if (stack_hash_order) { - entries = 1UL << stack_hash_order; + if (stack_bucket_number_order) { + entries = 1UL << stack_bucket_number_order; } else { - int scale = STACK_HASH_SCALE; + int scale = STACK_HASH_TABLE_SCALE; entries = nr_free_buffer_pages(); entries = roundup_pow_of_two(entries); @@ -198,10 +198,10 @@ int stack_depot_init(void) entries <<= (PAGE_SHIFT - scale); } - if (entries < 1UL << STACK_HASH_ORDER_MIN) - entries = 1UL << STACK_HASH_ORDER_MIN; - if (entries > 1UL << STACK_HASH_ORDER_MAX) - entries = 1UL << STACK_HASH_ORDER_MAX; + if (entries < 1UL << STACK_BUCKET_NUMBER_ORDER_MIN) + entries = 1UL << STACK_BUCKET_NUMBER_ORDER_MIN; + if (entries > 1UL << STACK_BUCKET_NUMBER_ORDER_MAX) + entries = 1UL << STACK_BUCKET_NUMBER_ORDER_MAX; pr_info("allocating hash table of %lu entries via kvcalloc\n", entries); stack_table = kvcalloc(entries, sizeof(struct stack_record *), GFP_KERNEL);