From nobody Sun Dec 14 06:42:13 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A728FC83F12 for ; Tue, 29 Aug 2023 17:15:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237689AbjH2ROu (ORCPT ); Tue, 29 Aug 2023 13:14:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237703AbjH2ROV (ORCPT ); Tue, 29 Aug 2023 13:14:21 -0400 Received: from out-244.mta1.migadu.com (out-244.mta1.migadu.com [IPv6:2001:41d0:203:375::f4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C31FCEE for ; Tue, 29 Aug 2023 10:13:49 -0700 (PDT) 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=1693329223; 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=SXcX5gR3dSvkxNFtne9AIJ3MreGstDXokl9zt3D1S94=; b=h6llS9CHe5RoqXvZREMQb8iyAp/Kb6KqjJZ0snmlmlR4rFM6dED6F0JcGGQU+5vqbXo8HX elNoG7XJ6jnDUln2rKKJ4l8c8KxNHcrBz76e+Dr/1x/lSC9m6R4ZN8FJDGgM6G/w4Breap 7U2QWpyTEl7oegpOYYamAOWgDo9QJW0= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH 12/15] stackdepot: add refcount for records Date: Tue, 29 Aug 2023 19:11:22 +0200 Message-Id: <306aeddcd3c01f432d308043c382669e5f63b395.1693328501.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Andrey Konovalov Add a reference counter for how many times a stack records has been added to stack depot. Do no yet decrement the refcount, this is implemented in one of the following patches. This is preparatory patch for implementing the eviction of stack records from the stack depot. Signed-off-by: Andrey Konovalov --- lib/stackdepot.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 5ad454367379..a84c0debbb9e 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -60,6 +61,7 @@ struct stack_record { u32 hash; /* Hash in hash table */ u32 size; /* Number of stored frames */ union handle_parts handle; + refcount_t count; unsigned long entries[DEPOT_STACK_MAX_FRAMES]; /* Frames */ }; =20 @@ -348,6 +350,7 @@ depot_alloc_stack(unsigned long *entries, int size, u32= hash, void **prealloc) stack->hash =3D hash; stack->size =3D size; /* stack->handle is already filled in by depot_init_pool. */ + refcount_set(&stack->count, 1); memcpy(stack->entries, entries, flex_array_size(stack, entries, size)); =20 /* @@ -452,6 +455,7 @@ depot_stack_handle_t __stack_depot_save(unsigned long *= entries, /* Fast path: look the stack trace up without full locking. */ found =3D find_stack(*bucket, entries, nr_entries, hash); if (found) { + refcount_inc(&found->count); read_unlock_irqrestore(&pool_rwlock, flags); goto exit; } --=20 2.25.1