All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Vivek Kumar <quic_vivekuma@quicinc.com>
Cc: corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org,
	tglx@linutronix.de, maz@kernel.org, axboe@kernel.dk,
	rafael@kernel.org, akpm@linux-foundation.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-block@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-mm@kvack.org, len.brown@intel.com, pavel@ucw.cz,
	paulmck@kernel.org, bp@suse.de, keescook@chromium.org,
	songmuchun@bytedance.com, rdunlap@infradead.org,
	damien.lemoal@opensource.wdc.com, pasha.tatashin@soleen.com,
	tabba@google.com, ardb@kernel.org, tsoni@quicinc.com,
	quic_psodagud@quicinc.com, quic_svaddagi@quicinc.com
Subject: Re: [RFC 0/6] Bootloader based hibernation
Date: Fri, 20 May 2022 17:43:26 +0100	[thread overview]
Message-ID: <YofFLih8LML9U5rc@FVFF77S0Q05N> (raw)
In-Reply-To: <1652860121-24092-1-git-send-email-quic_vivekuma@quicinc.com>

Hi,

On Wed, May 18, 2022 at 01:18:35PM +0530, Vivek Kumar wrote:
> Kernel Hibernation
> 
> Linux Kernel has been already supporting hibernation, a process which
> involves freezing of all userspace tasks, followed by quiescing of all
> kernel device drivers and then a DDR snapshot is taken which is saved
> to disc-swap partition, after the save, the system can either shutdown
> or continue further. Generally during the next power cycle when kernel
> boots and after probing almost all of the drivers, in the late_init()
> part, it checks if a hibernation image is present in the specified swap
> slot, if a valid hibernation image is found, it superimposes the currently
> executing Kernel with an older kernel from the snapshot, moving further,
> it calls the restore of the drivers and unfreezes the userspace tasks.
> CONFIG_HIBERNATION and a designated swap partition needs to be present
> for to enable Hibernation.
> 
> Bootloader Based Hibernation:
> 
> Automotive usecases require better boot KPIs, Hence we are proposing a
> bootloader based hibernation restore.

At a high-level, I'm not a fan of adding new ways to enter the kernel, and for
the same reasons that the existing hibernate handover is deliberately *not* a
stable ABI, I don't think we should add an ABI for this. This is not going to
remain maintainable or compatible over time as the kernel evolves.

> Purpose of bootloader based hibernation is to improve the overall boot time
> till the first display frame is seen on the screen or a camera application
> can be launched from userspace after the power on reset key is pressed.

Can you break down the time taken for that today?

What does a cold boot look like?

What *exactly* are you trying to skip by using hibernation?

Thanks,
Mark.

> This RFC patchset
> implements a slightly tweaked version of hibernation in which the
> restoration of an older snapshot into DDR is being carried out from the
> bootloader (ABL) itself, by doing this we are saving some time
> (1 second measured on msm-4.14 Kernel) by not running a
> temporary kernel and figuring out the hibernation image at late_init().
> In order to achieve the same bootloader checks for the hibernation
> image at a very early stage from swap partition, it parses the image and
> loads it in the DDR instead of loading boot image form boot partition.
> Since we are not running the temporary kernel,which would have done some
> basic ARM related setup like, MMU enablement, EL2 setup, CPU setup etc,
> entry point into hibernation snapshot image directly from bootloader is
> different, on similar lines, all device drivers are now re-programming
> the IO-mapped registers as part of the restore callback (which is
> triggered from the hibernation framework) to bring back the HW/SW sync.
> 
> Other factors like, read-speed of the secondary storage device and
> organization of the hibernation image in the swap partition effects the
> total image restore time and the overall boot time. In our current
> implementation we have serialized the allocation of swap-partition's slots
> in kernel, so when hibernation image is being saved to disc, each page is
> not scattered across various swap-slot offsets, rather it in a serial
> manner. For example, if a DDR page at Page frame number 0x8005 is
> located at a swap-slot offset 50, the next valid DDR page at PFN 0x8005
> will be preset at the swap-slot offset 51. With this optimization in
> place, bootloader can utilize the max capacity of issuing a disc-read
> for reading a bigger chunk (~50 MBs at once) from the swap slot,
> and also parsing of the image becomes simpler as it is available
> contiguously.
> 
> 
> 
> Vivek Kumar (6):
>   arm64: hibernate: Introduce new entry point to kernel
>   PM: Hibernate: Add option to disable disk offset randomization
>   block: gendisk: Add a new genhd capability flag
>   mm: swap: Add randomization check for swapon/off calls
>   Hibernate: Add check for pte_valid in saveable page
>   irqchip/gic-v3: Re-init GIC hardware upon hibernation restore
> 
>  Documentation/admin-guide/kernel-parameters.txt |  11 ++
>  arch/arm64/kernel/hibernate.c                   |   9 ++
>  drivers/irqchip/irq-gic-v3.c                    | 138 ++++++++++++++++-
>  include/linux/blkdev.h                          |   1 +
>  kernel/power/snapshot.c                         |  43 ++++++++
>  kernel/power/swap.c                             |  12 +++
>  mm/swapfile.c                                   |   6 +-
>  7 files changed, 216 insertions(+), 4 deletions(-)
> 
> -- 
> 2.7.4
> 

