All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: linux-pm@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
	Pavel Machek <pavel@ucw.cz>, Jiri Slaby <jslaby@suse.cz>,
	Len Brown <lenb@kernel.org>
Subject: Re: [patch 1/1] [PATCH] include storage keys in hibernation image.
Date: Sun, 12 Jun 2011 14:41:34 +0200	[thread overview]
Message-ID: <201106121441.35059.rjw@sisk.pl> (raw)
In-Reply-To: <20110608074648.287491002@de.ibm.com>

On Wednesday, June 08, 2011, Martin Schwidefsky wrote:
> From: Martin Schwidefsky <schwidefsky@de.ibm.com>
> 
> For s390 there is one additional byte associated with each page,
> the storage key. This byte contains the referenced and changed
> bits and needs to be included into the hibernation image.
> If the storage keys are not restored to their previous state all
> original pages would appear to be dirty. This can cause
> inconsistencies e.g. with read-only filesystems.
> 
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Rafael J. Wysocki <rjw@sisk.pl>
> Cc: Jiri Slaby <jslaby@suse.cz>
> Cc: linux-pm@lists.linux-foundation.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-s390@vger.kernel.org
> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
> ---
> 
>  arch/s390/kernel/swsusp_asm64.S |    3 
>  kernel/power/snapshot.c         |  148 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 151 insertions(+)
> 
> diff -urpN linux-2.6/arch/s390/kernel/swsusp_asm64.S linux-2.6-patched/arch/s390/kernel/swsusp_asm64.S
> --- linux-2.6/arch/s390/kernel/swsusp_asm64.S	2011-05-19 06:06:34.000000000 +0200
> +++ linux-2.6-patched/arch/s390/kernel/swsusp_asm64.S	2011-06-06 11:14:43.000000000 +0200
> @@ -138,11 +138,14 @@ swsusp_arch_resume:
>  0:
>  	lg	%r2,8(%r1)
>  	lg	%r4,0(%r1)
> +	iske	%r0,%r4
>  	lghi	%r3,PAGE_SIZE
>  	lghi	%r5,PAGE_SIZE
>  1:
>  	mvcle	%r2,%r4,0
>  	jo	1b
> +	lg	%r2,8(%r1)
> +	sske	%r0,%r2
>  	lg	%r1,16(%r1)
>  	ltgr	%r1,%r1
>  	jnz	0b

I cannot comment on the assembly.

> diff -urpN linux-2.6/kernel/power/snapshot.c linux-2.6-patched/kernel/power/snapshot.c
> --- linux-2.6/kernel/power/snapshot.c	2011-06-06 11:14:39.000000000 +0200
> +++ linux-2.6-patched/kernel/power/snapshot.c	2011-06-06 11:14:43.000000000 +0200
> @@ -1022,6 +1022,137 @@ static inline void copy_data_page(unsign
>  }
>  #endif /* CONFIG_HIGHMEM */
>  
> +#ifdef CONFIG_S390
> +/*
> + * For s390 there is one additional byte associated with each page,
> + * the storage key. The key consists of the access-control bits
> + * (alias the key), the fetch-protection bit, the referenced bit
> + * and the change bit (alias dirty bit). Linux uses only the
> + * referenced bit and the change bit for pages in the page cache.
> + * Any modification of a page will set the change bit, any access
> + * sets the referenced bit. Overindication of the referenced bits
> + * after a hibernation cycle does not cause any harm but the
> + * overindication of the change bits would cause trouble.
> + * Therefore it is necessary to include the storage keys in the
> + * hibernation image. The storage keys are saved to the most
> + * significant byte of each page frame number in the list of pfns
> + * in the hibernation image.
> + */

Let me say that is not exactly straightforward. :-)

One thing I don't really understand is where those storage keys are normally
stored so that they aren't present in the image without this additional
mechanism.  Could you explain that a bit more, please?

> +
> +/*
> + * Key storage is allocated as a linked list of pages.
> + * The size of the keys array is (PAGE_SIZE - sizeof(long))
> + */
> +struct page_key_data {
> +	struct page_key_data *next;
> +	unsigned char data[];
> +};

This seems to be similar to the data structure for the saving of ACPI NVS
memory, so perhaps it's possible to combine the two.

