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 82B92C38145 for ; Thu, 8 Sep 2022 05:32:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B25D18D0002; Thu, 8 Sep 2022 01:32:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD49C6B0073; Thu, 8 Sep 2022 01:32:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99D728D0002; Thu, 8 Sep 2022 01:32:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8A6C86B0072 for ; Thu, 8 Sep 2022 01:32:06 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5A26C160719 for ; Thu, 8 Sep 2022 05:32:06 +0000 (UTC) X-FDA: 79887797052.02.2FC8916 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) by imf24.hostedemail.com (Postfix) with ESMTP id 19F151800A0 for ; Thu, 8 Sep 2022 05:32:05 +0000 (UTC) Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-3454b0b1b6dso95671257b3.4 for ; Wed, 07 Sep 2022 22:32:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=WzVkFxioGR/YRpQq8W57ZtcDnW0QCcrE4C2tY3qbB4s=; b=EFOS8MzMKlHLUv0qkYLlhpBc12x9gJbQggXCRBeT2l5zrY/3+dbUqv0UZsv3nTyr9N ZBaguiu5aOAiexF9AFkiEFaqctF3jQ0MOqhh+1LLy3iywLcYOFnP6noHJzIiw/A2fnTL Fdb7glr3jkkjziKZYhH2EZ8NZwHkSrmB4r4OD5R2Ng5l4JBw4ouqq/+ACvgDokM1Xwi4 84ntchcfVanLJO6m1gT9o3JgtlnRow2wKJRTbV11ABPh5+iR9TpfboFVbCCzm4Ndm0ZW qNKk9nmBz6sGrHfRjkCIE0UcE7gxegRhL7vpBWD1ucSjY6ywr8WMGyq0loNlOFIvVTQ0 OEfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=WzVkFxioGR/YRpQq8W57ZtcDnW0QCcrE4C2tY3qbB4s=; b=ZyHM2tRAC+RXKCB4JtAfLLEmFKXTLD8TYOwjXkUPs2kMU1Zx16OJEEiEeSqiOcG2Tl cCgWhk/sLJeCbpGno5QgmpSm3DVbOIIC1vaX3LIrT7LbBusdxDE0oUmBEjcDocaEH0XW Pl1bTAUUXjF4RX60uBNQpL3fMkbYhVScJ6Hg2bpgUI0wDnfRn+JC4R+XuP6Gvo9uJWJX jzfqCw3s6WYjAZpN7Z486eCoMnD5iJ8Zi3TiTUVBCb2tUD692K9SSntyj55Hs4nLQa6n GJQLnsRWZ89RON8xJdlPuNEHE2KSL5Kdt3DKuIjO5gn2xhIL8v22/xRwV47hQ/SDhzVP nccw== X-Gm-Message-State: ACgBeo34n2WPqEy6R0VKx/rzCefs3+ujrkb4V7T34QkdzXdiALwdgzrv ZIve8EO47hKapY0ApUQUAsTkjszYl5K6LOaBeQePQg== X-Google-Smtp-Source: AA6agR49hiOOdenvIhboOgBhuYAhs2U/M4B60MYLWkUuCY10Kqgt8MwAaMYXDF7DBkZg7RJbcjEpxv11/1VLavQn2jw= X-Received: by 2002:a81:a16:0:b0:345:afa:5961 with SMTP id 22-20020a810a16000000b003450afa5961mr5987648ywk.11.1662615125240; Wed, 07 Sep 2022 22:32:05 -0700 (PDT) MIME-Version: 1.0 References: <20220905031012.4450-1-osalvador@suse.de> <20220905031012.4450-3-osalvador@suse.de> In-Reply-To: From: Marco Elver Date: Thu, 8 Sep 2022 07:31:29 +0200 Message-ID: Subject: Re: [PATCH v2 2/3] mm, page_owner: Add page_owner_stacks file to print out only stacks and their counter To: Oscar Salvador 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 Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662615126; a=rsa-sha256; cv=none; b=5/Vb3trJ11rrKY9FmxpUf32wG/A1ogX2JL/384bEy1L3olOYQkV1s8Af6rhjZ0P0AlLEDT X/uY7qd+RLevXKyfd2u7wcIk4I6t+PELLj0CS9ZJT8nKR0Wx+zVQ5LDdSKrLwe5dzSuwog CwtVFsiRas7ATNzv3/JAkgsmIH6cSPI= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=EFOS8MzM; spf=pass (imf24.hostedemail.com: domain of elver@google.com designates 209.85.128.175 as permitted sender) smtp.mailfrom=elver@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662615126; 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=WzVkFxioGR/YRpQq8W57ZtcDnW0QCcrE4C2tY3qbB4s=; b=SygXvYDGhPv16GG0ghCNS3WxWkb9vD/6jKvE8TLwqdLsMqMSa66PKyBySva0PIcnlb5Ip1 4yhRCOIQ7Ulcr3Ggn7U9DuBoqyhDRSVApjfpuloMAdVQ0hvIMsZWxE4q3QrApvCnLsyis7 GRvgGI70GcYLgdHa5eVgliCULokZDjk= X-Stat-Signature: rprhzniooktikmbb3c14s9czwspsusd8 X-Rspam-User: X-Rspamd-Queue-Id: 19F151800A0 X-Rspamd-Server: rspam07 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=EFOS8MzM; spf=pass (imf24.hostedemail.com: domain of elver@google.com designates 209.85.128.175 as permitted sender) smtp.mailfrom=elver@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1662615125-181653 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 Thu, 8 Sept 2022 at 05:32, Oscar Salvador wrote: > > 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. I would not prematurely optimize this. It's a hash map, and the only problem is if there are tons of collisions. Also, this function isn't performance critical, it's only used for printing, which itself is slow. I suggest you collect some stats how many entries each bucket has on average. If the average is <10, I'd go with the cleaner interface.