mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Leizhen (ThunderTown)" <thunder.leizhen@huawei.com>
To: Zqiang <qiang1.zhang@intel.com>, <paulmck@kernel.org>,
	<frederic@kernel.org>, <joel@joelfernandes.org>
Cc: <rcu@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] rcu: Make vmalloc_dump_obj() call in a preemptible context
Date: Thu, 17 Nov 2022 09:43:11 +0800	[thread overview]
Message-ID: <bbcb265f-0731-47c7-3a04-976504b95915@huawei.com> (raw)
In-Reply-To: <20221116141511.3695680-1-qiang1.zhang@intel.com>



On 2022/11/16 22:15, Zqiang wrote:
> Currently, the mem_dump_obj() is invoked in call_rcu(), the

Plan to call mem_dump_obj() in rcu_do_batch().

> call_rcu() is maybe invoked in non-preemptive code segment,
> for object allocated from vmalloc(), the following scenarios
> may occur:
> 
> 	CPU 0
> tasks context
>    spin_lock(&vmap_area_lock)
>           Interrupt context
> 	      call_rcu()
> 		mem_dump_obj
>                   vmalloc_dump_obj
>                     spin_lock(&vmap_area_lock) <--deadlock
> 
> and for PREEMPT-RT kernel, the spinlock will convert to sleepable
> lock, it also make vmap_area_lock spinlock can not acquire in
> non-preemptive code segment. therefore, this commit make the
> vmalloc_dump_obj() call in a preemptible context.
> 
> Signed-off-by: Zqiang <qiang1.zhang@intel.com>
> ---
>  mm/util.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/util.c b/mm/util.c
> index 12984e76767e..465f8b8824ca 100644
> --- a/mm/util.c
> +++ b/mm/util.c
> @@ -1124,8 +1124,12 @@ void mem_dump_obj(void *object)
>  		return;
>  	}
>  
> -	if (vmalloc_dump_obj(object))
> -		return;
> +	if (is_vmalloc_addr(object)) {
> +		if (preemptible() && vmalloc_dump_obj(object))

preemptible() --> !in_interrupt()?

> +			return;
> +		type = "vmalloc memory";
> +		goto end;
> +	}

Move into vmalloc_dump_obj()?

>  
>  	if (virt_addr_valid(object))
>  		type = "non-slab/vmalloc memory";
> @@ -1135,7 +1139,7 @@ void mem_dump_obj(void *object)
>  		type = "zero-size pointer";
>  	else
>  		type = "non-paged memory";
> -
> +end:
>  	pr_cont(" %s\n", type);
>  }
>  EXPORT_SYMBOL_GPL(mem_dump_obj);
> 

-- 
Regards,
  Zhen Lei

  reply	other threads:[~2022-11-17  1:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16 14:15 Zqiang
2022-11-17  1:43 ` Leizhen (ThunderTown) [this message]
2022-11-17  5:20   ` Zhang, Qiang1
2022-11-17  7:04     ` 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=bbcb265f-0731-47c7-3a04-976504b95915@huawei.com \
    --to=thunder.leizhen@huawei.com \
    --cc=frederic@kernel.org \
    --cc=joel@joelfernandes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=qiang1.zhang@intel.com \
    --cc=rcu@vger.kernel.org \
    /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®