From: David Hildenbrand <david@redhat.com>
To: Minwoo Jo <chminoo@g.cbnu.ac.kr>, akpm@linux-foundation.org
Cc: rostedt@goodmis.org, mhiramat@kernel.org, willy@infradead.org,
linux-mm@kvack.org
Subject: Re: [PATCH] Hitshield : Something new eviction process for MGLRU
Date: Mon, 5 Aug 2024 13:56:09 +0200 [thread overview]
Message-ID: <6b5f1ea1-4ebe-41c7-9a0f-0cf3418af815@redhat.com> (raw)
In-Reply-To: <20240802000546.322036-1-chminoo@g.cbnu.ac.kr>
On 02.08.24 02:05, Minwoo Jo wrote:
> Signed-off-by: Minwoo Jo <chminoo@g.cbnu.ac.kr>
>
> This commit addresses the page space occupancy issue that arose
> in the previous commit with the HitShield technology.
>
> The HitShield technology is based on the observation that MGLRU
> does not take into account the state of the folio during eviction.
>
> I assumed that if a folio, which has been updated only 1 to 3 times,
> has increased in generation until the point of eviction,
> it is likely to be referenced less in the future.
>
> Therefore, I implemented this technology to protect frequently updated folios.
>
> I added the hitshield_0, hitshield_1, and hitshield flags to the page flag.
>
> Upon my review, I confirmed that the flags occupy positions 0 to 28.
>
> Thus, I believe that allocating 3 flags, or 3 bits, is sufficient.
>
> The hitshield_0 and hitshield_1 flags serve as count flags, representing the digit positions in binary.
>
> The hitshield flag is a boolean flag used to verify whether the HitShield is actually enabled.
>
> Each time a folio is added to lrugen, the hitshield_0 and hitshield_1 flags are cleared to reset them.
>
> Subsequently, in the folio_update_gen function, I added the following code:
>
> if (!folio_test_hitshield(folio))
> if (folio_test_change_hitshield_0(folio))
> if (folio_test_change_hitshield_1(folio))
> folio_set_hitshield(folio);
>
> This code counts the HitShield, and if it exceeds 5, it sets the hitshield flag.
>
> In the sort_folio function, which is executed for eviction, if the folio's hitshield flag is set,
> it ages the folio to max_gen and resets the flag.
>
> The testing was conducted on Ubuntu 24.04 LTS (Kernel 6.8.0)
> with an AMD Ryzen 9 5950X 16Core (32Threads) environment, restricting DRAM to 750MiB through Docker.
>
> In this environment, the ycsb benchmark was tested using the following command:
>
> ./bin/ycsb load mongodb -s -P workloads/workloadf -p recordcount=100000000 -p mongodb.batchsize=1024
> -threads 32 -p mongodb.url="mongodb://localhost:27017/ycsb"
>
> During testing, a reduction of 78.9% in pswpin and 75.6% in pswpout was measured.
>
> Additionally, the runtime for the Load command decreased by 18.3%,
> and the runtime for the Run command decreased by 9.3%.
>
> However, when running a single-threaded program with the current implementation,
> while a decrease in swap counts was observed, the runtime increased compared to the native MGLRU.
>
> A thorough analysis is needed to understand why this occurs, but I think it appears
> that there is significant overhead from the flag calculations.
>
> Therefore, it seems that if we activate this functionality through an ifdef statement
> only in certain situations, we could achieve performance benefits.
>
> As an undergraduate student who is still self-studying the kernel, I am not very familiar with using ifdef,
> so I did not write that part separately.
>
> I apologize for not being able to test it with large memory swap workloads,
> as I was unsure what would be appropriate.
>
> I would appreciate your review and feedback on this approach.
>
> Thank you.
> ---
> include/linux/mm_inline.h | 4 ++++
> include/linux/page-flags.h | 26 ++++++++++++++++++++++++++
> include/trace/events/mmflags.h | 5 ++++-
> mm/vmscan.c | 22 ++++++++++++++++++++++
> 4 files changed, 56 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
> index f4fe593c1400..dea613b2785c 100644
> --- a/include/linux/mm_inline.h
> +++ b/include/linux/mm_inline.h
> @@ -266,6 +266,10 @@ static inline bool lru_gen_add_folio(struct lruvec *lruvec, struct folio *folio,
> else
> list_add(&folio->lru, &lrugen->folios[gen][type][zone]);
>
> + folio_clear_hitshield_0(folio);
> + folio_clear_hitshield_1(folio);
> + /* This for initialize hit_shield by 0 when folio add to gen */
> +
> return true;
> }
>
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index 5769fe6e4950..70951c6fe4ce 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -130,6 +130,16 @@ enum pageflags {
> PG_arch_2,
> PG_arch_3,
> #endif
> + PG_hitshield_0,
> + PG_hitshield_1,
> + PG_hitshield,
> +
> + /*
> + * The flags consist of two types: one for counting the update occurrences
> + * of the folio and another boolean flag to check whether the HitShield is activated.
> + */
Note that adding new pageflags is frowned upon -- we're actually trying
to get rid of some of them, like PG_error. Getting another 3 added seems
very .. unlikely :)
Especially when done unconditionally on 32bit as well this might just
not work at all, and as you state, would require #ifdefery.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-08-05 11:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-02 0:05 Minwoo Jo
2024-08-05 11:29 ` Vlastimil Babka
2024-08-05 11:56 ` David Hildenbrand [this message]
2024-10-08 18:50 ` SeongJae Park
2024-10-28 7:32 ` Minwoo Jo
[not found] <20241008084411.196455-1-chminoo@g.cbnu.ac.kr>
[not found] ` <b78d1aa5-1de4-4050-80a5-cbd4bc1eb8f2@efficios.com>
[not found] ` <c84e6cb4-646c-4b70-9834-3d0f66f51787@efficios.com>
2024-10-08 16:04 ` Minwoo Jo
-- strict thread matches above, loose matches on Subject: below --
2024-07-20 14:25 [PATCH] HitShield:Something " Minwoo Jo
2024-07-20 15:34 ` Matthew Wilcox
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=6b5f1ea1-4ebe-41c7-9a0f-0cf3418af815@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=chminoo@g.cbnu.ac.kr \
--cc=linux-mm@kvack.org \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--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