From mboxrd@z Thu Jan 1 00:00:00 1970 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 133D5C4829E for ; Thu, 15 Feb 2024 11:56:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D83E8D000E; Thu, 15 Feb 2024 06:56:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 787C08D0001; Thu, 15 Feb 2024 06:56:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6280C8D000E; Thu, 15 Feb 2024 06:56:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 4C0438D0001 for ; Thu, 15 Feb 2024 06:56:37 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E6B34A0FA1 for ; Thu, 15 Feb 2024 11:56:36 +0000 (UTC) X-FDA: 81793885992.08.0D0E757 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf26.hostedemail.com (Postfix) with ESMTP id E078F140003 for ; Thu, 15 Feb 2024 11:56:34 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707998195; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Bcvm1TEclRJUp7qzNv0tpMMgA3P6SqAo0lVMagZHIEE=; b=yNGN9PAZ9k9PaJynx5g8NTLf9772b8Shs/S+dsgqrtIKDymkrr6eBeuz2DfTJv0xXoAR/Y GyZfFTemLM/EnYZ6eQvi9T1ihmISppEau9s4mZkPoqLhab8aSjaWOPV0hiUvEMqBDU9fCs B8h0+L0C1torVvXGv07NyH1g/7RdpTo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707998195; a=rsa-sha256; cv=none; b=NMlD7objiwOOAUGvCs2ajzur2Sjqx292Cdtok9MncDttb+o+7Ey2v4HhgmGPLyp4vfj1P6 Datf5+RPcfCOYUus+vG7HfFsYSl8QTZTgV9J3xg/3HWUUVAebvvNPDlVXF/bF5XcyAEnjO lm3ZrMhUiGy3bG6ZSnhPtngVYNuKum8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (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-out1.suse.de (Postfix) with ESMTPS id 2A4A422205; Thu, 15 Feb 2024 11:56:33 +0000 (UTC) Received: from imap2.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 imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id A3AD91346A; Thu, 15 Feb 2024 11:56:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id IP28JPD7zWUrBwAAn2gu4w (envelope-from ); Thu, 15 Feb 2024 11:56:32 +0000 Date: Thu, 15 Feb 2024 12:57:39 +0100 From: Oscar Salvador To: Vlastimil Babka Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Marco Elver , Andrey Konovalov , Alexander Potapenko Subject: Re: [PATCH v9 4/7] mm,page_owner: Implement the tracking of the stacks count Message-ID: References: <20240214170157.17530-1-osalvador@suse.de> <20240214170157.17530-5-osalvador@suse.de> <9fc95f61-827f-40ee-a823-576cdcad7939@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9fc95f61-827f-40ee-a823-576cdcad7939@suse.cz> X-Rspamd-Queue-Id: E078F140003 X-Rspam-User: X-Stat-Signature: bpuc791hcmhu9mzn9nqozirmeg57b3u1 X-Rspamd-Server: rspam03 X-HE-Tag: 1707998194-824361 X-HE-Meta: U2FsdGVkX1/+wTbj2GG3XvedKt1DciI3FGZXDey7WgNIp2h6UcT2bRc+eRwE1wrcDyHg6eiW+8NtIIEwRlxweJJ3LJMW5Jdw/UdcTzV5AhKkSw/nZo4AH34UpG2DjDuzTcu7LN9eN5om/My9IRjmxjcQMHs1FpNCqUuDcHktBJvOPCa0wlX7X02JQzjDtDGnQftWB4+0i/W6JEJRMGyg5+vfQz9QCHXZpI9YQDFbJYRsUXk7iA4TazeLm0HSMNTvK2e58+hkCTqe4ET1dKzTAPktfpfefHX21+KGMQq1TG5WsSQO16nuzbLkiujb4qFXS7A5tr69BiERfraRZ/aT1zQf7eKkZlm6QOYjWzNCKXeG5PZ0tE1Qi2iM6N0MQPazpeO0vs22hf/jqzUvFGb/iJkJ6iCLX21vYWFb59WyKtUbvJotaj5FbR57o6CxVVFOPIx+F+W4BAUCWdBjcGUxXQDoXuwy/ZtJEbJ/RcLHN/eF4g+WHjQfzXws+JiRLlNSVmgPlPyATjav7fHgcHatn7BCOxUQNolt+ILG/vrNyqRKsCAZlK2yZjL0yoiujj7UI8WARkp/io+y7ToGHSLOcL4bIRNj9isde13odKCKfYechqinxWtSzthvgGGQZe8QfdRrkeTDSRQbQZFxEvS4yx39drWznQni4i+oMjZTFo97YeCeGwQnXAKgtS8Z1fOzowlwEWpA8iGi8R2lXLX2EAVkdeEw/iPzqUTIJw92lG8nAu6BRSKpgZOqieraWV2eF/P4l674ASYgyA/CN4+LMa3usHW5ZhPYreFC1glx92ybu58BfP1J+1kVNNtk0tf+faVzED+lQH1o10rs7vmgzcINMZVeS2Uj1pgp7N3ITfa9kzYcNCxDqsszEpjwEp0zHoLJgEPG2FY40fHucIcWpbfrx9LfNFlDEgGdcUZkF+SHmIsIXCaX5nAa8IdPI6FtxpgfthtJNOjGdUMNdJf 9l6AzYOn YCW/t6zqTmfhRhlfTRVeP5DOvC+AtWfAmY1x44LICLV3J/mx141MSVZndSalgrtM/3uM49Vr5w2hkOKM636EVn0WYt26uL1wENkKyRscklz1BE53A3xcYqPcf4uTTv6LK6xfKqIkt7Zr7OvxiVH2PPxoE4S6UPAAt9qGG 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: List-Subscribe: List-Unsubscribe: On Thu, Feb 15, 2024 at 12:08:53PM +0100, Vlastimil Babka wrote: > On 2/14/24 18:01, Oscar Salvador wrote: > > Implement {inc,dec}_stack_record_count() which increments or > > decrements on respective allocation and free operations, via > > __reset_page_owner() (free operation) and __set_page_owner() (alloc > > operation). > > Newly allocated stack_record structs will be added to the list stack_list > > via add_stack_record_to_list(). > > Modifications on the list are protected via a spinlock with irqs > > disabled, since this code can also be reached from IRQ context. > > > > Signed-off-by: Oscar Salvador > > Reviewed-by: Marco Elver > > Reviewed-by: Vlastimil Babka Thanks! > > + if (atomic_try_cmpxchg_relaxed(&stack_record->count.refs, &old, 1)) > > + /* Add the new stack_record to our list */ > > + add_stack_record_to_list(stack_record, gfp_mask); > > Not returning here... > > > + } > > + refcount_inc(&stack_record->count); > > ... means we'll increase the count to 2 on the first store, so there's a > bias. Which would be consistent with the failure and dummy stacks that also > start with a refcount of 1. But then the stack count reporting should > decrement by 1 to prevent confusion? (in the following patch). Imagine > somebody debugging an allocation stack where there are not so many of them, > but the allocation is large, and being sidetracked by an off-by-one error. Good catch Vlastimil! Yes, we should substract one from the total count in stack_print. -- Oscar Salvador SUSE Labs