* [PATCH] swap: warn when a swap area overflows the maximum size (resent)
[not found] <1373197450.26573.5.camel@warfang>
@ 2013-07-07 11:52 ` Raymond Jennings
2013-07-07 11:58 ` Raymond Jennings
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Raymond Jennings @ 2013-07-07 11:52 UTC (permalink / raw)
To: Rik van Riel; +Cc: Valdis Kletnieks, linux-kernel, linux-mm
Silly me, wrong email address
On Sun, 2013-07-07 at 04:44 -0700, Raymond Jennings wrote:
swap: warn when a swap area overflows the maximum size
It is possible to swapon a swap area that is too big for the pte width
to handle.
Presently this failure happens silently.
Instead, emit a diagnostic to warn the user.
Signed-off-by: Raymond Jennings <shentino@gmail.com>
Acked-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
----
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 36af6ee..5a4ce53 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1953,6 +1953,12 @@ static unsigned long read_swap_header(struct
swap_info_struct *p,
*/
maxpages = swp_offset(pte_to_swp_entry(
swp_entry_to_pte(swp_entry(0, ~0UL)))) + 1;
+ if (maxpages < swap_header->info.last_page) {
+ printk(KERN_WARNING
+ "Truncating oversized swap area, only using %luk out of %luk
\n",
+ maxpages << (PAGE_SHIFT - 10),
+ swap_header->info.last_page << (PAGE_SHIFT - 10));
+ }
if (maxpages > swap_header->info.last_page) {
maxpages = swap_header->info.last_page + 1;
/* p->max is an unsigned int: don't overflow it */
----
Testing results, root prompt commands and kernel log messages:
# lvresize /dev/system/swap --size 16G
# mkswap /dev/system/swap
# swapon /dev/system/swap
Jul 7 04:27:22 warfang kernel: Adding 16777212k swap
on /dev/mapper/system-swap. Priority:-1 extents:1 across:16777212k
# lvresize /dev/system/swap --size 16G
# mkswap /dev/system/swap
# swapon /dev/system/swap
Jul 7 04:27:22 warfang kernel: Truncating oversized swap area, only
using 33554432k out of 67108860k
Jul 7 04:27:22 warfang kernel: Adding 33554428k swap
on /dev/mapper/system-swap. Priority:-1 extents:1 across:33554428k
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] swap: warn when a swap area overflows the maximum size (resent)
2013-07-07 11:52 ` [PATCH] swap: warn when a swap area overflows the maximum size (resent) Raymond Jennings
@ 2013-07-07 11:58 ` Raymond Jennings
2013-07-07 12:01 ` Raymond Jennings
2013-07-07 19:13 ` [PATCH v2] swap: warn when a swap area overflows the maximum size Raymond Jennings
2 siblings, 0 replies; 6+ messages in thread
From: Raymond Jennings @ 2013-07-07 11:58 UTC (permalink / raw)
To: Rik van Riel
Cc: Valdis Kletnieks, Linux Kernel Mailing List,
Linux Memory Management List
[-- Attachment #1: Type: text/plain, Size: 159 bytes --]
Typo in the second test.
The first line should read:
# lvresize /dev/system/swap --size 64G
First ever serious patch, got excited and burned the copypasta.
[-- Attachment #2: Type: text/html, Size: 665 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] swap: warn when a swap area overflows the maximum size (resent)
2013-07-07 11:52 ` [PATCH] swap: warn when a swap area overflows the maximum size (resent) Raymond Jennings
2013-07-07 11:58 ` Raymond Jennings
@ 2013-07-07 12:01 ` Raymond Jennings
2013-07-07 19:13 ` [PATCH v2] swap: warn when a swap area overflows the maximum size Raymond Jennings
2 siblings, 0 replies; 6+ messages in thread
From: Raymond Jennings @ 2013-07-07 12:01 UTC (permalink / raw)
To: Rik van Riel; +Cc: Valdis Kletnieks, linux-kernel, linux-mm
...I hate you gmail...
On Sun, 2013-07-07 at 04:52 -0700, Raymond Jennings wrote:
> # lvresize /dev/system/swap --size 16G
Typo in the second test.
The first line should read:
# lvresize /dev/system/swap --size 64G
First ever serious patch, got excited and burned the copypasta.
> # mkswap /dev/system/swap
> # swapon /dev/system/swap
>
> Jul 7 04:27:22 warfang kernel: Truncating oversized swap area, only
> using 33554432k out of 67108860k
> Jul 7 04:27:22 warfang kernel: Adding 33554428k swap
> on /dev/mapper/system-swap. Priority:-1 extents:1 across:33554428k
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] swap: warn when a swap area overflows the maximum size
2013-07-07 11:52 ` [PATCH] swap: warn when a swap area overflows the maximum size (resent) Raymond Jennings
2013-07-07 11:58 ` Raymond Jennings
2013-07-07 12:01 ` Raymond Jennings
@ 2013-07-07 19:13 ` Raymond Jennings
2013-07-07 19:31 ` Rik van Riel
2 siblings, 1 reply; 6+ messages in thread
From: Raymond Jennings @ 2013-07-07 19:13 UTC (permalink / raw)
To: Rik van Riel; +Cc: Valdis Kletnieks, linux-kernel, linux-mm
Turned the comparison around for clarity of "bigger than"
No semantic changes, if it still compiles it should do the same thing so
I've omitted the testing this time. Will be happy to retest if required
but I'm on an atom 330 and kernel rebuilds are a nightmare.
----
swap: warn when a swap area overflows the maximum size
It is possible to swapon a swap area that is too big for the pte width
to handle.
Presently this failure happens silently.
Instead, emit a diagnostic to warn the user.
Signed-off-by: Raymond Jennings <shentino@gmail.com>
Acked-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
----
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 36af6ee..5a4ce53 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1953,6 +1953,12 @@ static unsigned long read_swap_header(struct
swap_info_struct *p,
*/
maxpages = swp_offset(pte_to_swp_entry(
swp_entry_to_pte(swp_entry(0, ~0UL)))) + 1;
+ if (swap_header->info.last_page > maxpages) {
+ printk(KERN_WARNING
+ "Truncating oversized swap area, only using %luk
out of %luk
\n",
+ maxpages << (PAGE_SHIFT - 10),
+ swap_header->info.last_page << (PAGE_SHIFT -
10));
+ }
if (maxpages > swap_header->info.last_page) {
maxpages = swap_header->info.last_page + 1;
/* p->max is an unsigned int: don't overflow it */
----
Testing results, root prompt commands and kernel log messages:
# lvresize /dev/system/swap --size 16G
# mkswap /dev/system/swap
# swapon /dev/system/swap
Jul 7 04:27:22 warfang kernel: Adding 16777212k swap
on /dev/mapper/system-swap. Priority:-1 extents:1 across:16777212k
# lvresize /dev/system/swap --size 16G
# mkswap /dev/system/swap
# swapon /dev/system/swap
Jul 7 04:27:22 warfang kernel: Truncating oversized swap area, only
using 33554432k out of 67108860k
Jul 7 04:27:22 warfang kernel: Adding 33554428k swap
on /dev/mapper/system-swap. Priority:-1 extents:1 across:33554428k
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] swap: warn when a swap area overflows the maximum size
2013-07-07 19:13 ` [PATCH v2] swap: warn when a swap area overflows the maximum size Raymond Jennings
@ 2013-07-07 19:31 ` Rik van Riel
2013-07-07 20:56 ` Raymond Jennings
0 siblings, 1 reply; 6+ messages in thread
From: Rik van Riel @ 2013-07-07 19:31 UTC (permalink / raw)
To: Raymond Jennings; +Cc: Valdis Kletnieks, linux-kernel, linux-mm, Andrew Morton
On 07/07/2013 03:13 PM, Raymond Jennings wrote:
> Turned the comparison around for clarity of "bigger than"
>
> No semantic changes, if it still compiles it should do the same thing so
> I've omitted the testing this time. Will be happy to retest if required
> but I'm on an atom 330 and kernel rebuilds are a nightmare.
Added CC: Andrew Morton, since this should probably go into -mm :)
> ----
>
> swap: warn when a swap area overflows the maximum size
>
> It is possible to swapon a swap area that is too big for the pte width
> to handle.
>
> Presently this failure happens silently.
>
> Instead, emit a diagnostic to warn the user.
>
> Signed-off-by: Raymond Jennings <shentino@gmail.com>
> Acked-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
Reviewed-by: Rik van Riel <riel@redhat.com>
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index 36af6ee..5a4ce53 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -1953,6 +1953,12 @@ static unsigned long read_swap_header(struct
> swap_info_struct *p,
> */
> maxpages = swp_offset(pte_to_swp_entry(
> swp_entry_to_pte(swp_entry(0, ~0UL)))) + 1;
> + if (swap_header->info.last_page > maxpages) {
> + printk(KERN_WARNING
> + "Truncating oversized swap area, only using %luk
> out of %luk
> \n",
> + maxpages << (PAGE_SHIFT - 10),
> + swap_header->info.last_page << (PAGE_SHIFT -
> 10));
> + }
> if (maxpages > swap_header->info.last_page) {
> maxpages = swap_header->info.last_page + 1;
> /* p->max is an unsigned int: don't overflow it */
>
> ----
>
> Testing results, root prompt commands and kernel log messages:
>
> # lvresize /dev/system/swap --size 16G
> # mkswap /dev/system/swap
> # swapon /dev/system/swap
>
> Jul 7 04:27:22 warfang kernel: Adding 16777212k swap
> on /dev/mapper/system-swap. Priority:-1 extents:1 across:16777212k
>
> # lvresize /dev/system/swap --size 16G
> # mkswap /dev/system/swap
> # swapon /dev/system/swap
>
> Jul 7 04:27:22 warfang kernel: Truncating oversized swap area, only
> using 33554432k out of 67108860k
> Jul 7 04:27:22 warfang kernel: Adding 33554428k swap
> on /dev/mapper/system-swap. Priority:-1 extents:1 across:33554428k
>
>
--
All rights reversed
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] swap: warn when a swap area overflows the maximum size
2013-07-07 19:31 ` Rik van Riel
@ 2013-07-07 20:56 ` Raymond Jennings
0 siblings, 0 replies; 6+ messages in thread
From: Raymond Jennings @ 2013-07-07 20:56 UTC (permalink / raw)
To: Rik van Riel; +Cc: Valdis Kletnieks, linux-kernel, linux-mm, Andrew Morton
Screwed up and didn't attach my fixed test log to the second version.
See below.
On Sun, 2013-07-07 at 15:31 -0400, Rik van Riel wrote:
> On 07/07/2013 03:13 PM, Raymond Jennings wrote:
> > Turned the comparison around for clarity of "bigger than"
> >
> > No semantic changes, if it still compiles it should do the same thing so
> > I've omitted the testing this time. Will be happy to retest if required
> > but I'm on an atom 330 and kernel rebuilds are a nightmare.
>
> Added CC: Andrew Morton, since this should probably go into -mm :)
>
> > ----
> >
> > swap: warn when a swap area overflows the maximum size
> >
> > It is possible to swapon a swap area that is too big for the pte width
> > to handle.
> >
> > Presently this failure happens silently.
> >
> > Instead, emit a diagnostic to warn the user.
> >
> > Signed-off-by: Raymond Jennings <shentino@gmail.com>
> > Acked-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
>
> Reviewed-by: Rik van Riel <riel@redhat.com>
>
> > diff --git a/mm/swapfile.c b/mm/swapfile.c
> > index 36af6ee..5a4ce53 100644
> > --- a/mm/swapfile.c
> > +++ b/mm/swapfile.c
> > @@ -1953,6 +1953,12 @@ static unsigned long read_swap_header(struct
> > swap_info_struct *p,
> > */
> > maxpages = swp_offset(pte_to_swp_entry(
> > swp_entry_to_pte(swp_entry(0, ~0UL)))) + 1;
> > + if (swap_header->info.last_page > maxpages) {
> > + printk(KERN_WARNING
> > + "Truncating oversized swap area, only using %luk
> > out of %luk
> > \n",
> > + maxpages << (PAGE_SHIFT - 10),
> > + swap_header->info.last_page << (PAGE_SHIFT -
> > 10));
> > + }
> > if (maxpages > swap_header->info.last_page) {
> > maxpages = swap_header->info.last_page + 1;
> > /* p->max is an unsigned int: don't overflow it */
> >
> > ----
> >
> > Testing results, root prompt commands and kernel log messages:
> >
> > # lvresize /dev/system/swap --size 16G
> > # mkswap /dev/system/swap
> > # swapon /dev/system/swap
> >
> > Jul 7 04:27:22 warfang kernel: Adding 16777212k swap
> > on /dev/mapper/system-swap. Priority:-1 extents:1 across:16777212k
> >
> > # lvresize /dev/system/swap --size 16G
On Sun, 2013-07-07 at 04:52 -0700, Raymond Jennings wrote:
> # lvresize /dev/system/swap --size 16G
Typo in the second test.
The first line should read:
# lvresize /dev/system/swap --size 64G
First ever serious patch, got excited and burned the copypasta.
> # mkswap /dev/system/swap
> # swapon /dev/system/swap
> > # mkswap /dev/system/swap
> > # swapon /dev/system/swap
> >
> > Jul 7 04:27:22 warfang kernel: Truncating oversized swap area, only
> > using 33554432k out of 67108860k
> > Jul 7 04:27:22 warfang kernel: Adding 33554428k swap
> > on /dev/mapper/system-swap. Priority:-1 extents:1 across:33554428k
> >
> >
>
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-07-07 20:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1373197450.26573.5.camel@warfang>
2013-07-07 11:52 ` [PATCH] swap: warn when a swap area overflows the maximum size (resent) Raymond Jennings
2013-07-07 11:58 ` Raymond Jennings
2013-07-07 12:01 ` Raymond Jennings
2013-07-07 19:13 ` [PATCH v2] swap: warn when a swap area overflows the maximum size Raymond Jennings
2013-07-07 19:31 ` Rik van Riel
2013-07-07 20:56 ` Raymond Jennings
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).