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.
+	 */
+
+
 	__NR_PAGEFLAGS,
 
 	PG_readahead = PG_reclaim,
@@ -504,6 +514,14 @@ static inline int TestClearPage##uname(struct page *page) { return 0; }
 #define TESTSCFLAG_FALSE(uname, lname)					\
 	TESTSETFLAG_FALSE(uname, lname) TESTCLEARFLAG_FALSE(uname, lname)
 
+#define TESTCHANGEPAGEFLAG(uname, lname, policy)                        \
+static __always_inline                                                  \
+bool folio_test_change_##lname(struct folio *folio)                     \
+{ return test_and_change_bit(PG_##lname, folio_flags(folio, FOLIO_##policy)); } \
+static __always_inline int TestChangePage##uname(struct page *page)             \
+{ return test_and_change_bit(PG_##lname, &policy(page, 0)->flags); }
+/* This macro function allows the use of the change operation defined in bitops. */
+
 __PAGEFLAG(Locked, locked, PF_NO_TAIL)
 FOLIO_FLAG(waiters, FOLIO_HEAD_PAGE)
 PAGEFLAG(Error, error, PF_NO_TAIL) TESTCLEARFLAG(Error, error, PF_NO_TAIL)
@@ -559,6 +577,14 @@ PAGEFLAG(Reclaim, reclaim, PF_NO_TAIL)
 PAGEFLAG(Readahead, readahead, PF_NO_COMPOUND)
 	TESTCLEARFLAG(Readahead, readahead, PF_NO_COMPOUND)
 
+/*
+ * hitshield_0 and 1 use only clear and test_change functions, also
+ * hitshield flag uses only set, test, test_clear function
+ */
+PAGEFLAG(Hitshield0, hitshield_0, PF_HEAD) TESTCHANGEPAGEFLAG(Hitshield0, hitshield_0, PF_HEAD)
+PAGEFLAG(Hitshield1, hitshield_1, PF_HEAD) TESTCHANGEPAGEFLAG(Hitshield1, hitshield_1, PF_HEAD)
+PAGEFLAG(Hitshield, hitshield, PF_HEAD) TESTSCFLAG(Hitshield, hitshield, PF_HEAD)
+
 #ifdef CONFIG_HIGHMEM
 /*
  * Must use a macro here due to header dependency issues. page_zone() is not
diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h
index b63d211bd141..d7ef9c503876 100644
--- a/include/trace/events/mmflags.h
+++ b/include/trace/events/mmflags.h
@@ -117,7 +117,10 @@
 	DEF_PAGEFLAG_NAME(mappedtodisk),				\
 	DEF_PAGEFLAG_NAME(reclaim),					\
 	DEF_PAGEFLAG_NAME(swapbacked),					\
-	DEF_PAGEFLAG_NAME(unevictable)					\
+	DEF_PAGEFLAG_NAME(unevictable),					\
+	DEF_PAGEFLAG_NAME(hitshield_0),					\
+	DEF_PAGEFLAG_NAME(hitshield_1),					\
+	DEF_PAGEFLAG_NAME(hitshield)					\
 IF_HAVE_PG_MLOCK(mlocked)						\
 IF_HAVE_PG_UNCACHED(uncached)						\
 IF_HAVE_PG_HWPOISON(hwpoison)						\
diff --git a/mm/vmscan.c b/mm/vmscan.c
index cfa839284b92..b44371dddb33 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3148,6 +3148,18 @@ static int folio_update_gen(struct folio *folio, int gen)
 		new_flags |= (gen + 1UL) << LRU_GEN_PGOFF;
 	} while (!try_cmpxchg(&folio->flags, &old_flags, new_flags));
 
+	/*
+	 * This part is core of hit_shield : Has this folio been updated frequently?
+	 * I chose 5 as the number of times to grant shield because of MAX_NR_GENS is 4,
+	 * so if this folio has been updated for more than a generation's length,
+	 * it has additional survivability equal to the generation's length.
+	 */
+
+	if (!folio_test_hitshield(folio))
+		if (folio_test_change_hitshield_0(folio))
+			if (folio_test_change_hitshield_1(folio))
+				folio_set_hitshield(folio);
+
 	return ((old_flags & LRU_GEN_MASK) >> LRU_GEN_PGOFF) - 1;
 }
 
@@ -4334,6 +4346,16 @@ static bool sort_folio(struct lruvec *lruvec, struct folio *folio, struct scan_c
 		return true;
 	}
 
+	/* this when hit_shield is enabled
+	 * init hit_shield again, and protect this folio like second chance algorithm
+	 */
+
+	if (folio_test_clear_hitshield(folio)) {
+		gen = folio_inc_gen(lruvec, folio, true);
+		list_move(&folio->lru, &lrugen->folios[gen][type][zone]);
+		return true;
+	}
+
 	return false;
 }
 
