public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Shuge <shugelinux@gmail.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, Kevin <kevin@allwinnertech.com>,
	linux-serial@vger.kernel.org,
	Russell King <linux@arm.linux.org.uk>, Tejun Heo <tj@kernel.org>
Subject: Re: [BUG]: when printk too more through serial, cpu up is failed.
Date: Fri, 15 Mar 2013 09:26:26 +0800	[thread overview]
Message-ID: <514278C2.3020900@gmail.com> (raw)
In-Reply-To: <20130314140553.GA4895@kroah.com>

于 2013年03月14日 22:05, Greg KH 写道:
> On Thu, Mar 14, 2013 at 09:51:34PM +0800, Shuge wrote:
>> Hi all,
>>      When the kernel printk too many log, the cpu is failed to come online.
>> The problem is this:
>> For example, cpu0 bring up cpu1:
>>
>>        a. cpu0 call cpu_up:
>>           cpu_up()
>>           ->_cpu_up()
>>              ->__cpu_notify(CPU_UP_PREPARE)
>>              ->__cpu_up()
>>                 ->boot_secondary()
>> #       ->wait_for_completion_timeout(&cpu_running, msecs_to_jiffires(1000))
>>           -> if (!cpu_online(cpu)) {
>>                    pr_crit("CPU%u: failed to come online\n", cpu);
>>                    ret = -EIO;
>>                }
>>           ->cpu_notify(CPU_ONLINE)
>>
>>        b. cpu1 enter kernel:
>>        secondary_start_kernel()
>> @   ->printk("CPU%u: Booted secondary processor\n", cpu)
>> *   ->calibrate_delay()
>>        ->set_cpu_online()
>>        ->complete(cpu_running)
>>          ->cpumask_set_cpu()
>>
>>     While cpu0 run to mark #,  which wait that cpu1 complete
>> cpu_running, and set online.
>> Generally, cpu0 can get it. But if the __log_buf is too large or
>> other threads write
>> it unceasing, then cpu1 come to mark @ or * in this moment. Cpu1 is
>> busy outputing
>> buffer, which cost time more than 1s, and cpu1 have not join in
>> sched, so cpu0 wait it timeout.
>>     By reading printk.c, I found that can_use_console() always return
>> true, which be called by
>> console_trylock_for_printk(). Because, have_callable_console()
>> return ture always, if the console
>> driver set CON_ANYTIME flag. I think that cpu should not output the
>> __log_buf in coming online,
>> even though have_callable_console() is true.
>>
>> /*
>>   * Can we actually use the console at this time on this cpu?
>>   *
>>   * Console drivers may assume that per-cpu resources have
>>   * been allocated. So unless they're explicitly marked as
>>   * being able to cope (CON_ANYTIME) don't call them until
>>   * this CPU is officially up.
>>   */
>> static inline int can_use_console(unsigned int cpu)
>> {
>>      return cpu_online(cpu) || have_callable_console();
>> }
>>
>> In can_use_console, why not is &&, but ||?
>>
>> Kernel Version: 3.3.0
> Why such an old and obsolete kernel version?  Please try this on 3.8,
> lots of work have gone into the printk area that should have solved this
> issue.
>
> greg k-h

I saw the printk.c in version 3.9, it still check 
console_trylock_for_printk() to decide to call console_unlock. In 
vprintk_emit(), cpu1 also have the opportunity to execute 
console_unlock() at coming online time.
Once cpu which is coming online can output buffer, nothing can interrupt 
it until buffer is empty.But we can't ensure that none always write the 
__log_buf. It is danger! I think, the solution is that we should prevent 
to use console at coming online.

  reply	other threads:[~2013-03-15  1:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-14 13:51 [BUG]: when printk too more through serial, cpu up is failed Shuge
2013-03-14 14:05 ` Greg KH
2013-03-15  1:26   ` Shuge [this message]
2013-03-15 15:03     ` Greg KH

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=514278C2.3020900@gmail.com \
    --to=shugelinux@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kevin@allwinnertech.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=tj@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