Re: [PATCH] kmemleak: Avoid RCU stalls when freeing metadata for per-CPU pointers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri,  1 Dec 2023 19:08:29 +0000 Catalin Marinas <catalin.marinas@xxxxxxx>
> @@ -1472,14 +1474,27 @@ static void scan_object(struct kmemleak_object *object)
>  		/* already freed object */
>  		goto out;
>  
> -	obj_ptr = object->flags & OBJECT_PHYS ?
> -		  __va((phys_addr_t)object->pointer) :
> -		  (void *)object->pointer;
> +	if (object->flags & OBJECT_PERCPU) {
> +		unsigned int cpu;
>  
> -	if (hlist_empty(&object->area_list) ||
> +		for_each_possible_cpu(cpu) {
> +			void *start = per_cpu_ptr((void __percpu *)object->pointer, cpu);
> +			void *end = start + object->size;
> +
> +			scan_block(start, end, object);
> +
> +			raw_spin_unlock_irqrestore(&object->lock, flags);
> +			cond_resched();
> +			raw_spin_lock_irqsave(&object->lock, flags);

Nit, spin_lock/unlock can be collapsed into need_resched().

			if (need_resched()) {
				raw_spin_unlock_irqrestore(&object->lock, flags);
				cond_resched();
				raw_spin_lock_irqsave(&object->lock, flags);
			}

> +			if (!(object->flags & OBJECT_ALLOCATED))
> +				break;
> +		}
> +	} else if (hlist_empty(&object->area_list) ||




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux