From: Sourav Panda <souravpanda@google.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: corbet@lwn.net, gregkh@linuxfoundation.org, rafael@kernel.org,
akpm@linux-foundation.org, mike.kravetz@oracle.com,
muchun.song@linux.dev, rppt@kernel.org, david@redhat.com,
rdunlap@infradead.org, chenlinxuan@uniontech.com,
yang.yang29@zte.com.cn, tomas.mudrunka@gmail.com,
bhelgaas@google.com, ivan@cloudflare.com,
pasha.tatashin@soleen.com, yosryahmed@google.com,
hannes@cmpxchg.org, shakeelb@google.com,
kirill.shutemov@linux.intel.com, wangkefeng.wang@huawei.com,
adobriyan@gmail.com, vbabka@suse.cz, Liam.Howlett@oracle.com,
surenb@google.com, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH v2 1/1] mm: report per-page metadata information
Date: Thu, 19 Oct 2023 09:20:32 -0700 [thread overview]
Message-ID: <CANruzcSBK5z+S79Wiu=k1hGgwFt5zbEkdmgo=wBCjw7+MwftZg@mail.gmail.com> (raw)
In-Reply-To: <ZS/m1KRwTLkcJY8y@casper.infradead.org>
[-- Attachment #1: Type: text/plain, Size: 1971 bytes --]
On Wed, Oct 18, 2023 at 7:08 AM Matthew Wilcox <willy@infradead.org> wrote:
> On Tue, Oct 17, 2023 at 05:55:48PM -0700, Sourav Panda wrote:
> > + mod_node_early_perpage_metadata(pgdat->node_id,
> > + PAGE_ALIGN(size) >>
> PAGE_SHIFT);
>
> What a curious way of writing DIV_ROUND_UP(size, PAGE_SIZE)
> (throughout). A quick grep shows about 230 DIV_ROUND_UP and 110 of what
> you wrote, so it's not something you invented, but DIV_ROUND_UP is
> clearer.
>
> > @@ -303,18 +308,25 @@ static int __meminit
> init_section_page_ext(unsigned long pfn, int nid)
> >
> > static void free_page_ext(void *addr)
> > {
> > + size_t table_size;
> > + struct page *page;
> > +
> > + table_size = page_ext_size * PAGES_PER_SECTION;
> > +
> > if (is_vmalloc_addr(addr)) {
> > + page = vmalloc_to_page(addr);
> > vfree(addr);
> > } else {
> > - struct page *page = virt_to_page(addr);
> > - size_t table_size;
> > -
> > - table_size = page_ext_size * PAGES_PER_SECTION;
> > + page = virt_to_page(addr);
> >
> > BUG_ON(PageReserved(page));
> > kmemleak_free(addr);
> > free_pages_exact(addr, table_size);
> > }
> > +
> > + __mod_node_page_state(page_pgdat(page), NR_PAGE_METADATA,
> > + -1L * (PAGE_ALIGN(table_size) >>
> PAGE_SHIFT));
>
> This troubles me. We're freeing the memory and then dereferencing
> the page that was freed. I know that struct pages don't go away when
> they're freed, and they don't change which node they're allocated to,
> but it feels wrong. I'd be happier if the page_pgdat() were extracted
> prior to freeing the memory.
>
Thank you Matthew Wilcox for pointing this out. I will extract page_pgdat()
prior to freeing the memory in v3.
With regards,
Sourav Panda
[-- Attachment #2: Type: text/html, Size: 2751 bytes --]
prev parent reply other threads:[~2023-10-19 16:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-18 0:55 [PATCH v2 0/1] " Sourav Panda
2023-10-18 0:55 ` [PATCH v2 1/1] " Sourav Panda
2023-10-18 7:51 ` Greg KH
2023-10-19 16:15 ` Sourav Panda
2023-10-19 16:22 ` Sourav Panda
2023-10-18 14:08 ` Matthew Wilcox
2023-10-19 16:20 ` Sourav Panda [this message]
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='CANruzcSBK5z+S79Wiu=k1hGgwFt5zbEkdmgo=wBCjw7+MwftZg@mail.gmail.com' \
--to=souravpanda@google.com \
--cc=Liam.Howlett@oracle.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=bhelgaas@google.com \
--cc=chenlinxuan@uniontech.com \
--cc=corbet@lwn.net \
--cc=david@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=hannes@cmpxchg.org \
--cc=ivan@cloudflare.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=muchun.song@linux.dev \
--cc=pasha.tatashin@soleen.com \
--cc=rafael@kernel.org \
--cc=rdunlap@infradead.org \
--cc=rppt@kernel.org \
--cc=shakeelb@google.com \
--cc=surenb@google.com \
--cc=tomas.mudrunka@gmail.com \
--cc=vbabka@suse.cz \
--cc=wangkefeng.wang@huawei.com \
--cc=willy@infradead.org \
--cc=yang.yang29@zte.com.cn \
--cc=yosryahmed@google.com \
/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