Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7588099rdb; Thu, 4 Jan 2024 00:52:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFRqydRVPhSXdIvNKApi5mP0Zfldfop00aKTfPWXhLgbuBCe8iJs2RttvBGxgwJ9Hps+Ena X-Received: by 2002:a05:6870:310f:b0:203:a98d:1d8c with SMTP id v15-20020a056870310f00b00203a98d1d8cmr270835oaa.52.1704358346163; Thu, 04 Jan 2024 00:52:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704358346; cv=none; d=google.com; s=arc-20160816; b=oNz+kJkpBhRnzE+Q7+8HKNYH+FgAhmAlaCJm8ukcDZP8RCmMj/+CqZUc825C6L0+xO JOh8jVRyswbsNAapkXX9ueWELReCQPxg9Op7OMXqHl9PpriKdguglV2Pog+8agUikPJ5 bCxZMcMRJfc6kCRwsHWqFGXjy4c2l/o0oG7GFVe0uzPcHtWas6AqCIBWCNdqVhQjw83b 63gD/fJNrQeqABLU98djwudxWMs1DQsqlRn9IfGFsX4Tfb96LrsWJkbf4CHn/mi5JStH MyxPzLNo7aI1MTb9TK9Bkt25j6RCzbw6/iTlOTiQAEBdY+uK1hAYJYZKNOhZBRve2QxJ yLUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=e2YJJ/wHF3T/z8OvARyhcqLm9IAHtRiaRn7YI2Y5QEw=; fh=uYnjiVNxbW5kI0u75v8U/Y/ao7NQ4m8EfWg99NPaynw=; b=al62XfsaJNUqCezatinAdfFnrUlPdpukIZp55FvcGXoOygJVKQSydeqJkVe5s4gaqA b7T7FXPDmCXSPFNs6Vv7YIoe84RC22HmCYIeu8xVRzWpjJK5eVOkDSf/ceuWSEJEJfrv tUzQ9/0tIRMdL8wmkBjjOK270qOaZxkTG8rHVTG/NrLz6LdgPmO2Mra06WW3htFcK3IA CH3zP3qtFXA77V5pcMyJ/2ZErg4RnbGw56H/VoGofN/FxnUuN0rEjpUWodMIDvYgFA/E l8vox/+X8A+PZW+fwKEFdcovx3fYpi7EUPgLKWCBr5SU5qAosnCRv+ULhWxAXbMXg+W+ F+Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="1TRI/m90"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="1TRI/m90"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel+bounces-16401-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16401-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id g66-20020a636b45000000b005be1955657esi22641546pgc.127.2024.01.04.00.52.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 00:52:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16401-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="1TRI/m90"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="1TRI/m90"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel+bounces-16401-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16401-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E2782B214FE for ; Thu, 4 Jan 2024 08:52:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F01121EA7E; Thu, 4 Jan 2024 08:52:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="1TRI/m90"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="CA1G1rqE"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="1TRI/m90"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="CA1G1rqE" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CA631E51F for ; Thu, 4 Jan 2024 08:52:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 8DA501F7F6; Thu, 4 Jan 2024 08:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1704358322; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=e2YJJ/wHF3T/z8OvARyhcqLm9IAHtRiaRn7YI2Y5QEw=; b=1TRI/m90ROrYdJZsQaXHP/1gHytvXKxr5PQ1CJXiURHxAO8NrbfjR7CklOn0hrg3bqLb8X rt3ZmF0KKMqv2cu84k5piyh/4xveQvGvXrXIhSeeLbepzLnH4GaRUE4P/egSyxTlaZIdhi aTM0Jdo/kZBKMF071V2MKSmEPFOfLtk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1704358322; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=e2YJJ/wHF3T/z8OvARyhcqLm9IAHtRiaRn7YI2Y5QEw=; b=CA1G1rqEwBXCavUcVP9PAxQth9MeLV2sVC0gf84o8wAPJEQPnviR8yqy8tloJL3q6I91RW hGMlFYWSY9FJh8Bw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1704358322; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=e2YJJ/wHF3T/z8OvARyhcqLm9IAHtRiaRn7YI2Y5QEw=; b=1TRI/m90ROrYdJZsQaXHP/1gHytvXKxr5PQ1CJXiURHxAO8NrbfjR7CklOn0hrg3bqLb8X rt3ZmF0KKMqv2cu84k5piyh/4xveQvGvXrXIhSeeLbepzLnH4GaRUE4P/egSyxTlaZIdhi aTM0Jdo/kZBKMF071V2MKSmEPFOfLtk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1704358322; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=e2YJJ/wHF3T/z8OvARyhcqLm9IAHtRiaRn7YI2Y5QEw=; b=CA1G1rqEwBXCavUcVP9PAxQth9MeLV2sVC0gf84o8wAPJEQPnviR8yqy8tloJL3q6I91RW hGMlFYWSY9FJh8Bw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CF48913722; Thu, 4 Jan 2024 08:52:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id QM5NL7FxlmW7VQAAD6G6ig (envelope-from ); Thu, 04 Jan 2024 08:52:01 +0000 Date: Thu, 4 Jan 2024 09:52:53 +0100 From: Oscar Salvador To: andrey.konovalov@linux.dev Cc: Andrew Morton , Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: Re: [PATCH v4 17/22] lib/stackdepot: allow users to evict stack traces Message-ID: References: <1d1ad5692ee43d4fc2b3fd9d221331d30b36123f.1700502145.git.andreyknvl@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1d1ad5692ee43d4fc2b3fd9d221331d30b36123f.1700502145.git.andreyknvl@google.com> X-Spam-Level: X-Spam-Level: X-Spamd-Result: default: False [-3.10 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_TWELVE(0.00)[12]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[linux-foundation.org,gmail.com,google.com,suse.cz,googlegroups.com,kvack.org,vger.kernel.org]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] Authentication-Results: smtp-out2.suse.de; none X-Spam-Score: -3.10 X-Spam-Flag: NO On Mon, Nov 20, 2023 at 06:47:15PM +0100, andrey.konovalov@linux.dev wrote: > From: Andrey Konovalov > > Add stack_depot_put, a function that decrements the reference counter > on a stack record and removes it from the stack depot once the counter > reaches 0. > > Internally, when removing a stack record, the function unlinks it from > the hash table bucket and returns to the freelist. > > With this change, the users of stack depot can call stack_depot_put > when keeping a stack trace in the stack depot is not needed anymore. > This allows avoiding polluting the stack depot with irrelevant stack > traces and thus have more space to store the relevant ones before the > stack depot reaches its capacity. > > Signed-off-by: Andrey Konovalov I yet have to review the final bits of this series, but I'd like to comment on something below > +void stack_depot_put(depot_stack_handle_t handle) > +{ > + struct stack_record *stack; > + unsigned long flags; > + > + if (!handle || stack_depot_disabled) > + return; > + > + write_lock_irqsave(&pool_rwlock, flags); > + > + stack = depot_fetch_stack(handle); > + if (WARN_ON(!stack)) > + goto out; > + > + if (refcount_dec_and_test(&stack->count)) { > + /* Unlink stack from the hash table. */ > + list_del(&stack->list); > + > + /* Free stack. */ > + depot_free_stack(stack); It would be great if stack_depot_put would also accept a boolean, which would determine whether we want to erase the stack or not. For the feature I'm working on page_ower [1], I need to keep track of how many times we allocated/freed from a certain path, which may expose a potential leak, and I was using the refcount to do that, but I don't want the record to be erased, because this new functionality won't be exclusive with the existing one. e.g: you can check /sys/kernel/debug/page_owner AND /sys/kernel/debug/page_owner_stacks So, while the new functionaliy won't care if a record has been erased, the old one will, so information will be lost. [1] https://patchwork.kernel.org/project/linux-mm/cover/20231120084300.4368-1-osalvador@suse.de/ -- Oscar Salvador SUSE Labs