From patchwork Mon Jan 30 20:49:35 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: 13121822 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 C5C00C636D6 for ; Mon, 30 Jan 2023 20:51:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B05C76B0081; Mon, 30 Jan 2023 15:50:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AB4196B0082; Mon, 30 Jan 2023 15:50:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 957856B0083; Mon, 30 Jan 2023 15:50:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 752EF6B0081 for ; Mon, 30 Jan 2023 15:50:57 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5079C40191 for ; Mon, 30 Jan 2023 20:50:57 +0000 (UTC) X-FDA: 80412659754.17.A466A50 Received: from out-196.mta0.migadu.com (out-196.mta0.migadu.com [91.218.175.196]) by imf15.hostedemail.com (Postfix) with ESMTP id 10DF1A0013 for ; Mon, 30 Jan 2023 20:50:54 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=H0xZx4zS; spf=pass (imf15.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.196 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=1675111855; 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=iXlgsoHOs+BLuKG+iZUfAdscpmKEgHjXPVNxwccGfOc=; b=WpCZoCJHUOvDFVaeGf1Xpym1fLd+fVfgKbRt9pILlzO0uWqr7vCrhnhPaVgSckrZH9tOSX DNRRnGAMPv+FakatyGhYwJzxuN1UGC5HFG42Wy+H3S5YiHQSRcNoq6z5xezb84OZXtWJSb Yi2e/Ldspxa/0K/Bb5TKbtYLsQ/jANs= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=H0xZx4zS; spf=pass (imf15.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.196 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=1675111855; a=rsa-sha256; cv=none; b=X1UquFYH3FccIMQ/etZLSQIx5Jl8OrPOd2XxLLrUtQKagcOsp+8O9mLXJU3lM5mTQgIq70 qexhYHh1RcMR+d/N7jBwvsGxHmKglFobRLGB4G+BDRy+kBd2e8TYtPWdwIYC8bls7+sQbb EBJEVkpH//BEwtv+UDMI+4eoM5bhyO4= 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=1675111853; 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=iXlgsoHOs+BLuKG+iZUfAdscpmKEgHjXPVNxwccGfOc=; b=H0xZx4zSVR5R1TTVo6Dq4Tk1fGJ1809Ce1jSVXVk9h7VH1pdC9UBrBWMfKmaJ+yvEFxCe1 vKFqnqMgtIUBw3xUT1K3M8gRABOsrDMGcGVAgNiniZRonGSGt7pdfEGXPOy46OlfwTgUum C1sqB4MBr5XwWI9FFgqUEkV0dRI3CPE= 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 11/18] lib/stackdepot: rename slab variables Date: Mon, 30 Jan 2023 21:49:35 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Stat-Signature: xarhzej8b8tin7w94iur1o56wamfszsb X-Rspam-User: X-Rspamd-Queue-Id: 10DF1A0013 X-Rspamd-Server: rspam06 X-HE-Tag: 1675111854-26281 X-HE-Meta: U2FsdGVkX19J+7mLrDpAzU0fxHKTRh4ldOrmM1ZMfUfpwQlIUfUo6GrlewBfWuoHYa9Zwg+E0eWSScgt3DDlLb7hGZ3xeNZXnUYq5rFmVbcbKCGSt4rI0IDdzGkzR4RPNJ6jnbOMVYmA/He+qQ40AfSAXEFb0Xro13a9S6JCh0fg2q8Kq/lemU+rFtR4/k57TjDWvZ+KM1PE/dJa8lA7zRGv5yDSkgssllkFyop2wSade743TIYoRWRktO2zu4cLwzga0SFDZhL7GFvNZ5gDVbhYAKFmNyS9CLyUPFkdLmZRvZd437kZuWmqiH/f2xt8BNYcmjv3ySw3nydXIWnIP25xvQQCpadwj+4Kkq0LknbpD0V7sPWlnwIHsCwdAiQVjfggyaF3PsWKgL8w6Kiomc38GPJBkeMzOKcLk3/EfM7G7GLMTefDZFsfTpogOJTPU8DRJcLPjpqnWDGK1GpoFtq++wBQj4sWE5AGQDPBVYlQVN5PCp+Laz1PxHx9Z4hIbhDB9OEb/0o+kmKTSZP9RE5LmL1J8iI8QRW23vctC9QyfDuVjkgKZqVHjPbzQDqRHmcp4YsZEnOpcT1bvrDU/5m3pQFmVvupf780LkZeSsoc38w4qwgcpY1wLEgFwN1RJHgMWSo0vog2a8Ps0vHglIYwFm8SNmljPXk5okcY/wTvDquQ0WAII9vzqTT2HPmyywV38dNZKq9MMWMBEiZDEbiGvgkzJzdP8OAXYiaBEfqw1DL9fNQ7q/AF0fn3Kxmie7AWItFDsf0R7O7DCIDllO8l1gf/bFystRArPy5h02wgVLx6rGvOSuBWtMATbo5+VvapgRlZ1k2WcZCdw5MCvmQa2cWrNbLkfikPX+EuRh04XiVmJ/G5J+IahEwNsrU9ndGFp9CADCD9gBcsUwlSv/u2o7cCJzy0MONKzzM+q2v2AzjfZ+8IISMGBQy9BXJjlb4+yHrYlTFOcVwJrS+ 8r+1NA3c eZqcUApPt4OcpLO/l2e1WqLbTnXnWDpAg0rh7YgTU+RjMGHuev8HXurwm5YnxcOh7Yq3fIqPm3srE6AYfur8wSqUsGL59ayRahQts5ZXydP7IDhU= 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 better names to slab-related global variables: change "depot_" prefix to "slab_" to point out that these variables are related to stack depot slabs. Also rename the slabindex field in handle_parts to align its name with the slab_index global variable. No functional changes. Signed-off-by: Andrey Konovalov --- lib/stackdepot.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 69b9316b0d4b..023f299bedf6 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -56,7 +56,7 @@ union handle_parts { depot_stack_handle_t handle; struct { - u32 slabindex : STACK_ALLOC_INDEX_BITS; + u32 slab_index : STACK_ALLOC_INDEX_BITS; u32 offset : STACK_ALLOC_OFFSET_BITS; u32 valid : STACK_ALLOC_NULL_PROTECTION_BITS; u32 extra : STACK_DEPOT_EXTRA_BITS; @@ -93,11 +93,11 @@ static unsigned int stack_hash_mask; /* Array of memory regions that store stack traces. */ static void *stack_slabs[STACK_ALLOC_MAX_SLABS]; /* Currently used slab in stack_slabs. */ -static int depot_index; +static int slab_index; /* Offset to the unused space in the currently used slab. */ -static size_t depot_offset; +static size_t slab_offset; /* Lock that protects the variables above. */ -static DEFINE_RAW_SPINLOCK(depot_lock); +static DEFINE_RAW_SPINLOCK(slab_lock); /* Whether the next slab is initialized. */ static int next_slab_inited; @@ -230,13 +230,13 @@ static bool depot_init_slab(void **prealloc) */ if (smp_load_acquire(&next_slab_inited)) return true; - if (stack_slabs[depot_index] == NULL) { - stack_slabs[depot_index] = *prealloc; + if (stack_slabs[slab_index] == NULL) { + stack_slabs[slab_index] = *prealloc; *prealloc = NULL; } else { /* If this is the last depot slab, do not touch the next one. */ - if (depot_index + 1 < STACK_ALLOC_MAX_SLABS) { - stack_slabs[depot_index + 1] = *prealloc; + if (slab_index + 1 < STACK_ALLOC_MAX_SLABS) { + stack_slabs[slab_index + 1] = *prealloc; *prealloc = NULL; /* * This smp_store_release pairs with smp_load_acquire() @@ -258,35 +258,35 @@ depot_alloc_stack(unsigned long *entries, int size, u32 hash, void **prealloc) required_size = ALIGN(required_size, 1 << STACK_ALLOC_ALIGN); - if (unlikely(depot_offset + required_size > STACK_ALLOC_SIZE)) { - if (unlikely(depot_index + 1 >= STACK_ALLOC_MAX_SLABS)) { + if (unlikely(slab_offset + required_size > STACK_ALLOC_SIZE)) { + if (unlikely(slab_index + 1 >= STACK_ALLOC_MAX_SLABS)) { WARN_ONCE(1, "Stack depot reached limit capacity"); return NULL; } - depot_index++; - depot_offset = 0; + slab_index++; + slab_offset = 0; /* * smp_store_release() here pairs with smp_load_acquire() from * |next_slab_inited| in stack_depot_save() and * depot_init_slab(). */ - if (depot_index + 1 < STACK_ALLOC_MAX_SLABS) + if (slab_index + 1 < STACK_ALLOC_MAX_SLABS) smp_store_release(&next_slab_inited, 0); } depot_init_slab(prealloc); - if (stack_slabs[depot_index] == NULL) + if (stack_slabs[slab_index] == NULL) return NULL; - stack = stack_slabs[depot_index] + depot_offset; + stack = stack_slabs[slab_index] + slab_offset; stack->hash = hash; stack->size = size; - stack->handle.slabindex = depot_index; - stack->handle.offset = depot_offset >> STACK_ALLOC_ALIGN; + stack->handle.slab_index = slab_index; + stack->handle.offset = slab_offset >> STACK_ALLOC_ALIGN; stack->handle.valid = 1; stack->handle.extra = 0; memcpy(stack->entries, entries, flex_array_size(stack, entries, size)); - depot_offset += required_size; + slab_offset += required_size; return stack; } @@ -418,7 +418,7 @@ depot_stack_handle_t __stack_depot_save(unsigned long *entries, prealloc = page_address(page); } - raw_spin_lock_irqsave(&depot_lock, flags); + raw_spin_lock_irqsave(&slab_lock, flags); found = find_stack(*bucket, entries, nr_entries, hash); if (!found) { @@ -441,7 +441,7 @@ depot_stack_handle_t __stack_depot_save(unsigned long *entries, WARN_ON(!depot_init_slab(&prealloc)); } - raw_spin_unlock_irqrestore(&depot_lock, flags); + raw_spin_unlock_irqrestore(&slab_lock, flags); exit: if (prealloc) { /* Nobody used this memory, ok to free it. */ @@ -497,12 +497,12 @@ unsigned int stack_depot_fetch(depot_stack_handle_t handle, if (!handle) return 0; - if (parts.slabindex > depot_index) { + if (parts.slab_index > slab_index) { WARN(1, "slab index %d out of bounds (%d) for stack id %08x\n", - parts.slabindex, depot_index, handle); + parts.slab_index, slab_index, handle); return 0; } - slab = stack_slabs[parts.slabindex]; + slab = stack_slabs[parts.slab_index]; if (!slab) return 0; stack = slab + offset;