hugetlb.c (cb8e59cc87201af93dfbb6c3dccc8fcad72a09c2) | hugetlb.c (ae94da898133947c2d1f005da10838478e4548db) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Generic hugetlb support. 4 * (C) Nadia Yvette Chambers, April 2004 5 */ 6#include <linux/list.h> 7#include <linux/init.h> 8#include <linux/mm.h> --- 3242 unchanged lines hidden (view full) --- 3251 BUG_ON(!hugetlb_fault_mutex_table); 3252 3253 for (i = 0; i < num_fault_mutexes; i++) 3254 mutex_init(&hugetlb_fault_mutex_table[i]); 3255 return 0; 3256} 3257subsys_initcall(hugetlb_init); 3258 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Generic hugetlb support. 4 * (C) Nadia Yvette Chambers, April 2004 5 */ 6#include <linux/list.h> 7#include <linux/init.h> 8#include <linux/mm.h> --- 3242 unchanged lines hidden (view full) --- 3251 BUG_ON(!hugetlb_fault_mutex_table); 3252 3253 for (i = 0; i < num_fault_mutexes; i++) 3254 mutex_init(&hugetlb_fault_mutex_table[i]); 3255 return 0; 3256} 3257subsys_initcall(hugetlb_init); 3258 |
3259/* Overwritten by architectures with more huge page sizes */ 3260bool __init __attribute((weak)) arch_hugetlb_valid_size(unsigned long size) 3261{ 3262 return size == HPAGE_SIZE; 3263} 3264 |
|
3259/* Should be called on processing a hugepagesz=... option */ 3260void __init hugetlb_bad_size(void) 3261{ 3262 parsed_valid_hugepagesz = false; 3263} 3264 3265void __init hugetlb_add_hstate(unsigned int order) 3266{ --- 59 unchanged lines hidden (view full) --- 3326 hugetlb_hstate_alloc_pages(parsed_hstate); 3327 3328 last_mhp = mhp; 3329 3330 return 1; 3331} 3332__setup("hugepages=", hugetlb_nrpages_setup); 3333 | 3265/* Should be called on processing a hugepagesz=... option */ 3266void __init hugetlb_bad_size(void) 3267{ 3268 parsed_valid_hugepagesz = false; 3269} 3270 3271void __init hugetlb_add_hstate(unsigned int order) 3272{ --- 59 unchanged lines hidden (view full) --- 3332 hugetlb_hstate_alloc_pages(parsed_hstate); 3333 3334 last_mhp = mhp; 3335 3336 return 1; 3337} 3338__setup("hugepages=", hugetlb_nrpages_setup); 3339 |
3334static int __init hugetlb_default_setup(char *s) | 3340static int __init default_hugepagesz_setup(char *s) |
3335{ | 3341{ |
3336 default_hstate_size = memparse(s, &s); | 3342 unsigned long size; 3343 3344 size = (unsigned long)memparse(s, NULL); 3345 3346 if (!arch_hugetlb_valid_size(size)) { 3347 pr_err("HugeTLB: unsupported default_hugepagesz %s\n", s); 3348 return 0; 3349 } 3350 3351 default_hstate_size = size; |
3337 return 1; 3338} | 3352 return 1; 3353} |
3339__setup("default_hugepagesz=", hugetlb_default_setup); | 3354__setup("default_hugepagesz=", default_hugepagesz_setup); |
3340 3341static unsigned int cpuset_mems_nr(unsigned int *array) 3342{ 3343 int node; 3344 unsigned int nr = 0; 3345 3346 for_each_node_mask(node, cpuset_current_mems_allowed) 3347 nr += array[node]; 3348 3349 return nr; 3350} 3351 3352#ifdef CONFIG_SYSCTL 3353static int hugetlb_sysctl_handler_common(bool obey_mempolicy, 3354 struct ctl_table *table, int write, | 3355 3356static unsigned int cpuset_mems_nr(unsigned int *array) 3357{ 3358 int node; 3359 unsigned int nr = 0; 3360 3361 for_each_node_mask(node, cpuset_current_mems_allowed) 3362 nr += array[node]; 3363 3364 return nr; 3365} 3366 3367#ifdef CONFIG_SYSCTL 3368static int hugetlb_sysctl_handler_common(bool obey_mempolicy, 3369 struct ctl_table *table, int write, |
3355 void *buffer, size_t *length, loff_t *ppos) | 3370 void __user *buffer, size_t *length, loff_t *ppos) |
3356{ 3357 struct hstate *h = &default_hstate; 3358 unsigned long tmp = h->max_huge_pages; 3359 int ret; 3360 3361 if (!hugepages_supported()) 3362 return -EOPNOTSUPP; 3363 --- 6 unchanged lines hidden (view full) --- 3370 if (write) 3371 ret = __nr_hugepages_store_common(obey_mempolicy, h, 3372 NUMA_NO_NODE, tmp, *length); 3373out: 3374 return ret; 3375} 3376 3377int hugetlb_sysctl_handler(struct ctl_table *table, int write, | 3371{ 3372 struct hstate *h = &default_hstate; 3373 unsigned long tmp = h->max_huge_pages; 3374 int ret; 3375 3376 if (!hugepages_supported()) 3377 return -EOPNOTSUPP; 3378 --- 6 unchanged lines hidden (view full) --- 3385 if (write) 3386 ret = __nr_hugepages_store_common(obey_mempolicy, h, 3387 NUMA_NO_NODE, tmp, *length); 3388out: 3389 return ret; 3390} 3391 3392int hugetlb_sysctl_handler(struct ctl_table *table, int write, |
3378 void *buffer, size_t *length, loff_t *ppos) | 3393 void __user *buffer, size_t *length, loff_t *ppos) |
3379{ 3380 3381 return hugetlb_sysctl_handler_common(false, table, write, 3382 buffer, length, ppos); 3383} 3384 3385#ifdef CONFIG_NUMA 3386int hugetlb_mempolicy_sysctl_handler(struct ctl_table *table, int write, | 3394{ 3395 3396 return hugetlb_sysctl_handler_common(false, table, write, 3397 buffer, length, ppos); 3398} 3399 3400#ifdef CONFIG_NUMA 3401int hugetlb_mempolicy_sysctl_handler(struct ctl_table *table, int write, |
3387 void *buffer, size_t *length, loff_t *ppos) | 3402 void __user *buffer, size_t *length, loff_t *ppos) |
3388{ 3389 return hugetlb_sysctl_handler_common(true, table, write, 3390 buffer, length, ppos); 3391} 3392#endif /* CONFIG_NUMA */ 3393 3394int hugetlb_overcommit_handler(struct ctl_table *table, int write, | 3403{ 3404 return hugetlb_sysctl_handler_common(true, table, write, 3405 buffer, length, ppos); 3406} 3407#endif /* CONFIG_NUMA */ 3408 3409int hugetlb_overcommit_handler(struct ctl_table *table, int write, |
3395 void *buffer, size_t *length, loff_t *ppos) | 3410 void __user *buffer, 3411 size_t *length, loff_t *ppos) |
3396{ 3397 struct hstate *h = &default_hstate; 3398 unsigned long tmp; 3399 int ret; 3400 3401 if (!hugepages_supported()) 3402 return -EOPNOTSUPP; 3403 --- 2215 unchanged lines hidden --- | 3412{ 3413 struct hstate *h = &default_hstate; 3414 unsigned long tmp; 3415 int ret; 3416 3417 if (!hugepages_supported()) 3418 return -EOPNOTSUPP; 3419 --- 2215 unchanged lines hidden --- |