* Idle THPs
@ 2021-06-10 3:43 Matthew Wilcox
2021-06-14 8:16 ` SeongJae Park
[not found] ` <59f61523-cb38-bf8c-51ba-1017ea7212d2@google.com>
0 siblings, 2 replies; 3+ messages in thread
From: Matthew Wilcox @ 2021-06-10 3:43 UTC (permalink / raw)
To: Vladimir Davydov, Kirill A. Shutemov, Hugh Dickins, linux-mm
As part of the folio work, I'm looking at PageIdle and PageYoung and
they're defined to operate on PF_ANY. So, for example, in
pagecache_get_page(), we will call clear_page_idle() on the head page
(actually, I changed this in a8cf7f272b5a -- before, it would call
clear_page_idle() on the tail page).
However, we never actually call set_page_idle() on tail pages. This is
because we only call it here:
page = page_idle_get_page(pfn);
if (page) {
page_idle_clear_pte_refs(page);
set_page_idle(page);
put_page(page);
}
where page_idle_get_page() does:
struct page *page = pfn_to_online_page(pfn);
if (!page || !PageLRU(page) ||
!get_page_unless_zero(page))
return NULL;
get_page_unless_zero() will always fail for tail pages (as it uses
page_ref_add_unless(), which does not redirect to the head page's
refcount). So all tail pages read back as !idle in
page_idle_bitmap_read(). Is this intended? Should they rather
mirror the state of their head page?
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: Idle THPs 2021-06-10 3:43 Idle THPs Matthew Wilcox @ 2021-06-14 8:16 ` SeongJae Park [not found] ` <59f61523-cb38-bf8c-51ba-1017ea7212d2@google.com> 1 sibling, 0 replies; 3+ messages in thread From: SeongJae Park @ 2021-06-14 8:16 UTC (permalink / raw) To: Matthew Wilcox Cc: Vladimir Davydov, Kirill A. Shutemov, Hugh Dickins, linux-mm From: SeongJae Park <sjpark@amazon.de> On Thu, 10 Jun 2021 04:43:18 +0100 Matthew Wilcox <willy@infradead.org> wrote: > As part of the folio work, I'm looking at PageIdle and PageYoung and > they're defined to operate on PF_ANY. So, for example, in > pagecache_get_page(), we will call clear_page_idle() on the head page > (actually, I changed this in a8cf7f272b5a -- before, it would call > clear_page_idle() on the tail page). > > However, we never actually call set_page_idle() on tail pages. This is > because we only call it here: > > page = page_idle_get_page(pfn); > if (page) { > page_idle_clear_pte_refs(page); > set_page_idle(page); > put_page(page); > } > > where page_idle_get_page() does: > > struct page *page = pfn_to_online_page(pfn); > > if (!page || !PageLRU(page) || > !get_page_unless_zero(page)) > return NULL; > > get_page_unless_zero() will always fail for tail pages (as it uses > page_ref_add_unless(), which does not redirect to the head page's > refcount). So all tail pages read back as !idle in > page_idle_bitmap_read(). Is this intended? Should they rather > mirror the state of their head page? I think this is an intended behavior, as the document[1] says as below: For huge pages the idle flag is set only on the head page, so one has to read /proc/kpageflags in order to correctly count idle huge pages. [1] https://www.kernel.org/doc/html/latest/admin-guide/mm/idle_page_tracking.html Thanks, SeongJae Park ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <59f61523-cb38-bf8c-51ba-1017ea7212d2@google.com>]
[parent not found: <CAHbLzkrznNBhGHZCN-Pf=1tUK+9Ad0TEXkC_fwDNcjceDt3vuw@mail.gmail.com>]
* Re: Idle THPs [not found] ` <CAHbLzkrznNBhGHZCN-Pf=1tUK+9Ad0TEXkC_fwDNcjceDt3vuw@mail.gmail.com> @ 2021-06-17 15:57 ` Shakeel Butt 0 siblings, 0 replies; 3+ messages in thread From: Shakeel Butt @ 2021-06-17 15:57 UTC (permalink / raw) To: Yang Shi, Yu Zhao Cc: Hugh Dickins, Matthew Wilcox, Vladimir Davydov, Kirill A. Shutemov, Linux MM +Yu Zhao On Thu, Jun 10, 2021 at 3:54 PM Yang Shi <shy828301@gmail.com> wrote: > > On Thu, Jun 10, 2021 at 2:47 PM Hugh Dickins <hughd@google.com> wrote: > > > > On Thu, 10 Jun 2021, Matthew Wilcox wrote: > > > > > As part of the folio work, I'm looking at PageIdle and PageYoung and > > > they're defined to operate on PF_ANY. So, for example, in > > > pagecache_get_page(), we will call clear_page_idle() on the head page > > > (actually, I changed this in a8cf7f272b5a -- before, it would call > > > clear_page_idle() on the tail page). > > > > > > However, we never actually call set_page_idle() on tail pages. This is > > > because we only call it here: > > > > > > page = page_idle_get_page(pfn); > > > if (page) { > > > page_idle_clear_pte_refs(page); > > > set_page_idle(page); > > > put_page(page); > > > } > > > > > > where page_idle_get_page() does: > > > > > > struct page *page = pfn_to_online_page(pfn); > > > > > > if (!page || !PageLRU(page) || > > > !get_page_unless_zero(page)) > > > return NULL; > > > > > > get_page_unless_zero() will always fail for tail pages (as it uses > > > page_ref_add_unless(), which does not redirect to the head page's > > > refcount). So all tail pages read back as !idle in > > > page_idle_bitmap_read(). Is this intended? Should they rather > > > mirror the state of their head page? From what I understand the idle bitmap is supposed to be used along with /proc/kpageflags. So, the users should skip tail pages for setting/getting the idle bits. > > > > Good point. > > > > I bet when I made that no-lru_lock cleanup in page_idle_get_page(), > > I was expecting the PageLRU to fail on tail, so get_page_unless_zero() > > irrelevant; but apparently PageLRU is PF_HEAD redirecting to head. > > Either way, yes, it will return NULL on tail, which may not be right. > > > > But maybe the physical scan works out okay with all the action > > happening on the head (Kirill got that to scan the tails in pvmw), > > then skipping the tails in the local scan. > > > > I'm not a page_idle user and don't want to get into the mechanics of it. > > Seems to be largely in maintenance mode these days, maybe nobody cares. > > > > Yang Shi was the last to make a real mod there, f0849ac0b8e0 ("mm: thp: fix > > potential clearing to referenced flag in page_idle_clear_pte_refs_one()"): > > likely he will know best. > > It was more than 3 years ago :-) > > Since the whole THP is considered referenced if any one of sub page is > referenced, so IMHO the tail page should mirror the state of their > head page. > > And AFAIK Google uses the idle flag to reclaim memory proactively, but > it is an out-of-tree feature. Loop Shakeel in this thread. We are not directly using upstream idle page infrastructure but surgically using the parts we need. Yu can provide more details. > > > > > Hugh ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-06-17 15:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-10 3:43 Idle THPs Matthew Wilcox
2021-06-14 8:16 ` SeongJae Park
[not found] ` <59f61523-cb38-bf8c-51ba-1017ea7212d2@google.com>
[not found] ` <CAHbLzkrznNBhGHZCN-Pf=1tUK+9Ad0TEXkC_fwDNcjceDt3vuw@mail.gmail.com>
2021-06-17 15:57 ` Shakeel Butt
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).