diff options
Diffstat (limited to 'mm/util.c')
-rw-r--r-- | mm/util.c | 31 |
1 files changed, 19 insertions, 12 deletions
@@ -4,9 +4,11 @@ | |||
4 | #include <linux/module.h> | 4 | #include <linux/module.h> |
5 | #include <linux/err.h> | 5 | #include <linux/err.h> |
6 | #include <linux/sched.h> | 6 | #include <linux/sched.h> |
7 | #include <linux/tracepoint.h> | ||
8 | #include <asm/uaccess.h> | 7 | #include <asm/uaccess.h> |
9 | 8 | ||
9 | #define CREATE_TRACE_POINTS | ||
10 | #include <trace/events/kmem.h> | ||
11 | |||
10 | /** | 12 | /** |
11 | * kstrdup - allocate space for and copy an existing string | 13 | * kstrdup - allocate space for and copy an existing string |
12 | * @s: the string to duplicate | 14 | * @s: the string to duplicate |
@@ -166,6 +168,10 @@ EXPORT_SYMBOL(krealloc); | |||
166 | * | 168 | * |
167 | * The memory of the object @p points to is zeroed before freed. | 169 | * The memory of the object @p points to is zeroed before freed. |
168 | * If @p is %NULL, kzfree() does nothing. | 170 | * If @p is %NULL, kzfree() does nothing. |
171 | * | ||
172 | * Note: this function zeroes the whole allocated buffer which can be a good | ||
173 | * deal bigger than the requested buffer size passed to kmalloc(). So be | ||
174 | * careful when using this function in performance sensitive code. | ||
169 | */ | 175 | */ |
170 | void kzfree(const void *p) | 176 | void kzfree(const void *p) |
171 | { | 177 | { |
@@ -231,13 +237,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm) | |||
231 | * @pages: array that receives pointers to the pages pinned. | 237 | * @pages: array that receives pointers to the pages pinned. |
232 | * Should be at least nr_pages long. | 238 | * Should be at least nr_pages long. |
233 | * | 239 | * |
234 | * Attempt to pin user pages in memory without taking mm->mmap_sem. | ||
235 | * If not successful, it will fall back to taking the lock and | ||
236 | * calling get_user_pages(). | ||
237 | * | ||
238 | * Returns number of pages pinned. This may be fewer than the number | 240 | * Returns number of pages pinned. This may be fewer than the number |
239 | * requested. If nr_pages is 0 or negative, returns 0. If no pages | 241 | * requested. If nr_pages is 0 or negative, returns 0. If no pages |
240 | * were pinned, returns -errno. | 242 | * were pinned, returns -errno. |
243 | * | ||
244 | * get_user_pages_fast provides equivalent functionality to get_user_pages, | ||
245 | * operating on current and current->mm, with force=0 and vma=NULL. However | ||
246 | * unlike get_user_pages, it must be called without mmap_sem held. | ||
247 | * | ||
248 | * get_user_pages_fast may take mmap_sem and page table locks, so no | ||
249 | * assumptions can be made about lack of locking. get_user_pages_fast is to be | ||
250 | * implemented in a way that is advantageous (vs get_user_pages()) when the | ||
251 | * user memory area is already faulted in and present in ptes. However if the | ||
252 | * pages have to be faulted in, it may turn out to be slightly slower so | ||
253 | * callers need to carefully consider what to use. On many architectures, | ||
254 | * get_user_pages_fast simply falls back to get_user_pages. | ||
241 | */ | 255 | */ |
242 | int __attribute__((weak)) get_user_pages_fast(unsigned long start, | 256 | int __attribute__((weak)) get_user_pages_fast(unsigned long start, |
243 | int nr_pages, int write, struct page **pages) | 257 | int nr_pages, int write, struct page **pages) |
@@ -255,13 +269,6 @@ int __attribute__((weak)) get_user_pages_fast(unsigned long start, | |||
255 | EXPORT_SYMBOL_GPL(get_user_pages_fast); | 269 | EXPORT_SYMBOL_GPL(get_user_pages_fast); |
256 | 270 | ||
257 | /* Tracepoints definitions. */ | 271 | /* Tracepoints definitions. */ |
258 | DEFINE_TRACE(kmalloc); | ||
259 | DEFINE_TRACE(kmem_cache_alloc); | ||
260 | DEFINE_TRACE(kmalloc_node); | ||
261 | DEFINE_TRACE(kmem_cache_alloc_node); | ||
262 | DEFINE_TRACE(kfree); | ||
263 | DEFINE_TRACE(kmem_cache_free); | ||
264 | |||
265 | EXPORT_TRACEPOINT_SYMBOL(kmalloc); | 272 | EXPORT_TRACEPOINT_SYMBOL(kmalloc); |
266 | EXPORT_TRACEPOINT_SYMBOL(kmem_cache_alloc); | 273 | EXPORT_TRACEPOINT_SYMBOL(kmem_cache_alloc); |
267 | EXPORT_TRACEPOINT_SYMBOL(kmalloc_node); | 274 | EXPORT_TRACEPOINT_SYMBOL(kmalloc_node); |