diff options
| author | Dmitry Torokhov <[email protected]> | 2023-05-01 15:20:08 -0700 | 
|---|---|---|
| committer | Dmitry Torokhov <[email protected]> | 2023-05-01 15:20:08 -0700 | 
| commit | 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e (patch) | |
| tree | d57f3a63479a07b4e0cece029886e76e04feb984 /mm/util.c | |
| parent | 5dc63e56a9cf8df0b59c234a505a1653f1bdf885 (diff) | |
| parent | 53bea86b5712c7491bb3dae12e271666df0a308c (diff) | |
Merge branch 'next' into for-linus
Prepare input updates for 6.4 merge window.
Diffstat (limited to 'mm/util.c')
| -rw-r--r-- | mm/util.c | 26 | 
1 files changed, 24 insertions, 2 deletions
diff --git a/mm/util.c b/mm/util.c index b56c92fb910f..b8ed9dbc7fd5 100644 --- a/mm/util.c +++ b/mm/util.c @@ -120,7 +120,8 @@ EXPORT_SYMBOL(kstrndup);   * @len: memory region length   * @gfp: GFP mask to use   * - * Return: newly allocated copy of @src or %NULL in case of error + * Return: newly allocated copy of @src or %NULL in case of error, + * result is physically contiguous. Use kfree() to free.   */  void *kmemdup(const void *src, size_t len, gfp_t gfp)  { @@ -134,6 +135,27 @@ void *kmemdup(const void *src, size_t len, gfp_t gfp)  EXPORT_SYMBOL(kmemdup);  /** + * kvmemdup - duplicate region of memory + * + * @src: memory region to duplicate + * @len: memory region length + * @gfp: GFP mask to use + * + * Return: newly allocated copy of @src or %NULL in case of error, + * result may be not physically contiguous. Use kvfree() to free. + */ +void *kvmemdup(const void *src, size_t len, gfp_t gfp) +{ +	void *p; + +	p = kvmalloc(len, gfp); +	if (p) +		memcpy(p, src, len); +	return p; +} +EXPORT_SYMBOL(kvmemdup); + +/**   * kmemdup_nul - Create a NUL-terminated string from unterminated data   * @s: The data to stringify   * @len: The size of the data @@ -945,7 +967,7 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)  	if (percpu_counter_read_positive(&vm_committed_as) < allowed)  		return 0;  error: -	pr_warn_ratelimited("%s: pid: %d, comm: %s, no enough memory for the allocation\n", +	pr_warn_ratelimited("%s: pid: %d, comm: %s, not enough memory for the allocation\n",  			    __func__, current->pid, current->comm);  	vm_unacct_memory(pages);  |