From: Andrew Morton <akpm@linux-foundation.org>
To: Kairui Song <kasong@tencent.com>
Cc: Kairui Song <ryncsn@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH] mm/util: reduce stack usage of folio_mapcount
Date: Thu, 11 Aug 2022 16:07:39 -0700 [thread overview]
Message-ID: <20220811160739.ea6b0f9c2912317c49287cda@linux-foundation.org> (raw)
In-Reply-To: <20220801173155.92008-1-ryncsn@gmail.com>
On Tue, 2 Aug 2022 01:31:55 +0800 Kairui Song <ryncsn@gmail.com> wrote:
> From: Kairui Song <kasong@tencent.com>
>
> folio_entire_mapcount will call PageHeadHuge which is a function call,
> and blocks the compiler from recognizing this redundant load.
Did you mean folio_test_hugetlb() rather than folio_entire_mapcount()?
> After rearranging the code, stack usage is dropped from 32 to 24, and
> the function size is smaller (tested on GCC 12):
>
> Before:
> Stack usage:
> mm/util.c:845:5:folio_mapcount 32 static
> Size:
> 0000000000000ea0 00000000000000c7 T folio_mapcount
>
> After:
> Stack usage:
> mm/util.c:845:5:folio_mapcount 24 static
> Size:
> 0000000000000ea0 00000000000000b0 T folio_mapcount
>
> ...
>
> @@ -850,10 +850,10 @@ int folio_mapcount(struct folio *folio)
> return atomic_read(&folio->_mapcount) + 1;
>
> compound = folio_entire_mapcount(folio);
> - nr = folio_nr_pages(folio);
> if (folio_test_hugetlb(folio))
> return compound;
> ret = compound;
> + nr = folio_nr_pages(folio);
> for (i = 0; i < nr; i++)
> ret += atomic_read(&folio_page(folio, i)->_mapcount) + 1;
> /* File pages has compound_mapcount included in _mapcount */
> --
> 2.35.2
next prev parent reply other threads:[~2022-08-11 23:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-01 17:31 Kairui Song
2022-08-11 23:07 ` Andrew Morton [this message]
2022-08-12 4:49 ` Kairui Song
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=20220811160739.ea6b0f9c2912317c49287cda@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ryncsn@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