The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	Daniel Vetter <daniel.vetter@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>, Will Deacon <will.deacon@arm.com>,
	Petr Mladek <pmladek@suse.com>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	John Ogness <john.ogness@linutronix.de>,
	linux-kernel@vger.kernel.org, Nicolai Stange <nstange@suse.de>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] RFC: x86/smp: use printk_deferred in native_smp_send_reschedule
Date: Wed, 8 May 2019 16:44:20 +0900	[thread overview]
Message-ID: <20190508074420.GB15704@jagdpanzerIV> (raw)
In-Reply-To: <20190507173329.17031-1-daniel.vetter@ffwll.ch>

On (05/07/19 19:33), Daniel Vetter wrote:
[..]
> - make the console_trylock trylock also the spinlock. This works in
>   the limited case of the console_lock use-case, but doesn't fix the
>   same semaphore.lock acquisition in the up() path in console_unlock,
>   which we can't avoid with a trylock.
> 
> - move the wake_up_process in up() out from under the semaphore.lock
>   spinlock critical section. Again this works for the limited case of
>   the console_lock, and does fully break the cycle for this lock.
>   Unfortunately there's still plenty of scheduler related locks that
>   wake_up_process needs, so the loop is still there, just with a few
>   less locks involved.
> 
> Hence now third attempt, trying to fix this by using printk_deferred()
> instead of the normal printk that WARN() uses.
> native_smp_send_reschedule is only called from scheduler related code,
> which has to use printk_deferred due to this locking recursion, so
> this seems consistent.
> 
> It has the unfortunate downside that we're losing the backtrace though
> (I didn't find a printk_deferred version of WARN, and I'm not sure
> it's a bright idea to dump that much using printk_deferred.)

I'm catching up with the emails now (was offline for almost 2 weeks),
so I haven't seen [yet] all of the previous patches/discussions.

[..]
>  static void native_smp_send_reschedule(int cpu)
>  {
>  	if (unlikely(cpu_is_offline(cpu))) {
> -		WARN(1, "sched: Unexpected reschedule of offline CPU#%d!\n", cpu);
> +		printk_deferred(KERN_WARNING
> +				"sched: Unexpected reschedule of offline CPU#%d!\n", cpu);
>  		return;
>  	}
>  	apic->send_IPI(cpu, RESCHEDULE_VECTOR);

Hmm,
One thing to notice here is that the CPU in question is offline-ed,
and printk_deferred() is a per-CPU type of deferred printk(). So the
following thing

	__this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT);
	irq_work_queue(this_cpu_ptr(&wake_up_klogd_work));

might not print anything at all. In this particular case we always
need another CPU to do console_unlock(), since this_cpu() is not
really expected to do wake_up_klogd_work_func()->console_unlock().

	-ss

  reply	other threads:[~2019-05-08  7:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-07 17:33 [PATCH] RFC: x86/smp: use printk_deferred in native_smp_send_reschedule Daniel Vetter
2019-05-08  7:44 ` Sergey Senozhatsky [this message]
2019-05-08  7:53   ` Sergey Senozhatsky
2019-05-08  8:06     ` Daniel Vetter
2019-05-08  8:24       ` Sergey Senozhatsky
2019-05-08  8:14     ` Daniel Vetter
2019-05-08  8:25   ` Daniel Vetter

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=20190508074420.GB15704@jagdpanzerIV \
    --to=sergey.senozhatsky.work@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nstange@suse.de \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.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