linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anshuman Khandual <khandual@linux.vnet.ibm.com>
To: Joel Stanley <joel@jms.id.au>,
	linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Cc: rusty@rustcorp.com.au, fabf@skynet.be, jk@ozlabs.org,
	akpm@linux-foundation.org
Subject: Re: [PATCH 1/2] kernel/reboot.c: Add orderly_reboot for graceful reboot
Date: Wed, 01 Apr 2015 10:22:08 +0530	[thread overview]
Message-ID: <551B7978.8040502@linux.vnet.ibm.com> (raw)
In-Reply-To: <1427681733-25488-1-git-send-email-joel@jms.id.au>

On 03/30/2015 07:45 AM, Joel Stanley wrote:
> The kernel has orderly_poweroff which allows the kernel to initiate a
> graceful shutdown of userspace, by running /sbin/poweroff. This adds
> orderly_reboot that will cause userspace to shut itself down by calling
> /sbin/reboot.
> 
> This will be used for shutdown initiated by a system controller on
> platforms that do not use ACPI.
> 
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
>  include/linux/reboot.h |  1 +
>  kernel/reboot.c        | 51 +++++++++++++++++++++++++++++++++++++++++++++++---
>  2 files changed, 49 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/reboot.h b/include/linux/reboot.h
> index 48bf152..a4ffcd9 100644
> --- a/include/linux/reboot.h
> +++ b/include/linux/reboot.h
> @@ -68,6 +68,7 @@ void ctrl_alt_del(void);
>  extern char poweroff_cmd[POWEROFF_CMD_PATH_LEN];
>  
>  extern int orderly_poweroff(bool force);
> +extern int orderly_reboot(void);
>  
>  /*
>   * Emergency restart, callable from an interrupt handler.
> diff --git a/kernel/reboot.c b/kernel/reboot.c
> index a3a9e24..d0aa1ec 100644
> --- a/kernel/reboot.c
> +++ b/kernel/reboot.c
> @@ -306,8 +306,9 @@ void ctrl_alt_del(void)
>  }
>  
>  char poweroff_cmd[POWEROFF_CMD_PATH_LEN] = "/sbin/poweroff";
> +char reboot_cmd[POWEROFF_CMD_PATH_LEN] = "/sbin/reboot";

Should not we declare one more REBOOT_CMD_PATH_LEN to make it cleaner.

>  
> -static int __orderly_poweroff(bool force)
> +static int run_cmd(const char *cmd)
>  {
>  	char **argv;
>  	static char *envp[] = {
> @@ -316,8 +317,7 @@ static int __orderly_poweroff(bool force)
>  		NULL
>  	};
>  	int ret;
> -
> -	argv = argv_split(GFP_KERNEL, poweroff_cmd, NULL);
> +	argv = argv_split(GFP_KERNEL, cmd, NULL);
>  	if (argv) {
>  		ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC);
>  		argv_free(argv);
> @@ -325,8 +325,33 @@ static int __orderly_poweroff(bool force)
>  		ret = -ENOMEM;
>  	}
>  
> +	return ret;
> +}
> +
> +static int __orderly_reboot(void)
> +{
> +	int ret;
> +
> +	ret = run_cmd(reboot_cmd);
> +
> +	if (ret) {
> +		pr_warn("Failed to start orderly reboot: forcing the issue\n");
> +		emergency_sync();
> +		kernel_restart(NULL);
> +	}
> +
> +	return ret;
> +}
> +
> +static int __orderly_poweroff(bool force)
> +{
> +	int ret;
> +
> +	ret = run_cmd(reboot_cmd);

Would it be poweroff_cmd instead of reboot_cmd ? Dont see poweroff_cmd getting used.


  parent reply	other threads:[~2015-04-01  4:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-30  2:15 [PATCH 1/2] kernel/reboot.c: Add orderly_reboot for graceful reboot Joel Stanley
2015-03-30  2:15 ` [PATCH 2/2] powerpc/powernv: Reboot when requested by firmware Joel Stanley
2015-03-30  5:32   ` Michael Ellerman
2015-03-31 22:39 ` [PATCH 1/2] kernel/reboot.c: Add orderly_reboot for graceful reboot Andrew Morton
2015-04-01  3:17   ` Joel Stanley
2015-04-01  5:05     ` Anshuman Khandual
2015-04-01  4:52 ` Anshuman Khandual [this message]
2015-04-01  5:03   ` Andrew Morton
2015-04-01  5:05     ` Andrew Morton
2015-04-01  5:32   ` Joel Stanley

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=551B7978.8040502@linux.vnet.ibm.com \
    --to=khandual@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=fabf@skynet.be \
    --cc=jk@ozlabs.org \
    --cc=joel@jms.id.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=rusty@rustcorp.com.au \
    /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;
as well as URLs for NNTP newsgroup(s).