mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: liguang <lig.fnst@cn.fujitsu.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	David Howells <dhowells@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Michael Kerrisk <mtk.manpages@gmail.com>,
	Dave Jones <davej@redhat.com>, Kees Cook <keescook@chromium.org>,
	Cyrill Gorcunov <gorcunov@openvz.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] sys: remove kernel_shutdown_prepare's parameter
Date: Fri, 31 May 2013 15:58:02 -0700	[thread overview]
Message-ID: <20130531155802.5d0b24958e11783553e5cd00@linux-foundation.org> (raw)
In-Reply-To: <1369900686-5936-2-git-send-email-lig.fnst@cn.fujitsu.com>

On Thu, 30 May 2013 15:58:04 +0800 liguang <lig.fnst@cn.fujitsu.com> wrote:

> kernel_shutdown_prepare's parameter can be removed
> by checking global 'system_state', so, maybe we
> can save a register to be used :-).
> 
> --- a/kernel/sys.c
> +++ b/kernel/sys.c
> @@ -382,11 +382,10 @@ void kernel_restart(char *cmd)
>  }
>  EXPORT_SYMBOL_GPL(kernel_restart);
>  
> -static void kernel_shutdown_prepare(enum system_states state)
> +static void kernel_shutdown_prepare(void)
>  {
>  	blocking_notifier_call_chain(&reboot_notifier_list,
> -		(state == SYSTEM_HALT)?SYS_HALT:SYS_POWER_OFF, NULL);
> -	system_state = state;
> +		(system_state == SYSTEM_HALT)?SYS_HALT:SYS_POWER_OFF, NULL);
>  	usermodehelper_disable();
>  	device_shutdown();
>  }
> @@ -397,7 +396,7 @@ static void kernel_shutdown_prepare(enum system_states state)
>   */
>  void kernel_halt(void)
>  {
> -	kernel_shutdown_prepare(SYSTEM_HALT);
> +	kernel_shutdown_prepare();
>  	disable_nonboot_cpus();
>  	syscore_shutdown();
>  	printk(KERN_EMERG "System halted.\n");
> @@ -414,7 +413,7 @@ EXPORT_SYMBOL_GPL(kernel_halt);
>   */
>  void kernel_power_off(void)
>  {
> -	kernel_shutdown_prepare(SYSTEM_POWER_OFF);
> +	kernel_shutdown_prepare();
>  	if (pm_power_off_prepare)
>  		pm_power_off_prepare();
>  	disable_nonboot_cpus();
> @@ -484,11 +483,13 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
>  		break;
>  
>  	case LINUX_REBOOT_CMD_HALT:
> +		system_state = SYSTEM_HALT;
>  		kernel_halt();
>  		do_exit(0);
>  		panic("cannot halt");
>  
>  	case LINUX_REBOOT_CMD_POWER_OFF:
> +		system_state = SYSTEM_POWER_OFF;
>  		kernel_power_off();
>  		do_exit(0);
>  		break;

No, this changes behavior for all other callers of kernel_halt() and
kernel_power_off(): system_state will no longer be updated for those
callers.

And passing an argument via a global variable is not nice :(

  reply	other threads:[~2013-05-31 22:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-30  7:58 [PATCH 1/4] sys: remove unnecesscary parameter of set_one_prio liguang
2013-05-30  7:58 ` [PATCH 2/4] sys: remove kernel_shutdown_prepare's parameter liguang
2013-05-31 22:58   ` Andrew Morton [this message]
2013-05-30  7:58 ` [PATCH 3/4] sys/reboot: boolize C_A_D liguang
2013-05-31 23:02   ` Andrew Morton
2013-06-03  0:25     ` li guang
2013-06-03  1:09     ` Joe Perches
2013-05-30  7:58 ` [PATCH 4/4] sys: fix malformed panic massage of reboot liguang
2013-05-30  8:08 ` [PATCH 1/4] sys: remove unnecesscary parameter of set_one_prio Joe Perches
2013-05-31 23:07   ` Andrew Morton
2013-05-31 22:53 ` Andrew Morton

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=20130531155802.5d0b24958e11783553e5cd00@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=davej@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=gorcunov@openvz.org \
    --cc=keescook@chromium.org \
    --cc=lig.fnst@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    /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®