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 BF48FC38145 for ; Thu, 8 Sep 2022 03:32:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 52D1C6B0072; Wed, 7 Sep 2022 23:32:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DC8E6B0074; Wed, 7 Sep 2022 23:32:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A40C8D0001; Wed, 7 Sep 2022 23:32:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 28F116B0072 for ; Wed, 7 Sep 2022 23:32:33 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F2285A0ACC for ; Thu, 8 Sep 2022 03:32:32 +0000 (UTC) X-FDA: 79887495744.11.4A1D0D7 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf26.hostedemail.com (Postfix) with ESMTP id 993A6140096 for ; Thu, 8 Sep 2022 03:32:32 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9255D220BE; Thu, 8 Sep 2022 03:32:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662607951; 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=oM/TdedenIQlQuKX4DHi/gp9jbEY2MeF287tY+t0mjE=; b=ib26AO1UtuXU3zm1beeP/PcV2lOp1JPiRStd5b3gTXbYMElNoEQF0+tkeEbfEUot/6eXap eVQ+d3pJS2yxNd1FxeJI74GN8hRSRZiedcIUpuY7a0zI+lODeJYRP7bo45w1s9aPk783At BLv8Ym4Khe/xZfKB1qkD6jqzmWEyk+4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662607951; 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=oM/TdedenIQlQuKX4DHi/gp9jbEY2MeF287tY+t0mjE=; b=1nFbNex9kfeqeYo+0+xVd9B/TQRuiEe5S7hMOSaDRy0qArfR9zFUsnRkukAk4dqdu1hd/i 9xyXZTgxHDOFKVBA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id F0CAF1348C; Thu, 8 Sep 2022 03:32:30 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id bT8OOE5iGWP1BgAAMHmgww (envelope-from ); Thu, 08 Sep 2022 03:32:30 +0000 Date: Thu, 8 Sep 2022 05:32:28 +0200 From: Oscar Salvador To: Marco Elver Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Vlastimil Babka , Eric Dumazet , Waiman Long , Suren Baghdasaryan , Andrey Konovalov , Alexander Potapenko Subject: Re: [PATCH v2 2/3] mm, page_owner: Add page_owner_stacks file to print out only stacks and their counter Message-ID: References: <20220905031012.4450-1-osalvador@suse.de> <20220905031012.4450-3-osalvador@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662607952; a=rsa-sha256; cv=none; b=xOp/y0n2r0I/PSdKCAfKpaBIJfmRiXU1qnsptQzk/O6+Hf9j6NZ8bH+nZVXEOKofVZ/sBK xKSzODZWqvgref1XXbF6obzAKujC9sS9ihwwab1aaLVfNDlA602MGyJBMLG5qecz1/IN3z n/qqrVn4n/Gxynqz7n1+6h2Rt5JfHYA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=ib26AO1U; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=1nFbNex9; spf=pass (imf26.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.28 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=1662607952; 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:dkim-signature; bh=oM/TdedenIQlQuKX4DHi/gp9jbEY2MeF287tY+t0mjE=; b=FeSrRnJX2dz6oA4BfpC63ByBzzTfIcM5BMOlIYNUro8xrXZOf5Z6lUrmMdpNISBTeecNGB gwef6aqLcyEnh51iz/C7dQhJqt6cIvUv+Y5CiM/Opm42BeMyq6uLmWrj6QhGbT5lQVnZRt VBXnvJx/ZOzQSNiDEFoWa+v1skkPKqk= Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=ib26AO1U; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=1nFbNex9; spf=pass (imf26.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de X-Rspam-User: X-Rspamd-Queue-Id: 993A6140096 X-Rspamd-Server: rspam09 X-Stat-Signature: wcqiuhfenz3cod9b6mdo4uedmn4mcwus X-HE-Tag: 1662607952-656631 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: On Wed, Sep 07, 2022 at 09:14:35AM +0200, Marco Elver wrote: > Why are you casting a stack_record** to a stack_record*? stack_table > is already appropriately typed, and there should be no need to cast > things around. > > 'stacks' is supposed to be the bucket? In which case you need to > dereference it to get the first entry in the bucket: bucket = > stack_table[table_i]; > > stack_i cannot be used to index into the bucket, because the elements > in it are a linked list and not necessarily adjacent in memory. You > have to traverse the linked list stack_i elements to get to the start: Yea, I figured that much after thinking about more, but I was overly eager. > for (int i = 0; stack && i < stack_i; stack = stack->next, ++i); But this seems suboptimal. With this code, we have to walk the list till we find the right index every time we enter the function, while the actual code of v2 or even the patch from v1 [1], we do not really need to do that because we already have the pointer to the stack. So I much rather prefer that, than having to traverse the stacks till the find the right one. -- Oscar Salvador SUSE Labs