From patchwork Mon Jan 30 20:49:33 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: 13121819 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 CA1F6C636D6 for ; Mon, 30 Jan 2023 20:50:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E6006B0073; Mon, 30 Jan 2023 15:50:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 694496B0075; Mon, 30 Jan 2023 15:50:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49A9A6B0081; Mon, 30 Jan 2023 15:50:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 32AF96B0073 for ; Mon, 30 Jan 2023 15:50:56 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 05F40C0B94 for ; Mon, 30 Jan 2023 20:50:56 +0000 (UTC) X-FDA: 80412659712.06.52C9A4A Received: from out-174.mta0.migadu.com (out-174.mta0.migadu.com [91.218.175.174]) by imf25.hostedemail.com (Postfix) with ESMTP id 2DA23A0008 for ; Mon, 30 Jan 2023 20:50:53 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=oaNF1e2Z; spf=pass (imf25.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.174 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=1675111854; 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=4ThIc/E8It52Ai7wF9nGezLQDQ6i5NEX+ZonMvNBuyU=; b=tTFrKAkfdIkdI/APPOJrVfGoxJ5BV9gD6LIdRUNzwbIkPpYRCeCL5Wcns9ZUEBr9U/OTmI cKI5/88aMPuoZ0CVyOcpTuNjENbldqp3opH9Ad/gpW1ZZ8ZiNGETq9scsWLwvQs2RsauLu wYEP83jQDM4Q3eDk+WEtNuDsAl47h3s= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=oaNF1e2Z; spf=pass (imf25.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.174 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=1675111854; a=rsa-sha256; cv=none; b=4Sj/7Kh1PY/qNXcTBeDEQXbVuGZByppADQ8S+U13DGV2ZWNHRZf4PoGi6YhGWgHG69ZUa7 mgfzN/mrqN+To/JLzxAJ83e0MAjFfJ4q30Wzh1JUH+ZZjNqQ4lP7YJP7IMJTEvZgDl5Dqf ueNaMtFCxxQHLj70lx55fDtaYPg0s54= 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=1675111852; 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=4ThIc/E8It52Ai7wF9nGezLQDQ6i5NEX+ZonMvNBuyU=; b=oaNF1e2Zp8D74xhXSi9Xe8Em5fla04L3chl/gZgXxmenAMqSyBOC0TK0L+frAQoublm+D6 y3a+B2b/IEkOa1iD1H2U0A+sIMqhuheKhY5InYI2bt99cXYWbPbe8vQKOEBSspaWphgQIM onT6jzEMY8KySqyE2k0QGKr+jJVppcs= 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 09/18] lib/stackdepot: rename hash table constants and variables Date: Mon, 30 Jan 2023 21:49:33 +0100 Message-Id: <5456286e2c9f3cd5abf25ad2e7e60dc997c71f66.1675111415.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Stat-Signature: h3qcb6cxkhe5ahb5hs7zs8d4usk7s3xz X-Rspam-User: X-Rspamd-Queue-Id: 2DA23A0008 X-Rspamd-Server: rspam06 X-HE-Tag: 1675111853-712852 X-HE-Meta: U2FsdGVkX19DDp4za27l8QiQkv1L0fDmjzWQyNU/hTL64FvChgn5bXcwvNo5nK0HAc2NuFMejWt1j5qcWNpLBzj73sNDr6zUYPae+Pg0DJ/G/GyWsdTTfu6z3JIRkg8cg9Ed09542Fq0XlLF4/s8tOvCs2Six9kKe21Chj1aivMNQHhqOxFLLP+/mi6f/qAqKeuRQOqykw1+iW69FxtqObKxToHVsSfkyxPOerkrVjBczR/zmNKD2nsZo5NNEBmNG3G4UBnjfXz0CJYowHC12/IBc6yghkCjl/SXGYD472J6yE2zcVqzhBsoAcjcjRkmRobuNdoekOrmsIinrkZJ0FFBEuCwzTCKAOh+J2jCdqGCMibNUpo9D3KCJf85axJgswp3AuDTuDXA/FU6gsot+8Tz+uJov0BD27eoe0RkuT+zKhCD8X1KRfirmGpvyoNGlLvR9jACQB5FnFQA6KUv3IVEum+/g6zFpJhGn2Ma+AIVI+NiiKkiyMDRXbvzCobSeQpX+URyrtEqVBvBZSnIImROvwLiH0LSPOQZd7tSJiOeMSTiJ9cgo7ppEfMO4ltZowppN4bGG1x8RXbXjL10bsF3AgdB0L44xnh+A9gF7jWhA8is22RwtIkqfcBJAuyjIGNwtF5QT1jITbYhTngjSB6ejmk477AE+z9h1IvooJAPtmbfZKkmd+yAVKsGvmhRKFqsaqSWsmwShIquArev0blAzI5jGpCKUrBGlPiRdHMAC1cEU5WfYKN8TeQr0QSfaWj8n2oUH8MhplDgwnWjLcPdVD6psXyydtCVcXwQe+bfNljQLiV5JIK/KNpAwDd9AveTUU3najZiRMls3y264c/Po6Zpn8sD7mwEWbIMuRty2PXT3EouQhqBdun5jNDItt3VQB0FMZBRxDlojAhtY/XKPcBTy+qGrMeXhDrq7aczOcjGnaCA7v3zcT2V4ALEDtGrA/sTaAm9+/uJopB liDLvX+t kBtiFZ3X/MNs0D1lQRn8UHGf5WQamqg1mhvwrdhDnETT0IdkyyiiXr7MtV71RbOYK9paSEKDhCZzGCIblR9pLsFCvrOQG1uDuxY63+amtsuOQneM= 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_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 --- lib/stackdepot.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 89aee133303a..cddcf029e307 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_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_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_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);