linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yosry Ahmed <yosryahmed@google.com>
To: Waiman Long <longman@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Hugh Dickins <hughd@google.com>,
	 Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	 Roman Gushchin <roman.gushchin@linux.dev>,
	Shakeel Butt <shakeelb@google.com>,
	 Muchun Song <muchun.song@linux.dev>,
	Naoya Horiguchi <naoya.horiguchi@nec.com>,
	 Miaohe Lin <linmiaohe@huawei.com>,
	Vladimir Davydov <vdavydov.dev@gmail.com>,
	linux-mm@kvack.org,  cgroups@vger.kernel.org,
	Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH] memcg: page_cgroup_ino() get memcg from compound_head(page)
Date: Tue, 14 Mar 2023 20:40:46 -0700	[thread overview]
Message-ID: <CAJD7tkaFdi4gb9Y-SZGxmwCM1ev2JZ_A2h_b_asnpDH4jYPYPQ@mail.gmail.com> (raw)
In-Reply-To: <84d8fd38-f05c-73f5-ef50-fcac524097f3@redhat.com>

On Tue, Mar 14, 2023 at 8:33 PM Waiman Long <longman@redhat.com> wrote:
>
> On 3/14/23 23:10, Yosry Ahmed wrote:
> >>> The only other user today is print_page_owner_memcg(). I am not sure
> >>> if it's doing the right thing by explicitly reading page->memcg_data,
> >>> but it is already excluding pages that have page->memcg_data == 0,
> >>> which should be the case for tail pages.
> >> It is reading memcg_data directly to see if it is slab cache page. It is
> >> currently skipping page that does not have memcg_data set.
> > IIUC this skips tail pages, because they should always have
> > page->memcg_data == 0, even if they are charged to a memcg. To
> > correctly get their memcg we should read it from the
> > compound_head()/page_folio().
> The purpose of that function is mainly to report pages that have a
> reference to a memcg, especially the dead one. So by counting the
> occurrence of a particular cgroup name, we can have a rough idea of
> that. So only head page has relevance here and we can skip the tail pages.

I see. If you update the code to not check memcg_data directly, and we
update page_memcg_check() to return memcg of the head page, this will
stop skipping tail pages. Is this okay?

If not, we can explicitly skip tail pages in print_page_owner_memcg()
if we decide to check the head's memcg in page_memcg_check().

> >
> > My 2c, we can check PageSlab() to print the extra message for slab
> > pages, instead of reading memcg_data directly, which kinda breaks the
> > abstraction created by the various helpers for reading a page memcg.
> > Someone can easily change something in how memcg_data is interpreted
> > in those helpers without realizing that page_owner is also reading it.
>
> You are right. We should be using a helper if available. I will send a
> patch to fix that.

Great, thanks!

>
> Thanks,
> Longman
>


  reply	other threads:[~2023-03-15  3:41 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-13  8:34 Yosry Ahmed
2023-03-13 19:44 ` Andrew Morton
2023-03-13 21:08   ` Yosry Ahmed
2023-03-14 10:02     ` Michal Hocko
2023-03-14 19:45       ` Yosry Ahmed
2023-03-14 19:46         ` Yosry Ahmed
2023-03-15  2:34     ` Roman Gushchin
2023-03-15  2:39       ` Yosry Ahmed
2023-03-15  3:06     ` Waiman Long
2023-03-15  3:10       ` Yosry Ahmed
2023-03-15  3:33         ` Waiman Long
2023-03-15  3:40           ` Yosry Ahmed [this message]
2023-03-15  4:54     ` Matthew Wilcox
2023-03-15  7:04       ` Yosry Ahmed
2023-03-15 12:19         ` Matthew Wilcox
2023-03-15 21:43           ` Yosry Ahmed
2023-03-16  0:09             ` Waiman Long
2023-03-16  0:25               ` Yosry Ahmed
2023-03-16  3:07                 ` Matthew Wilcox
2023-03-16  3:16                   ` Yosry Ahmed
2023-03-22  6:52                     ` Yosry Ahmed
2023-03-14 10:00 ` Michal Hocko
2023-03-15  2:37 ` Yosry Ahmed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJD7tkaFdi4gb9Y-SZGxmwCM1ev2JZ_A2h_b_asnpDH4jYPYPQ@mail.gmail.com \
    --to=yosryahmed@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-mm@kvack.org \
    --cc=longman@redhat.com \
    --cc=mhocko@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=naoya.horiguchi@nec.com \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeelb@google.com \
    --cc=vdavydov.dev@gmail.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox