[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221114165443.98042d9244ee8899901df164@linux-foundation.org>
Date: Mon, 14 Nov 2022 16:54:43 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Zhen Lei <thunder.leizhen@...wei.com>
Cc: <linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>,
"Paul E . McKenney" <paulmck@...nel.org>,
Zhang Qiang1 <qiang1.zhang@...el.com>,
"Uladzislau Rezki (Sony)" <urezki@...il.com>
Subject: Re: [PATCH] mm/vmalloc: allow mem_dump_obj() to be called in
interrupt context
On Sat, 12 Nov 2022 20:15:37 +0800 Zhen Lei <thunder.leizhen@...wei.com> wrote:
> The function mem_dump_obj() can sometimes provide valuable debugging
> information, but it cannot be called in an interrupt context because
> spinlock vmap_area_lock has not been protected against IRQs. If the
> current task has held the lock before hard/soft interrupt handler calls
> mem_dump_obj(), simply abandoning the dump operation can avoid deadlock.
> That is, no deadlock occurs in extreme cases, and dump succeeds in most
> cases.
>
> ...
>
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -4034,6 +4034,9 @@ bool vmalloc_dump_obj(void *object)
> struct vm_struct *vm;
> void *objp = (void *)PAGE_ALIGN((unsigned long)object);
>
> + if (unlikely(spin_is_locked(&vmap_area_lock)))
> + return false;
> +
> vm = find_vm_area(objp);
> if (!vm)
> return false;
Yes, but this will worsen the current uses of this function. Consider
the case where task A wants to call vmalloc_dump_obj() but task B holds
vmap_area_lock. No problem, task A will simply spin until task B is
done.
But after this patch, task A's call to vmalloc_dump_obj() will return
without having done anything.
Powered by blists - more mailing lists