From: "Sukrit.Bhatnagar@sony.com" <Sukrit.Bhatnagar@sony.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Pavel Machek <pavel@ucw.cz>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Christian Brauner <brauner@kernel.org>,
"Darrick J. Wong" <djwong@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
"linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: RE: [PATCH 0/2] Improve dmesg output for swapfile+hibernation
Date: Fri, 31 May 2024 14:15:43 +0000 [thread overview]
Message-ID: <TYAPR01MB4048E8F253CBFE44EBF9836CF6FC2@TYAPR01MB4048.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <ZlSDinoWgqLt21QD@infradead.org>
On 2024-05-27 21:58, Christoph Hellwig wrote:
> On Mon, May 27, 2024 at 12:51:07PM +0000, Sukrit.Bhatnagar@sony.com wrote:
>> In my understanding, the resume offset in hibernate is used as follows.
>>
>> Suspend
>> - Hibernate looks up the swap/swapfile using the details we pass in the
>> sysfs entries, in the function swsusp_swap_check():
>> * /sys/power/resume - path/uuid/major:minor of the swap partition (or
>> non-swap partition for swapfile)
>> * /sys/power/resume_offset - physical offset of the swapfile in that
>> partition
>> * If no resume device is specified, it just uses the first available
>> swap! - It then proceeds to write the image to the specified swap.
>> (The allocation of swap pages is done by the swapfile code
>> internally.)
>
> Where "it" is userspace code? If so, that already seems unsafe for
> a swap device, but definitely is a no-go for a swapfile.
By "it", I meant the hibernate code running in kernel space.
Once userspace triggers hibernation by `echo disk > /sys/power/state`
or a systemd wrapper program etc., and userspace tasks are frozen,
everything happens within kernel context.
>> - Hibernate gets the partition and offset values from kernel command-line
>> parameters "resume" and "resume_offset" (which must be set from
>> userspace, not ideal).
>
> Or is it just for these parameters? In which case we "only" need to
> specify the swap file, which would then need code in the file system
> driver to resolve the logical to physical mapping as swap files don't
> need to be contiguous.
Yes, it is just for setting these parameters in sysfs entries and in kernel
commandline.
I think specifying the swapfile path *may* not work because when we resume
from hibernation, the filesystems are not yet mounted (except for the case
when someone is resuming from initramfs stage).
Using the block device + physical offset, this procedure becomes Independent
of the filesystem and the mounted status.
And since the system swap information is lost on reboot/shutdown, the kernel
which loads the hibernation image will not know what swaps were enabled
when the image was created.
--
Sukrit
prev parent reply other threads:[~2024-05-31 14:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-22 7:46 Sukrit Bhatnagar
2024-05-22 7:46 ` [PATCH 1/2] iomap: swap: print warning for unaligned swapfile Sukrit Bhatnagar
2024-05-22 18:02 ` Chris Li
2024-05-27 10:54 ` Sukrit.Bhatnagar
2024-05-22 7:46 ` [PATCH 2/2] mm: swap: print starting physical block offset in swapon Sukrit Bhatnagar
2024-05-22 14:56 ` Darrick J. Wong
2024-05-22 14:59 ` Christoph Hellwig
2024-05-27 11:02 ` Sukrit.Bhatnagar
2024-05-23 19:45 ` [PATCH 0/2] Improve dmesg output for swapfile+hibernation Pavel Machek
2024-05-27 11:06 ` Sukrit.Bhatnagar
2024-05-27 11:20 ` Christoph Hellwig
2024-05-27 12:51 ` Sukrit.Bhatnagar
2024-05-27 12:58 ` Christoph Hellwig
2024-05-31 14:15 ` Sukrit.Bhatnagar [this message]
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=TYAPR01MB4048E8F253CBFE44EBF9836CF6FC2@TYAPR01MB4048.jpnprd01.prod.outlook.com \
--to=sukrit.bhatnagar@sony.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=djwong@kernel.org \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=rafael@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