Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp99709rwn; Wed, 7 Sep 2022 21:04:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR7bLTaQR5Mc/lztdTNlL2MKuimC/pQlmlAOWfk2sOGKBjRKCtAia0z+S+QYiCAi44UJ65X8 X-Received: by 2002:a17:90a:d593:b0:200:b212:6eb2 with SMTP id v19-20020a17090ad59300b00200b2126eb2mr1991803pju.60.1662609844625; Wed, 07 Sep 2022 21:04:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662609844; cv=none; d=google.com; s=arc-20160816; b=tMCNGnxgIfyfkz+T6aXuYdFHrw+zDBVJU18gOj1TDPWzwtfGl8mnt+YZqk7N6JtT35 +qw9PX2nwi0Xo0bhrYRdpJ2v2K2DDdqNhHLNN80IrZGCgYFoT1zIZvS56oCMroNPNbbx XLA0WCMOXH72AWOc9KQlTX9kJUDsAtuJWcDG+SarJZIYHp3af2ysCv0HFaAFY5KFJlDq m6gWWd9/Nkj6ViqFD2hamTiwu8vzx06Xc6MkV0r4RfFbyIGnhZrUuoN4noEWdYTDYG43 OA9z/eApZOoM8muMwe763Fe27VuBA/TA9U4+oE7xzht/eopJT/Cl1fMax1/u5nV7q5sf E06g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=oM/TdedenIQlQuKX4DHi/gp9jbEY2MeF287tY+t0mjE=; b=eRRpDR0b7RU1O+3mN5QxV13oeilz0tkC3UZsjc12XJ23i8RwQCo3hr3ZNLt0LuqlcU Z/LOez9qD2Cjt3Vfo3nQyDQR+svJuMl9qSQt0FOxizfyow6rQ5p/pHcLiWL+FiqpJUmv WzLlXSrP4i1v//OSFigj8F6caTOwCQBI6bdVNwwLn8aze/LBwED/Y+Ht3406uKAmp18i Ck7HEwoK8eCfx+0gQajciYRrn0bBkmoQxD5NHzrAhJDs/0e6r4AiT1LevGCXM+BXZ2GQ LcHtxL9qlg7FIvWgz1eTFn0XbSvXn9xxpZi+9tdDFdciiXgSKI/YO8B7vx64vzK24H3G Xb+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=ib26AO1U; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=1nFbNex9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bk13-20020a056a02028d00b0042b4a196e66si2422863pgb.160.2022.09.07.21.03.50; Wed, 07 Sep 2022 21:04:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=ib26AO1U; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=1nFbNex9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229598AbiIHDcj (ORCPT + 99 others); Wed, 7 Sep 2022 23:32:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbiIHDce (ORCPT ); Wed, 7 Sep 2022 23:32:34 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F35E4C7BA3 for ; Wed, 7 Sep 2022 20:32:32 -0700 (PDT) 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: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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