WARNING: multiple messages have this Message-ID (diff)
From: Mark Rutland <mark.rutland@arm.com>
To: Vivek Kumar <quic_vivekuma@quicinc.com>
Cc: corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org,
	tglx@linutronix.de, maz@kernel.org, axboe@kernel.dk,
	rafael@kernel.org, akpm@linux-foundation.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-block@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-mm@kvack.org, len.brown@intel.com, pavel@ucw.cz,
	paulmck@kernel.org, bp@suse.de, keescook@chromium.org,
	songmuchun@bytedance.com, rdunlap@infradead.org,
	damien.lemoal@opensource.wdc.com, pasha.tatashin@soleen.com,
	tabba@google.com, ardb@kernel.org, tsoni@quicinc.com,
	quic_psodagud@quicinc.com, quic_svaddagi@quicinc.com
Subject: Re: [RFC 0/6] Bootloader based hibernation
Date: Fri, 20 May 2022 17:43:26 +0100	[thread overview]
Message-ID: <YofFLih8LML9U5rc@FVFF77S0Q05N> (raw)
In-Reply-To: <1652860121-24092-1-git-send-email-quic_vivekuma@quicinc.com>

Hi,

On Wed, May 18, 2022 at 01:18:35PM +0530, Vivek Kumar wrote:
> Kernel Hibernation
> 
> Linux Kernel has been already supporting hibernation, a process which
> involves freezing of all userspace tasks, followed by quiescing of all
> kernel device drivers and then a DDR snapshot is taken which is saved
> to disc-swap partition, after the save, the system can either shutdown
> or continue further. Generally during the next power cycle when kernel
> boots and after probing almost all of the drivers, in the late_init()
> part, it checks if a hibernation image is present in the specified swap
> slot, if a valid hibernation image is found, it superimposes the currently
> executing Kernel with an older kernel from the snapshot, moving further,
> it calls the restore of the drivers and unfreezes the userspace tasks.
> CONFIG_HIBERNATION and a designated swap partition needs to be present
> for to enable Hibernation.
> 
> Bootloader Based Hibernation:
> 
> Automotive usecases require better boot KPIs, Hence we are proposing a
> bootloader based hibernation restore.

At a high-level, I'm not a fan of adding new ways to enter the kernel, and for
the same reasons that the existing hibernate handover is deliberately *not* a
stable ABI, I don't think we should add an ABI for this. This is not going to
remain maintainable or compatible over time as the kernel evolves.

> Purpose of bootloader based hibernation is to improve the overall boot time
> till the first display frame is seen on the screen or a camera application
> can be launched from userspace after the power on reset key is pressed.

Can you break down the time taken for that today?

What does a cold boot look like?

What *exactly* are you trying to skip by using hibernation?

Thanks,
Mark.

