Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * test_free_pages.c: Check that free_pages() doesn't leak memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Copyright (c) 2020 Oracle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Author: Matthew Wilcox <willy@infradead.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/gfp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) static void test_free_pages(gfp_t gfp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	for (i = 0; i < 1000 * 1000; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 		unsigned long addr = __get_free_pages(gfp, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 		struct page *page = virt_to_page(addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 		/* Simulate page cache getting a speculative reference */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 		get_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 		free_pages(addr, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 		put_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static int m_in(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	test_free_pages(GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	test_free_pages(GFP_KERNEL | __GFP_COMP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static void m_ex(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) module_init(m_in);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) module_exit(m_ex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) MODULE_AUTHOR("Matthew Wilcox <willy@infradead.org>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) MODULE_LICENSE("GPL");