> +#define PAGE_KEY_DATA_SIZE	(PAGE_SIZE - sizeof(struct page_key_data *))
> +
> +static struct page_key_data *page_key_data;
> +static struct page_key_data *page_key_rp, *page_key_wp;
> +static unsigned long page_key_rx, page_key_wx;
> +
> +/*
> + * For each page in the hibernation image one additional byte is
> + * stored in the most significant byte of the page frame number.

I'm not sure it's really worth the complication.  If you simply store those
keys in separete pages, you'd need one additional page per PAGE_SIZE
page frames, so given PAGE_SIZE = 4096 that's one page per 16 MB of memory,
which is not a whole lot (64 extra pages per GB if I'm not mistaken).

It seems that doing it will simplify things quite a git.

Apart from this, I'm not sure that kernel/power/snapshot.c is the right
place for all this S390-specific code.  I'd rather see it in arch/s390.

Thanks,
Rafael

WARNING: multiple messages have this Message-ID (diff)
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pm@lists.linux-foundation.org, Jiri Slaby <jslaby@suse.cz>
Subject: Re: [patch 1/1] [PATCH] include storage keys in hibernation image.
Date: Sun, 12 Jun 2011 14:41:34 +0200	[thread overview]
Message-ID: <201106121441.35059.rjw@sisk.pl> (raw)
In-Reply-To: <20110608074648.287491002@de.ibm.com>

On Wednesday, June 08, 2011, Martin Schwidefsky wrote:
> From: Martin Schwidefsky <schwidefsky@de.ibm.com>
> 
> For s390 there is one additional byte associated with each page,
> the storage key. This byte contains the referenced and changed
> bits and needs to be included into the hibernation image.
> If the storage keys are not restored to their previous state all
> original pages would appear to be dirty. This can cause
> inconsistencies e.g. with read-only filesystems.
> 
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Rafael J. Wysocki <rjw@sisk.pl>
> Cc: Jiri Slaby <jslaby@suse.cz>
> Cc: linux-pm@lists.linux-foundation.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-s390@vger.kernel.org
> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
> ---
> 
>  arch/s390/kernel/swsusp_asm64.S |    3 
>  kernel/power/snapshot.c         |  148 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 151 insertions(+)
> 
> diff -urpN linux-2.6/arch/s390/kernel/swsusp_asm64.S linux-2.6-patched/arch/s390/kernel/swsusp_asm64.S
> --- linux-2.6/arch/s390/kernel/swsusp_asm64.S	2011-05-19 06:06:34.000000000 +0200
> +++ linux-2.6-patched/arch/s390/kernel/swsusp_asm64.S	2011-06-06 11:14:43.000000000 +0200
> @@ -138,11 +138,14 @@ swsusp_arch_resume:
>  0:
>  	lg	%r2,8(%r1)
>  	lg	%r4,0(%r1)
> +	iske	%r0,%r4
>  	lghi	%r3,PAGE_SIZE
>  	lghi	%r5,PAGE_SIZE
>  1:
>  	mvcle	%r2,%r4,0
>  	jo	1b
> +	lg	%r2,8(%r1)
> +	sske	%r0,%r2
>  	lg	%r1,16(%r1)
>  	ltgr	%r1,%r1
>  	jnz	0b

I cannot comment on the assembly.

> diff -urpN linux-2.6/kernel/power/snapshot.c linux-2.6-patched/kernel/power/snapshot.c
> --- linux-2.6/kernel/power/snapshot.c	2011-06-06 11:14:39.000000000 +0200
> +++ linux-2.6-patched/kernel/power/snapshot.c	2011-06-06 11:14:43.000000000 +0200
> @@ -1022,6 +1022,137 @@ static inline void copy_data_page(unsign
>  }
>  #endif /* CONFIG_HIGHMEM */
>  
> +#ifdef CONFIG_S390
> +/*
> + * For s390 there is one additional byte associated with each page,
> + * the storage key. The key consists of the access-control bits
> + * (alias the key), the fetch-protection bit, the referenced bit
> + * and the change bit (alias dirty bit). Linux uses only the
> + * referenced bit and the change bit for pages in the page cache.
> + * Any modification of a page will set the change bit, any access
> + * sets the referenced bit. Overindication of the referenced bits
> + * after a hibernation cycle does not cause any harm but the
> + * overindication of the change bits would cause trouble.
> + * Therefore it is necessary to include the storage keys in the
> + * hibernation image. The storage keys are saved to the most
> + * significant byte of each page frame number in the list of pfns
> + * in the hibernation image.
> + */

