swap: warn when a swap area overflows the maximum size
Subsystems (2)
PATCH 1/1 swap: warn when a swap area overflows the maximum size
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.
----
mm/swapfile.c +0 -0
@@ -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
PATCH 1/1 swap: warn when a swap area overflows the maximum size (resent)
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.
----
mm/swapfile.c +0 -0
@@ -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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH] swap: warn when a swap area overflows the maximum size (resent)
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.
Re: [PATCH] swap: warn when a swap area overflows the maximum size (resent)
In reply to Raymond Jennings...I hate you gmail...
Quoted 1 line · Raymond Jennings
# 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.
Quoted 7 lines
# mkswap /dev/system/swap # swapon /dev/system/swapJul 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 swapon
/dev/mapper/system-swap. Priority:-1 extents:1 across:33554428k
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 1/1 swap: warn when a swap area overflows the maximum size
In reply to Raymond JenningsTurned 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.
----
mm/swapfile.c +0 -0
@@ -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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 5 lines · Raymond Jennings
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 :)
Quoted 7 lines
----
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.
Quoted 6 lines
Presently this failure happens silently.
Instead, emit a diagnostic to warn the user.
Signed-off-by Raymond Jennings <[email protected]>Acked-by Valdis Kletnieks <[email protected]>
Quoted 43 lines
mm/swapfile.c +3
-0@@ -1953,6 +1953,12 @@ static unsigned long read_swap_header(structswap_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 %lukout of %luk
\n",mm/swapfile.c +2
-0+ 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/swapJul 7 04:27:22 warfang kernel: Adding 16777212k swapon
/dev/mapper/system-swap. Priority:-1 extents:1 across:16777212k# lvresize /dev/system/swap --size 16G # mkswap /dev/system/swap # swapon /dev/system/swapJul 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 swapon
/dev/mapper/system-swap. Priority:-1 extents:1 across:33554428k
Signature · 7 lines
All rights reversed -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Screwed up and didn't attach my fixed test log to the second version.
See below.
Quoted 59 lines · Rik van Riel
Quoted 5 lines · Raymond Jennings
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 :)
Quoted 7 lines
----
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.
Quoted 6 lines
Presently this failure happens silently.
Instead, emit a diagnostic to warn the user.
Signed-off-by Raymond Jennings <[email protected]>Acked-by Valdis Kletnieks <[email protected]>Reviewed-by Rik van Riel <[email protected]>Quoted 34 lines
mm/swapfile.c +3
-0@@ -1953,6 +1953,12 @@ static unsigned long read_swap_header(structswap_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 %lukout of %luk
\n",mm/swapfile.c +2
-0+ 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/swapJul 7 04:27:22 warfang kernel: Adding 16777212k swapon
/dev/mapper/system-swap. Priority:-1 extents:1 across:16777212k# lvresize /dev/system/swap --size 16G
Quoted 1 line · Raymond Jennings
# 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.
Quoted 14 lines
# mkswap /dev/system/swap # swapon /dev/system/swapQuoted 9 lines
# mkswap /dev/system/swap # swapon /dev/system/swapJul 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 swapon
/dev/mapper/system-swap. Priority:-1 extents:1 across:33554428k
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>