History

mm: maintain randomization of page free lists

When freeing a page with an order >= shuffle_page_order randomly select the front or back of the list for insertion. While the mm tries to defragment physical pages into huge pages this can tend to make the page allocator more predictable over time. Inject the front-back randomness to preserve the initial randomness established by shuffle_free_memory() when the kernel was booted. The overhead of this manipulation is constrained by only being applied for MAX_ORDER sized pages by default. [akpm@linux-foundation.org: coding-style fixes] Link: http://lkml.kernel.org/r/154899812788.3165233.9066631950746578517.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Kees Cook <keescook@chromium.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Keith Busch <keith.busch@intel.com> Cc: Robert Elliott <elliott@hpe.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Dan Williams committed 7 years ago

Commit 97500a41 parent b03641a4 files · +56 −2Browse files

Showing the changes to include/linux (1 of 4 files). Show all

Unified · Split

include/linux/mmzone.h+12−0
@@ -116,6 +116,18 @@ static inline void add_to_free_area_tail(struct page *page, struct free_area *ar · 115 unmodified lines
116116 area->nr_free++;
117117 }
118118
119+#ifdef CONFIG_SHUFFLE_PAGE_ALLOCATOR
120+/* Used to preserve page allocation order entropy */
121+void add_to_free_area_random(struct page *page, struct free_area *area,
122+ int migratetype);
123+#else
124+static inline void add_to_free_area_random(struct page *page,
125+ struct free_area *area, int migratetype)
126+{
127+ add_to_free_area(page, area, migratetype);
128+}
129+#endif
130+
119131 /* Used for pages which are on another list */
120132 static inline void move_to_free_area(struct page *page, struct free_area *area,
121133 int migratetype)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t