From patchwork Tue Aug 29 17:11:22 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: 13369246 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 5F032C83F1D for ; Tue, 29 Aug 2023 17:13:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED9118E0039; Tue, 29 Aug 2023 13:13:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E61D08E0036; Tue, 29 Aug 2023 13:13:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D03588E0039; Tue, 29 Aug 2023 13:13:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id BBE5E8E0036 for ; Tue, 29 Aug 2023 13:13:46 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 99ABD160199 for ; Tue, 29 Aug 2023 17:13:46 +0000 (UTC) X-FDA: 81177789252.26.11F1176 Received: from out-248.mta1.migadu.com (out-248.mta1.migadu.com [95.215.58.248]) by imf13.hostedemail.com (Postfix) with ESMTP id DE80F20008 for ; Tue, 29 Aug 2023 17:13:44 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=h6llS9CH; spf=pass (imf13.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.248 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=1693329225; 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=SXcX5gR3dSvkxNFtne9AIJ3MreGstDXokl9zt3D1S94=; b=GKO/u6kxhtIWVnZZmCJL9fCdvSeg/8dC3SE/v352yxJ0pavNqk9zjpMz3iegs3JnDzz6Fy ETGKs/Q0JbkRK/2a0sgFyhZGHza+bm+dl/T50DQn3v+20DWFVSHqj79XeLI66okYYuNgzY FjB4aB/xj0S+HPPxl5BTBN4NK0gsqd0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693329225; a=rsa-sha256; cv=none; b=jPxWSAEJkspct1lYXuHERG+dHg65LOJ9UVpiMt8esFfTbMySJP151hZXR7OjnDSLgFqc1D Zgd67ue9feo8JQEY9gqovghnAc6zQMYtQjXGNYpNuKsqcJxW/LBBHKaSSpncu1YV1p2/Ob qLFMj58hyxcgIstP6Cm7lO6sTOE2F14= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=h6llS9CH; spf=pass (imf13.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.248 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev 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 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: DE80F20008 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 6sffeoauhssd1m987t355ww1xottusrz X-HE-Tag: 1693329224-832451 X-HE-Meta: U2FsdGVkX1+KD4tCEIlJmJXskov9BMgH5SblgAZfc4iPmNFBQERXRH+WAwLG14EtxnynTQFvD/zvIgyTDszb0/ZICTZWMTM4eNTiERseOFw3/9z7zmTVjdoFBpKYMWpdA1exqhScnFWJcXg4MrRhipQfVV59RcKa7sQsiIaW/1SI5n67AIBK6lcQlU16RwsiRGZ2Jz9wBWGPAOnhGxRWjPUtW5PBCSqEzQcwsuD6H/P6VzGr9dX+7y1dYLjLnKzYwi46gmwf+g8EepHi5TsiTprI2LjSYrrRIaYXqCS0GqbuEzB0tH6uRCAv+Yzpaun6Ldw8am/JNX7Pp/bzaVKmd4NrpkPBfFTGOS6L9gPPfzaMD9TPtQsNXWh+15hO6kFj15UULTv8cPq7YQkvPfjFQxUZinNOEAJSAvvCnhBxVY28xR1wn+jWfyIRR/Wksgv9AfwKFBuu0q4to+NngJV0Hqcg78Xn/kbO/x8ztY2JNiZCMkXX41b3F+eBgZH0nBlPSxdHv0gaYSaCUdzMR4dhsGMw+W5cqr5UIZ5FYoqg+lspJeXAsyvnSiB27yBqH9f2OYv2SRycsz7sk5QDJNFZrtmcXqKkt3e1whQkzcE8xyXKnHbl10RfwSB3ur4pya1dLZqRXe2l8UnKlrn1A/n8jHKylnoX+i2W12Is1P2s6gob8dCMhbklNY9S+sD4DrfPTcNeBfHRiDsg8srEijTpaCgpZYISjaUBHZFaQkCzflFgD3bwr4RsNCR8hRigGz0Y16/h8q9jZSAEfa7SjSku0kdeRh1IpFhj5/x42Fq4GTT6t+ndl2VrWvuGN9MvA+cEcqbxpf8XLqbsm4r+i7R0/uOkhzW5HPIv8Y7M59NlBf86aHayWM6TG0OCiv4SnZuTvD2hIJn7a++5VRNh4XQA6Hxw8fB07izsWbnzmr1hDRC6OoVeD+5tcha/QMtSZpc67CEECxxWfjirHgHx6f4 anrFVllB 7nx8kaWT6oMoXQkC2JVsREB46bREXZW6QyR/pQ8qraSF/w/JDyTUYmUWwAlab2wm0mFdzKJmVzRQ1We6dGZSXPc5G2ii/kCiLOzRWyVjJZL0xD7v8vgjsBAyf9Q== 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 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 */ }; @@ -348,6 +350,7 @@ depot_alloc_stack(unsigned long *entries, int size, u32 hash, void **prealloc) stack->hash = hash; stack->size = 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)); /* @@ -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 = find_stack(*bucket, entries, nr_entries, hash); if (found) { + refcount_inc(&found->count); read_unlock_irqrestore(&pool_rwlock, flags); goto exit; }