vmscan.c (f661d007f40dffc719c1b2b1a636b759f87c4e78) | vmscan.c (6b700b5b3c595594c7c0c608cfe903c4e3a0af2d) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * linux/mm/vmscan.c 4 * 5 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds 6 * 7 * Swap reorganised 29.12.95, Stephen Tweedie. 8 * kswapd added: 7.1.96 sct --- 4016 unchanged lines hidden (view full) --- 4025 set_task_reclaim_state(current, NULL); 4026 memalloc_noreclaim_restore(noreclaim_flag); 4027 fs_reclaim_release(sc.gfp_mask); 4028 4029 return nr_reclaimed; 4030} 4031#endif /* CONFIG_HIBERNATION */ 4032 | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * linux/mm/vmscan.c 4 * 5 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds 6 * 7 * Swap reorganised 29.12.95, Stephen Tweedie. 8 * kswapd added: 7.1.96 sct --- 4016 unchanged lines hidden (view full) --- 4025 set_task_reclaim_state(current, NULL); 4026 memalloc_noreclaim_restore(noreclaim_flag); 4027 fs_reclaim_release(sc.gfp_mask); 4028 4029 return nr_reclaimed; 4030} 4031#endif /* CONFIG_HIBERNATION */ 4032 |
4033/* It's optimal to keep kswapds on the same CPUs as their memory, but 4034 not required for correctness. So if the last cpu in a node goes 4035 away, we get changed to run anywhere: as the first one comes back, 4036 restore their cpu bindings. */ 4037static int kswapd_cpu_online(unsigned int cpu) 4038{ 4039 int nid; 4040 4041 for_each_node_state(nid, N_MEMORY) { 4042 pg_data_t *pgdat = NODE_DATA(nid); 4043 const struct cpumask *mask; 4044 4045 mask = cpumask_of_node(pgdat->node_id); 4046 4047 if (cpumask_any_and(cpu_online_mask, mask) < nr_cpu_ids) 4048 /* One of our CPUs online: restore mask */ 4049 set_cpus_allowed_ptr(pgdat->kswapd, mask); 4050 } 4051 return 0; 4052} 4053 | |
4054/* 4055 * This kswapd start function will be called by init and node-hot-add. 4056 * On node-hot-add, kswapd will moved to proper cpus if cpus are hot-added. 4057 */ 4058int kswapd_run(int nid) 4059{ 4060 pg_data_t *pgdat = NODE_DATA(nid); 4061 int ret = 0; --- 23 unchanged lines hidden (view full) --- 4085 if (kswapd) { 4086 kthread_stop(kswapd); 4087 NODE_DATA(nid)->kswapd = NULL; 4088 } 4089} 4090 4091static int __init kswapd_init(void) 4092{ | 4033/* 4034 * This kswapd start function will be called by init and node-hot-add. 4035 * On node-hot-add, kswapd will moved to proper cpus if cpus are hot-added. 4036 */ 4037int kswapd_run(int nid) 4038{ 4039 pg_data_t *pgdat = NODE_DATA(nid); 4040 int ret = 0; --- 23 unchanged lines hidden (view full) --- 4064 if (kswapd) { 4065 kthread_stop(kswapd); 4066 NODE_DATA(nid)->kswapd = NULL; 4067 } 4068} 4069 4070static int __init kswapd_init(void) 4071{ |
4093 int nid, ret; | 4072 int nid; |
4094 4095 swap_setup(); 4096 for_each_node_state(nid, N_MEMORY) 4097 kswapd_run(nid); | 4073 4074 swap_setup(); 4075 for_each_node_state(nid, N_MEMORY) 4076 kswapd_run(nid); |
4098 ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, 4099 "mm/vmscan:online", kswapd_cpu_online, 4100 NULL); 4101 WARN_ON(ret < 0); | |
4102 return 0; 4103} 4104 4105module_init(kswapd_init) 4106 4107#ifdef CONFIG_NUMA 4108/* 4109 * Node reclaim mode --- 221 unchanged lines hidden --- | 4077 return 0; 4078} 4079 4080module_init(kswapd_init) 4081 4082#ifdef CONFIG_NUMA 4083/* 4084 * Node reclaim mode --- 221 unchanged lines hidden --- |