The patch titled
slab: removes local_irq_save()/local_irq_restore() pair
has been added to the -mm tree. Its filename is
slab-removes-local_irq_save-local_irq_restore-pair.patch
Patches currently in -mm which might be from [EMAIL PROTECTED] are
slab-removes-local_irq_save-local_irq_restore-pair.patch
ipc-add-generic-struct-ipc_ids-seq_file-iteration.patch
ipc-convert-proc-sysvipc-to-generic-seq_file-interface.patch
numa-aware-slab-allocator-v5.patch
slab-leak-detector.patch
update-kfree-vfree-and-vunmap-kerneldoc.patch
From: Manfred Spraul <[EMAIL PROTECTED]>
Proposed by and based on a patch from Eric Dumazet <[EMAIL PROTECTED]>:
This patch removes unnecessary critical section in ksize() function, as
cli/sti are rather expensive on modern CPUS.
It additionally adds a docbook entry for ksize() and further simplifies the
code.
Signed-Off-By: Manfred Spraul <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---
mm/slab.c | 26 +++++++++++++++-----------
1 files changed, 15 insertions(+), 11 deletions(-)
diff -puN mm/slab.c~slab-removes-local_irq_save-local_irq_restore-pair mm/slab.c
--- devel/mm/slab.c~slab-removes-local_irq_save-local_irq_restore-pair
2005-08-21 22:30:01.000000000 -0700
+++ devel-akpm/mm/slab.c 2005-08-21 22:30:01.000000000 -0700
@@ -3069,20 +3069,24 @@ ssize_t slabinfo_write(struct file *file
}
#endif
+/**
+ * ksize - get the actual amount of memory allocated for a given object
+ * @objp: Pointer to the object
+ *
+ * kmalloc may internally round up allocations and return more memory
+ * than requested. ksize() can be used to determine the actual amount of
+ * memory allocated. The caller may use this additional memory, even though
+ * a smaller amount of memory was initially specified with the kmalloc call.
+ * The caller must guarantee that objp points to a valid object previously
+ * allocated with either kmalloc() or kmem_cache_alloc(). The object
+ * must not be freed during the duration of the call.
+ */
unsigned int ksize(const void *objp)
{
- kmem_cache_t *c;
- unsigned long flags;
- unsigned int size = 0;
-
- if (likely(objp != NULL)) {
- local_irq_save(flags);
- c = GET_PAGE_CACHE(virt_to_page(objp));
- size = kmem_cache_size(c);
- local_irq_restore(flags);
- }
+ if (unlikely(objp == NULL))
+ return 0;
- return size;
+ return obj_reallen(GET_PAGE_CACHE(virt_to_page(objp)));
}
_
-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html