> This RFC patchset
> implements a slightly tweaked version of hibernation in which the
> restoration of an older snapshot into DDR is being carried out from the
> bootloader (ABL) itself, by doing this we are saving some time
> (1 second measured on msm-4.14 Kernel) by not running a
> temporary kernel and figuring out the hibernation image at late_init().
> In order to achieve the same bootloader checks for the hibernation
> image at a very early stage from swap partition, it parses the image and
> loads it in the DDR instead of loading boot image form boot partition.
> Since we are not running the temporary kernel,which would have done some
> basic ARM related setup like, MMU enablement, EL2 setup, CPU setup etc,
> entry point into hibernation snapshot image directly from bootloader is
> different, on similar lines, all device drivers are now re-programming
> the IO-mapped registers as part of the restore callback (which is
> triggered from the hibernation framework) to bring back the HW/SW sync.
> 
> Other factors like, read-speed of the secondary storage device and
> organization of the hibernation image in the swap partition effects the
> total image restore time and the overall boot time. In our current
> implementation we have serialized the allocation of swap-partition's slots
> in kernel, so when hibernation image is being saved to disc, each page is
> not scattered across various swap-slot offsets, rather it in a serial
> manner. For example, if a DDR page at Page frame number 0x8005 is
> located at a swap-slot offset 50, the next valid DDR page at PFN 0x8005
> will be preset at the swap-slot offset 51. With this optimization in
> place, bootloader can utilize the max capacity of issuing a disc-read
> for reading a bigger chunk (~50 MBs at once) from the swap slot,
> and also parsing of the image becomes simpler as it is available
> contiguously.
> 
> 
> 
> Vivek Kumar (6):
>   arm64: hibernate: Introduce new entry point to kernel
>   PM: Hibernate: Add option to disable disk offset randomization
>   block: gendisk: Add a new genhd capability flag
>   mm: swap: Add randomization check for swapon/off calls
>   Hibernate: Add check for pte_valid in saveable page
>   irqchip/gic-v3: Re-init GIC hardware upon hibernation restore
> 
>  Documentation/admin-guide/kernel-parameters.txt |  11 ++
>  arch/arm64/kernel/hibernate.c                   |   9 ++
>  drivers/irqchip/irq-gic-v3.c                    | 138 ++++++++++++++++-
>  include/linux/blkdev.h                          |   1 +
>  kernel/power/snapshot.c                         |  43 ++++++++
>  kernel/power/swap.c                             |  12 +++
>  mm/swapfile.c                                   |   6 +-
>  7 files changed, 216 insertions(+), 4 deletions(-)
> 
> -- 
> 2.7.4
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2022-05-20 16:43 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-18  7:48 [RFC 0/6] Bootloader based hibernation Vivek Kumar
2022-05-18  7:48 ` Vivek Kumar
2022-05-18  7:48 ` [RFC 1/6] arm64: hibernate: Introduce new entry point to kernel Vivek Kumar
2022-05-18  7:48   ` Vivek Kumar
2022-05-19 15:27   ` Marc Zyngier
2022-05-19 15:27     ` Marc Zyngier
2022-05-18  7:48 ` [RFC 2/6] PM: Hibernate: Add option to disable disk offset randomization Vivek Kumar
2022-05-18  7:48   ` Vivek Kumar
2022-05-18 12:19   ` Andrew Lunn
2022-05-18 12:19     ` Andrew Lunn
2022-05-18 13:00   ` Christoph Hellwig
2022-05-18 13:00     ` Christoph Hellwig
2022-05-23 20:49   ` Randy Dunlap
2022-05-23 20:49     ` Randy Dunlap
2022-05-18  7:48 ` [RFC 3/6] block: gendisk: Add a new genhd capability flag Vivek Kumar
2022-05-18  7:48   ` Vivek Kumar
2022-05-18  8:08   ` Christoph Hellwig
2022-05-18  8:08     ` Christoph Hellwig
2022-05-18  7:48 ` [RFC 4/6] mm: swap: Add randomization check for swapon/off calls Vivek Kumar
2022-05-18  7:48   ` Vivek Kumar
2022-05-18 12:27   ` Andrew Lunn
2022-05-18 12:27     ` Andrew Lunn
2022-05-18  7:48 ` [RFC 5/6] Hibernate: Add check for pte_valid in saveable page Vivek Kumar
2022-05-18  7:48   ` Vivek Kumar
2022-05-18 13:09   ` Christoph Hellwig
2022-05-18 13:09     ` Christoph Hellwig
2022-05-18  7:48 ` [RFC 6/6] irqchip/gic-v3: Re-init GIC hardware upon hibernation restore Vivek Kumar
2022-05-18  7:48   ` Vivek Kumar
2022-05-19  7:59   ` Marc Zyngier
2022-05-19  7:59     ` Marc Zyngier
2022-05-18 16:55 ` [RFC 0/6] Bootloader based hibernation Pasha Tatashin
2022-05-18 16:55   ` Pasha Tatashin
2022-05-20 16:43 ` Mark Rutland [this message]
2022-05-20 16:43   ` Mark Rutland

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=YofFLih8LML9U5rc@FVFF77S0Q05N \
    --to=mark.rutland@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=ardb@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=bp@suse.de \
    --cc=catalin.marinas@arm.com \
    --cc=corbet@lwn.net \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=keescook@chromium.org \
    --cc=len.brown@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=pasha.tatashin@soleen.com \
    --cc=paulmck@kernel.org \
    --cc=pavel@ucw.cz \
    --cc=quic_psodagud@quicinc.com \
    --cc=quic_svaddagi@quicinc.com \
    --cc=quic_vivekuma@quicinc.com \
    --cc=rafael@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=songmuchun@bytedance.com \
    --cc=tabba@google.com \
    --cc=tglx@linutronix.de \
    --cc=tsoni@quicinc.com \
    --cc=will@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.