mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: Yunseong Kim <ysk@kzalloc.com>
Cc: Dmitry Vyukov <dvyukov@google.com>,
	Andrey Konovalov <andreyknvl@gmail.com>,
	linux-kernel@vger.kernel.org,
	Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Uladzislau Rezki <urezki@gmail.com>
Subject: Re: [PATCH v2] kcov, usb: Fix invalid context sleep in softirq path on PREEMPT_RT
Date: Sun,  3 Aug 2025 10:34:38 +0800	[thread overview]
Message-ID: <20250803023439.3760-1-hdanton@sina.com> (raw)
In-Reply-To: <20250802142647.139186-3-ysk@kzalloc.com>

On Sat,  2 Aug 2025 14:26:49 +0000 Yunseong Kim wrote:
> @@ -862,7 +879,7 @@ void kcov_remote_start(u64 handle)
>  	if (!in_task() && !in_softirq_really())
>  		return;
>  
> -	local_lock_irqsave(&kcov_percpu_data.lock, flags);
> +	local_irq_save(flags);
>  
>  	/*
>  	 * Check that kcov_remote_start() is not called twice in background
> @@ -870,7 +887,7 @@ void kcov_remote_start(u64 handle)
>  	 */
>  	mode = READ_ONCE(t->kcov_mode);
>  	if (WARN_ON(in_task() && kcov_mode_enabled(mode))) {
> -		local_unlock_irqrestore(&kcov_percpu_data.lock, flags);
> +		local_irq_restore(flags);
>  		return;
>  	}
>  	/*
> @@ -879,15 +896,15 @@ void kcov_remote_start(u64 handle)
>  	 * happened while collecting coverage from a background thread.
>  	 */
>  	if (WARN_ON(in_serving_softirq() && t->kcov_softirq)) {
> -		local_unlock_irqrestore(&kcov_percpu_data.lock, flags);
> +		local_irq_restore(flags);
>  		return;
>  	}
>  
> -	spin_lock(&kcov_remote_lock);
> +	raw_spin_lock(&kcov_remote_lock);
>  	remote = kcov_remote_find(handle);
>  	if (!remote) {
> -		spin_unlock(&kcov_remote_lock);
> -		local_unlock_irqrestore(&kcov_percpu_data.lock, flags);
> +		raw_spin_unlock(&kcov_remote_lock);
> +		local_irq_restore(flags);
>  		return;
>  	}
>  	kcov_debug("handle = %llx, context: %s\n", handle,
> @@ -908,17 +925,17 @@ void kcov_remote_start(u64 handle)
>  		size = CONFIG_KCOV_IRQ_AREA_SIZE;
>  		area = this_cpu_ptr(&kcov_percpu_data)->irq_area;
>  	}
> -	spin_unlock(&kcov_remote_lock);
> +	raw_spin_unlock(&kcov_remote_lock);
>  
>  	/* Can only happen when in_task(). */
>  	if (!area) {
> -		local_unlock_irqrestore(&kcov_percpu_data.lock, flags);
> +		local_irq_restore(flags);
>  		area = vmalloc(size * sizeof(unsigned long));

Given irq disabled for the duration of the coverage collection section [1],
vmalloc does not work here [2].

>  		if (!area) {
>  			kcov_put(kcov);
>  			return;
>  		}
> -		local_lock_irqsave(&kcov_percpu_data.lock, flags);
> +		local_irq_save(flags);
>  	}

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/kcov.h#n73
[2] Subject: [RFC 0/7] vmallloc and non-blocking GFPs
https://lore.kernel.org/all/20250704152537.55724-1-urezki@gmail.com/

  parent reply	other threads:[~2025-08-03  2:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-02 14:26 Yunseong Kim
2025-08-02 21:30 ` Greg Kroah-Hartman
2025-08-02 21:30 ` Greg Kroah-Hartman
2025-08-02 22:01   ` Yunseong Kim
2025-08-03  2:34 ` Hillf Danton [this message]
2025-08-03  3:07   ` Yunseong Kim
2025-08-03  8:49     ` Hillf Danton

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=20250803023439.3760-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=andreyknvl@gmail.com \
    --cc=bigeasy@linutronix.de \
    --cc=dvyukov@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=urezki@gmail.com \
    --cc=ysk@kzalloc.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®