Re: [PATCH 1/2] mm: vmalloc_bytes()

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

 



On Tue, 27 Feb 2024 02:25:14 -0500 Kent Overstreet <kent.overstreet@xxxxxxxxx> wrote:

> Add a __ksize() equivalent for vmalloc.
> +++ b/mm/vmalloc.c
> @@ -2848,6 +2848,26 @@ void vfree(const void *addr)
>  }
>  EXPORT_SYMBOL(vfree);
>  
> +/**
> + * vmalloc_bytes - Return size of a vmalloc() allocation
> + * @addr:  Memory base address
> + *
> + * Returns the size of the allocation as passed to vmalloc() rounded up to
> + * PAGE_SIZE; does not include extra internal allocations.
> + */
> +size_t vmalloc_bytes(const void *addr)
> +{
> +	struct vm_struct *vm = find_vm_area(addr);
> +	if (unlikely(!vm)) {
> +		WARN(1, KERN_ERR "vmalloc_bytes() called on nonexistent vm area (%p)\n",
> +		     addr);
> +		return 0;

	if (WARN(!vm, "..."))

and I don't think the explicit KERN_ERR facility is needed?





[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