• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/mm/

Lines Matching refs:object

50  *   Note that the kmemleak_object.use_count is incremented when an object is
108 #define MSECS_MIN_AGE 5000 /* minimum object age for reporting */
131 * object->lock. Insertions or deletions from object_list, gray_list or
138 unsigned long flags; /* object status flags */
143 /* object usage count; object freed when use_count == 0 */
149 /* the total number of pointers found pointing to this object */
153 /* memory ranges to be scanned inside an object (empty for all) */
164 /* flag set after the first reporting of an unreference object */
166 /* flag set to not scan the object */
182 /* prio search tree for object boundaries */
219 * Early object allocation/freeing logging. Kmemleak is initialized after the
279 * with the object->lock held.
282 struct kmemleak_object *object)
284 const u8 *ptr = (const u8 *)object->pointer;
290 min(object->size, (size_t)(HEX_MAX_LINES * HEX_ROW_SIZE));
306 * - white - orphan object, not enough references to it (count < min_count)
311 * Newly created objects don't have any color assigned (object->count == -1)
314 static bool color_white(const struct kmemleak_object *object)
316 return object->count != KMEMLEAK_BLACK &&
317 object->count < object->min_count;
320 static bool color_gray(const struct kmemleak_object *object)
322 return object->min_count != KMEMLEAK_BLACK &&
323 object->count >= object->min_count;
331 static bool unreferenced_object(struct kmemleak_object *object)
333 return (color_white(object) && object->flags & OBJECT_ALLOCATED) &&
334 time_before_eq(object->jiffies + jiffies_min_age,
340 * print_unreferenced function must be called with the object->lock held.
343 struct kmemleak_object *object)
346 unsigned int msecs_age = jiffies_to_msecs(jiffies - object->jiffies);
348 seq_printf(seq, "unreferenced object 0x%08lx (size %zu):\n",
349 object->pointer, object->size);
351 object->comm, object->pid, object->jiffies,
353 hex_dump_object(seq, object);
356 for (i = 0; i < object->trace_len; i++) {
357 void *ptr = (void *)object->trace[i];
365 * the object->lock held.
367 static void dump_object_info(struct kmemleak_object *object)
371 trace.nr_entries = object->trace_len;
372 trace.entries = object->trace;
375 object->tree_node.start, object->size);
377 object->comm, object->pid, object->jiffies);
378 pr_notice(" min_count = %d\n", object->min_count);
379 pr_notice(" count = %d\n", object->count);
380 pr_notice(" flags = 0x%lx\n", object->flags);
381 pr_notice(" checksum = %d\n", object->checksum);
396 struct kmemleak_object *object;
401 object = prio_tree_entry(node, struct kmemleak_object,
403 if (!alias && object->pointer != ptr) {
404 pr_warning("Found object by alias at 0x%08lx\n", ptr);
406 dump_object_info(object);
407 object = NULL;
410 object = NULL;
412 return object;
416 * Increment the object use_count. Return 1 if successful or 0 otherwise. Note
417 * that once an object's use_count reached 0, the RCU freeing was already
418 * registered and the object should no longer be used. This function must be
421 static int get_object(struct kmemleak_object *object)
423 return atomic_inc_not_zero(&object->use_count);
433 struct kmemleak_object *object =
438 * code accessing this object, hence no need for locking.
440 hlist_for_each_entry_safe(area, elem, tmp, &object->area_list, node) {
444 kmem_cache_free(object_cache, object);
448 * Decrement the object use_count. Once the count is 0, free the object using
454 static void put_object(struct kmemleak_object *object)
456 if (!atomic_dec_and_test(&object->use_count))
460 WARN_ON(object->flags & OBJECT_ALLOCATED);
462 call_rcu(&object->rcu, free_object_rcu);
466 * Look up an object in the prio search tree and increase its use_count.
471 struct kmemleak_object *object = NULL;
476 object = lookup_object(ptr, alias);
479 /* check whether the object is still available */
480 if (object && !get_object(object))
481 object = NULL;
484 return object;
511 struct kmemleak_object *object;
514 object = kmem_cache_alloc(object_cache, gfp & GFP_KMEMLEAK_MASK);
515 if (!object) {
520 INIT_LIST_HEAD(&object->object_list);
521 INIT_LIST_HEAD(&object->gray_list);
522 INIT_HLIST_HEAD(&object->area_list);
523 spin_lock_init(&object->lock);
524 atomic_set(&object->use_count, 1);
525 object->flags = OBJECT_ALLOCATED;
526 object->pointer = ptr;
527 object->size = size;
528 object->min_count = min_count;
529 object->count = 0; /* white color initially */
530 object->jiffies = jiffies;
531 object->checksum = 0;
535 object->pid = 0;
536 strncpy(object->comm, "hardirq", sizeof(object->comm));
538 object->pid = 0;
539 strncpy(object->comm, "softirq", sizeof(object->comm));
541 object->pid = current->pid;
548 strncpy(object->comm, current->comm, sizeof(object->comm));
552 object->trace_len = __save_stack_trace(object->trace);
554 INIT_PRIO_TREE_NODE(&object->tree_node);
555 object->tree_node.start = ptr;
556 object->tree_node.last = ptr + size - 1;
562 node = prio_tree_insert(&object_tree_root, &object->tree_node);
569 if (node != &object->tree_node) {
570 kmemleak_stop("Cannot insert 0x%lx into the object search tree "
572 object = lookup_object(ptr, 1);
573 spin_lock(&object->lock);
574 dump_object_info(object);
575 spin_unlock(&object->lock);
579 list_add_tail_rcu(&object->object_list, &object_list);
582 return object;
589 static void __delete_object(struct kmemleak_object *object)
594 prio_tree_remove(&object_tree_root, &object->tree_node);
595 list_del_rcu(&object->object_list);
598 WARN_ON(!(object->flags & OBJECT_ALLOCATED));
599 WARN_ON(atomic_read(&object->use_count) < 2);
605 spin_lock_irqsave(&object->lock, flags);
606 object->flags &= ~OBJECT_ALLOCATED;
607 spin_unlock_irqrestore(&object->lock, flags);
608 put_object(object);
617 struct kmemleak_object *object;
619 object = find_and_get_object(ptr, 0);
620 if (!object) {
622 kmemleak_warn("Freeing unknown object at 0x%08lx\n",
627 __delete_object(object);
628 put_object(object);
638 struct kmemleak_object *object;
641 object = find_and_get_object(ptr, 1);
642 if (!object) {
644 kmemleak_warn("Partially freeing unknown object at 0x%08lx "
649 __delete_object(object);
658 start = object->pointer;
659 end = object->pointer + object->size;
661 create_object(start, ptr - start, object->min_count,
664 create_object(ptr + size, end - ptr - size, object->min_count,
667 put_object(object);
670 static void __paint_it(struct kmemleak_object *object, int color)
672 object->min_count = color;
674 object->flags |= OBJECT_NO_SCAN;
677 static void paint_it(struct kmemleak_object *object, int color)
681 spin_lock_irqsave(&object->lock, flags);
682 __paint_it(object, color);
683 spin_unlock_irqrestore(&object->lock, flags);
688 struct kmemleak_object *object;
690 object = find_and_get_object(ptr, 0);
691 if (!object) {
692 kmemleak_warn("Trying to color unknown object "
698 paint_it(object, color);
699 put_object(object);
703 * Mark an object permanently as gray-colored so that it can no longer be
712 * Mark the object as black-colored so that it is ignored from scans and
721 * Add a scanning area to the object. If at least one such area is added,
727 struct kmemleak_object *object;
730 object = find_and_get_object(ptr, 1);
731 if (!object) {
732 kmemleak_warn("Adding scan area to unknown object at 0x%08lx\n",
743 spin_lock_irqsave(&object->lock, flags);
744 if (ptr + size > object->pointer + object->size) {
745 kmemleak_warn("Scan area larger than object 0x%08lx\n", ptr);
746 dump_object_info(object);
755 hlist_add_head(&area->node, &object->area_list);
757 spin_unlock_irqrestore(&object->lock, flags);
759 put_object(object);
763 * Set the OBJECT_NO_SCAN flag for the object corresponding to the give
764 * pointer. Such object will not be scanned by kmemleak but references to it
770 struct kmemleak_object *object;
772 object = find_and_get_object(ptr, 0);
773 if (!object) {
774 kmemleak_warn("Not scanning unknown object at 0x%08lx\n", ptr);
778 spin_lock_irqsave(&object->lock, flags);
779 object->flags |= OBJECT_NO_SCAN;
780 spin_unlock_irqrestore(&object->lock, flags);
781 put_object(object);
822 struct kmemleak_object *object;
830 * RCU locking needed to ensure object is not freed via put_object().
833 object = create_object((unsigned long)log->ptr, log->size,
835 if (!object)
837 spin_lock_irqsave(&object->lock, flags);
839 object->trace[i] = log->trace[i];
840 object->trace_len = log->trace_len;
841 spin_unlock_irqrestore(&object->lock, flags);
847 * kmemleak_alloc - register a newly allocated object
848 * @ptr: pointer to beginning of the object
849 * @size: size of the object
850 * @min_count: minimum number of references to this object. If during memory
852 * the object is reported as a memory leak. If @min_count is 0,
853 * the object is never reported as a leak. If @min_count is -1,
854 * the object is ignored (not scanned and not reported as a leak)
857 * This function is called from the kernel allocators when a new object
873 * kmemleak_free - unregister a previously registered object
874 * @ptr: pointer to beginning of the object
876 * This function is called from the kernel allocators when an object (memory
891 * kmemleak_free_part - partially unregister a previously registered object
892 * @ptr: pointer to the beginning or inside the object. This also
911 * kmemleak_not_leak - mark an allocated object as false positive
912 * @ptr: pointer to beginning of the object
914 * Calling this function on an object will cause the memory block to no longer
929 * kmemleak_ignore - ignore an allocated object
930 * @ptr: pointer to beginning of the object
932 * Calling this function on an object will cause the memory block to be
949 * kmemleak_scan_area - limit the range to be scanned in an allocated object
950 * @ptr: pointer to beginning or inside the object. This also
955 * This function is used when it is known that only certain parts of an object
971 * kmemleak_no_scan - do not scan an allocated object
972 * @ptr: pointer to beginning of the object
975 * in situations where it is known that the given object does not contain any
991 * Update an object's checksum and return true if it was modified.
993 static bool update_checksum(struct kmemleak_object *object)
995 u32 old_csum = object->checksum;
997 if (!kmemcheck_is_obj_initialized(object->pointer, object->size))
1000 object->checksum = crc32(0, (void *)object->pointer, object->size);
1001 return object->checksum != old_csum;
1037 struct kmemleak_object *object;
1053 object = find_and_get_object(pointer, 1);
1054 if (!object)
1056 if (object == scanned) {
1058 put_object(object);
1063 * Avoid the lockdep recursive warning on object->lock being
1067 spin_lock_irqsave_nested(&object->lock, flags,
1069 if (!color_white(object)) {
1071 spin_unlock_irqrestore(&object->lock, flags);
1072 put_object(object);
1077 * Increase the object's reference count (number of pointers
1079 * minimum, the object's color will become gray and it will be
1082 object->count++;
1083 if (color_gray(object)) {
1084 list_add_tail(&object->gray_list, &gray_list);
1085 spin_unlock_irqrestore(&object->lock, flags);
1089 spin_unlock_irqrestore(&object->lock, flags);
1090 put_object(object);
1096 * that object->use_count >= 1.
1098 static void scan_object(struct kmemleak_object *object)
1105 * Once the object->lock is acquired, the corresponding memory block
1108 spin_lock_irqsave(&object->lock, flags);
1109 if (object->flags & OBJECT_NO_SCAN)
1111 if (!(object->flags & OBJECT_ALLOCATED))
1112 /* already freed object */
1114 if (hlist_empty(&object->area_list)) {
1115 void *start = (void *)object->pointer;
1116 void *end = (void *)(object->pointer + object->size);
1118 while (start < end && (object->flags & OBJECT_ALLOCATED) &&
1119 !(object->flags & OBJECT_NO_SCAN)) {
1121 object, 0);
1124 spin_unlock_irqrestore(&object->lock, flags);
1126 spin_lock_irqsave(&object->lock, flags);
1129 hlist_for_each_entry(area, elem, &object->area_list, node)
1132 object, 0);
1134 spin_unlock_irqrestore(&object->lock, flags);
1143 struct kmemleak_object *object, *tmp;
1150 object = list_entry(gray_list.next, typeof(*object), gray_list);
1151 while (&object->gray_list != &gray_list) {
1156 scan_object(object);
1158 tmp = list_entry(object->gray_list.next, typeof(*object),
1161 /* remove the object from the list and release it */
1162 list_del(&object->gray_list);
1163 put_object(object);
1165 object = tmp;
1178 struct kmemleak_object *object;
1186 list_for_each_entry_rcu(object, &object_list, object_list) {
1187 spin_lock_irqsave(&object->lock, flags);
1191 * 1 reference to any object at this point.
1193 if (atomic_read(&object->use_count) > 1) {
1194 pr_debug("object->use_count = %d\n",
1195 atomic_read(&object->use_count));
1196 dump_object_info(object);
1199 /* reset the reference count (whiten the object) */
1200 object->count = 0;
1201 if (color_gray(object) && get_object(object))
1202 list_add_tail(&object->gray_list, &gray_list);
1204 spin_unlock_irqrestore(&object->lock, flags);
1267 list_for_each_entry_rcu(object, &object_list, object_list) {
1268 spin_lock_irqsave(&object->lock, flags);
1269 if (color_white(object) && (object->flags & OBJECT_ALLOCATED)
1270 && update_checksum(object) && get_object(object)) {
1272 object->count = object->min_count;
1273 list_add_tail(&object->gray_list, &gray_list);
1275 spin_unlock_irqrestore(&object->lock, flags);
1294 list_for_each_entry_rcu(object, &object_list, object_list) {
1295 spin_lock_irqsave(&object->lock, flags);
1296 if (unreferenced_object(object) &&
1297 !(object->flags & OBJECT_REPORTED)) {
1298 object->flags |= OBJECT_REPORTED;
1301 spin_unlock_irqrestore(&object->lock, flags);
1375 * Iterate over the object_list and return the first valid object at or after
1381 struct kmemleak_object *object;
1390 list_for_each_entry_rcu(object, &object_list, object_list) {
1393 if (get_object(object))
1396 object = NULL;
1398 return object;
1402 * Return the next object in the object_list. The function decrements the
1403 * use_count of the previous object and increases that of the next one.
1424 * Decrement the use_count of the last object required, if any.
1441 * Print the information for an unreferenced object to the seq file.
1445 struct kmemleak_object *object = v;
1448 spin_lock_irqsave(&object->lock, flags);
1449 if ((object->flags & OBJECT_REPORTED) && unreferenced_object(object))
1450 print_unreferenced(seq, object);
1451 spin_unlock_irqrestore(&object->lock, flags);
1478 struct kmemleak_object *object;
1482 object = find_and_get_object(addr, 0);
1483 if (!object) {
1484 pr_info("Unknown object at 0x%08lx\n", addr);
1488 spin_lock_irqsave(&object->lock, flags);
1489 dump_object_info(object);
1490 spin_unlock_irqrestore(&object->lock, flags);
1492 put_object(object);
1504 struct kmemleak_object *object;
1508 list_for_each_entry_rcu(object, &object_list, object_list) {
1509 spin_lock_irqsave(&object->lock, flags);
1510 if ((object->flags & OBJECT_REPORTED) &&
1511 unreferenced_object(object))
1512 __paint_it(object, KMEMLEAK_GREY);
1513 spin_unlock_irqrestore(&object->lock, flags);
1531 * dump=... - dump information about the object found at the given address
1604 struct kmemleak_object *object;
1610 list_for_each_entry_rcu(object, &object_list, object_list)
1611 delete_object_full(object->pointer);