mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Zhen Lei <thunder.leizhen@huawei.com>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
	"Paul E . McKenney" <paulmck@kernel.org>,
	Zhang Qiang1 <qiang1.zhang@intel.com>,
	"Uladzislau Rezki (Sony)" <urezki@gmail.com>
Subject: Re: [PATCH] mm/vmalloc: allow mem_dump_obj() to be called in interrupt context
Date: Mon, 14 Nov 2022 16:54:43 -0800	[thread overview]
Message-ID: <20221114165443.98042d9244ee8899901df164@linux-foundation.org> (raw)
In-Reply-To: <20221112121537.1634-1-thunder.leizhen@huawei.com>

On Sat, 12 Nov 2022 20:15:37 +0800 Zhen Lei <thunder.leizhen@huawei.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.


  reply	other threads:[~2022-11-15  0:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-12 12:15 Zhen Lei
2022-11-15  0:54 ` Andrew Morton [this message]
2022-11-15  2:01   ` Leizhen (ThunderTown)
2022-11-16 14:05     ` Leizhen (ThunderTown)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221114165443.98042d9244ee8899901df164@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=paulmck@kernel.org \
    --cc=qiang1.zhang@intel.com \
    --cc=thunder.leizhen@huawei.com \
    --cc=urezki@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®