Let me say that is not exactly straightforward. :-)

One thing I don't really understand is where those storage keys are normally
stored so that they aren't present in the image without this additional
mechanism.  Could you explain that a bit more, please?

> +
> +/*
> + * Key storage is allocated as a linked list of pages.
> + * The size of the keys array is (PAGE_SIZE - sizeof(long))
> + */
> +struct page_key_data {
> +	struct page_key_data *next;
> +	unsigned char data[];
> +};

This seems to be similar to the data structure for the saving of ACPI NVS
memory, so perhaps it's possible to combine the two.

> +#define PAGE_KEY_DATA_SIZE	(PAGE_SIZE - sizeof(struct page_key_data *))
> +
> +static struct page_key_data *page_key_data;
> +static struct page_key_data *page_key_rp, *page_key_wp;
> +static unsigned long page_key_rx, page_key_wx;
> +
> +/*
> + * For each page in the hibernation image one additional byte is
> + * stored in the most significant byte of the page frame number.

I'm not sure it's really worth the complication.  If you simply store those
keys in separete pages, you'd need one additional page per PAGE_SIZE
page frames, so given PAGE_SIZE = 4096 that's one page per 16 MB of memory,
which is not a whole lot (64 extra pages per GB if I'm not mistaken).

It seems that doing it will simplify things quite a git.

Apart from this, I'm not sure that kernel/power/snapshot.c is the right
place for all this S390-specific code.  I'd rather see it in arch/s390.

Thanks,
Rafael

  reply	other threads:[~2011-06-12 12:41 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-08  7:45 [patch 0/1] [RFC] include storage keys in hibernation image Martin Schwidefsky
2011-06-08  7:45 ` [patch 1/1] [PATCH] " Martin Schwidefsky
2011-06-12 12:41   ` Rafael J. Wysocki [this message]
2011-06-12 12:41     ` Rafael J. Wysocki
2011-06-14  8:50     ` Martin Schwidefsky
2011-06-14 20:50       ` Rafael J. Wysocki
2011-06-15  7:36         ` Martin Schwidefsky
2011-06-15  7:36         ` Martin Schwidefsky
2011-06-15 23:21           ` Rafael J. Wysocki
2011-06-15 23:21           ` Rafael J. Wysocki
2011-07-03 17:46           ` Pavel Machek
2011-07-03 17:46           ` Pavel Machek
2011-07-04  8:09             ` Martin Schwidefsky
2011-07-04  8:09             ` Martin Schwidefsky
2011-07-07 21:36           ` Rafael J. Wysocki
2011-07-07 21:36           ` Rafael J. Wysocki
2011-07-08  8:29             ` Martin Schwidefsky
2011-07-08  8:29             ` Martin Schwidefsky
2011-06-14 20:50       ` Rafael J. Wysocki
2011-06-14  8:50     ` Martin Schwidefsky
2011-07-28 22:01   ` Rafael J. Wysocki
2011-07-28 22:01     ` Rafael J. Wysocki
2011-08-09 15:45     ` Martin Schwidefsky
2011-08-09 19:56       ` Rafael J. Wysocki
2011-08-09 19:56       ` Rafael J. Wysocki
2011-08-09 15:45     ` Martin Schwidefsky
2011-06-08  7:45 ` Martin Schwidefsky
2011-08-16 14:14 [patch 0/1] [patch 0/1] " Martin Schwidefsky
2011-08-16 14:14 ` [patch 1/1] [PATCH] " Martin Schwidefsky
2011-08-16 14:14 ` Martin Schwidefsky
2011-08-16 17:56   ` Rafael J. Wysocki
2011-08-16 17:56   ` Rafael J. Wysocki
2011-08-17  7:43     ` Martin Schwidefsky
2011-08-17  7:43     ` Martin Schwidefsky
2011-08-17  9:15       ` Rafael J. Wysocki
2011-08-17  9:15       ` Rafael J. Wysocki

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=201106121441.35059.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=jslaby@suse.cz \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=schwidefsky@de.ibm.com \
    /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.