Check return code in mm/vmscan.c
Subsystems (4)
PATCH 1/1 Check return code in mm/vmscan.c
http://www.anomalistic.org/patches/vmscan-check-ret-kernel_thread-fix-2.6.1-rc1-mm1.patch
mm/vmscan.c +8 -2
@@ -1093,10 +1093,16 @@static int __init kswapd_init (void ) { +int ret;pg_data_t *pgdat;swap_setup (); -for_each_pgdat (pgdat) -kernel_thread (kswapd, pgdat,CLONE_KERNEL ); +for_each_pgdat (pgdat) { + ret =kernel_thread (kswapd, pgdat,CLONE_KERNEL ); +if (ret <0 ) { +printk ("%s: unable to start kernel thread\n" , __FUNCTION__); +return ret; + } + } total_memory =nr_free_pagecache_pages ();return 0 ; }
Signature · 8 lines
Eugene TEO <[email protected]> <http://www.anomalistic.org/> 1024D/14A0DDE5 print D851 4574 E357 469C D308 A01E 7321 A38A 14A0 DDE5 main(i) { putchar(182623909 >> (i-1) * 5&31|!!(i<7)<<6) && main(++i); } _______________________________________________ Kernel-janitors mailing list [email protected] http://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 Check return code in
http://www.anomalistic.org/patches/setup-check-ret-alloc_bootmem_low-fix-2.6.1-rc1-mm1.patch
arch/i386/kernel/setup.c +6 -0
@@ -17,6 +17,8 @@* Provisions for empty E820 memory regions (reported by certain BIOSes). * Alex Achenbach <[email protected]>, December 2002. * +* Check the return value of alloc_bootmem_low. +* Eugene Teo <[email protected]>, January 2004. */ /*
@@ -875,6 +877,10 @@if (e820.map[i].addr + e820.map[i].size >0x100000000ULL )continue ; res =alloc_bootmem_low (sizeof (struct resource )); +if (!res) { +printk (KERN_ERR "Cannot allocate lowmem\n" ); +return ; + }switch (e820.map[i].type) {case E820_RAM : res->name ="System RAM" ;break ;case E820_ACPI : res->name ="ACPI Tables" ;break ;
Signature · 8 lines
Eugene TEO <[email protected]> <http://www.anomalistic.org/> 1024D/14A0DDE5 print D851 4574 E357 469C D308 A01E 7321 A38A 14A0 DDE5 main(i) { putchar(182623909 >> (i-1) * 5&31|!!(i<7)<<6) && main(++i); } _______________________________________________ Kernel-janitors mailing list [email protected] http://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 Check return code in mm/pdflush.c
In reply to Eugene Teohttp://www.anomalistic.org/patches/pdflush-check-ret-kernel_thread-fix-2.6.1-rc1-mm1.patch
mm/pdflush.c +5 -1
@@ -223,7 +223,11 @@static void start_one_pdflush_thread (void ) { -kernel_thread (pdflush,NULL ,CLONE_KERNEL ); +int ret; + + ret =kernel_thread (pdflush,NULL ,CLONE_KERNEL ); +if (ret <0 ) +printk ("%s: unable to start kernel thread\n" , __FUNCTION__); }static int __init pdflush_init (void )
Signature · 8 lines
Eugene TEO <[email protected]> <http://www.anomalistic.org/> 1024D/14A0DDE5 print D851 4574 E357 469C D308 A01E 7321 A38A 14A0 DDE5 main(i) { putchar(182623909 >> (i-1) * 5&31|!!(i<7)<<6) && main(++i); } _______________________________________________ Kernel-janitors mailing list [email protected] http://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 14 lines · Eugene Teo
http://www.anomalistic.org/patches/vmscan-check-ret-kernel_thread-fix-2.6.1-rc1-mm1.patch
diff -Naur -X
/home/amnesia/w/dontdiff2.6.1-rc1-mm1/mm/vmscan.c2.6.1-rc1-mm1-fix/mm/vmscan.cmm/vmscan.c +1
-2@@ -1093,10 +1093,16 @@static int __init kswapd_init (void ) { +int ret;pg_data_t *pgdat;swap_setup (); -for_each_pgdat (pgdat) -kernel_thread (kswapd, pgdat,CLONE_KERNEL );
mm/vmscan.c line 1108
Quoted 10 lines
mm/vmscan.c +7
-0+for_each_pgdat (pgdat) { + ret =kernel_thread (kswapd, pgdat,CLONE_KERNEL ); +if (ret <0 ) { +printk ("%s: unable to start kernel thread\n" , __FUNCTION__); +return ret; + } + } total_memory =nr_free_pagecache_pages ();return 0 ; }
If your new code is triggered, we've just failed to set up total_memory. I expect the system to behave very oddly after this ;-)
Signature · 10 lines
"Next the statesmen will invent cheap lies, putting the blame upon the nation that is attacked, and every man will be glad of those conscience-soothing falsities, and will diligently study them, and refuse to examine any refutations of them; and thus he will by and by convince himself that the war is just, and will thank God for the better sleep he enjoys after this process of grotesque self-deception." -- Mark Twain _______________________________________________ Kernel-janitors mailing list [email protected] http://lists.osdl.org/mailman/listinfo/kernel-janitors
<quote sender="Matthew Wilcox">
Quoted 20 lines · Eugene Teo
Quoted 19 lines
http://www.anomalistic.org/patches/vmscan-check-ret-kernel_thread-fix-2.6.1-rc1-mm1.patch
diff -Naur -X
/home/amnesia/w/dontdiff2.6.1-rc1-mm1/mm/vmscan.c2.6.1-rc1-mm1-fix/mm/vmscan.cmm/vmscan.c +6
-2@@ -1093,10 +1093,16 @@static int __init kswapd_init (void ) { +int ret;pg_data_t *pgdat;swap_setup (); -for_each_pgdat (pgdat) -kernel_thread (kswapd, pgdat,CLONE_KERNEL ); +for_each_pgdat (pgdat) { + ret =kernel_thread (kswapd, pgdat,CLONE_KERNEL ); +if (ret <0 ) { +printk ("%s: unable to start kernel thread\n" , __FUNCTION__); +return ret;
Quoted 8 lines
mm/vmscan.c line 1108
Quoted 5 lines
mm/vmscan.c +2
-0+ } + } total_memory =nr_free_pagecache_pages ();return 0 ; }If your new code is triggered, we've just failed to set up
total_memory. I expect the system to behave very oddly after this ;-)
a panic call seems to be more appropriate :)
Here is the new fix. Patch compiles, and tested.
http://www.anomalistic.org/patches/vmscan-check-ret-kernel_thread-fix-2.6.1-rc1-mm1.patch
mm/vmscan.c +6 -2
@@ -1093,10 +1093,14 @@static int __init kswapd_init (void ) { +int ret;pg_data_t *pgdat;swap_setup (); -for_each_pgdat (pgdat) -kernel_thread (kswapd, pgdat,CLONE_KERNEL ); +for_each_pgdat (pgdat) { + ret =kernel_thread (kswapd, pgdat,CLONE_KERNEL ); +if (ret <0 ) +panic ("%s: unable to initialise kswapd\n" , __FUNCTION__); + } total_memory =nr_free_pagecache_pages ();return 0 ; }
Signature · 8 lines
Eugene TEO <[email protected]> <http://www.anomalistic.org/> 1024D/14A0DDE5 print D851 4574 E357 469C D308 A01E 7321 A38A 14A0 DDE5 main(i) { putchar(182623909 >> (i-1) * 5&31|!!(i<7)<<6) && main(++i); } _______________________________________________ Kernel-janitors mailing list [email protected] http://lists.osdl.org/mailman/listinfo/kernel-janitors
On Sun, 4 Jan 2004 13:11:26 +0800 Eugene Teo <[email protected]> wrote:
| <quote sender="Matthew Wilcox"> | > On Sat, Jan 03, 2004 at 09:25:24PM +0800, Eugene Teo wrote: | > > http://www.anomalistic.org/patches/vmscan-check-ret-kernel_thread-fix-2.6.1-rc1-mm1.patch | > > | > > diff -Naur -X /home/amnesia/w/dontdiff 2.6.1-rc1-mm1/mm/vmscan.c 2.6.1-rc1-mm1-fix/mm/vmscan.c | > > --- 2.6.1-rc1-mm1/mm/vmscan.c 2004-01-03 20:33:39.000000000 +0800 | > > +++ 2.6.1-rc1-mm1-fix/mm/vmscan.c 2004-01-03 21:16:30.000000000 +0800 | > > @@ -1093,10 +1093,16 @@ | > > | > > static int __init kswapd_init(void) | > > { | > > + int ret; | > > pg_data_t *pgdat; | > > swap_setup(); | > > - for_each_pgdat(pgdat) | > > - kernel_thread(kswapd, pgdat, CLONE_KERNEL); | > > + for_each_pgdat(pgdat) { | > > + ret = kernel_thread(kswapd, pgdat, CLONE_KERNEL); | > > + if (ret < 0) { | > > + printk("%s: unable to start kernel thread\n", __FUNCTION__); | > > + return ret; | > > + } | > > + } | > > total_memory = nr_free_pagecache_pages(); | > > return 0; | > > } | > | > If your new code is triggered, we've just failed to set up total_memory. | > I expect the system to behave very oddly after this ;-) | | a panic call seems to be more appropriate :) | | Here is the new fix. Patch compiles, and tested.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Eugene, patch is tested how? What do you mean by "tested"? In what conditions?
| http://www.anomalistic.org/patches/vmscan-check-ret-kernel_thread-fix-2.6.1-rc1-mm1.patch | | diff -Naur -X /home/amnesia/w/dontdiff 2.6.1-rc1-mm1/mm/vmscan.c 2.6.1-rc1-mm1-fix/mm/vmscan.c | --- 2.6.1-rc1-mm1/mm/vmscan.c 2004-01-04 10:29:24.000000000 +0800 | +++ 2.6.1-rc1-mm1-fix/mm/vmscan.c 2004-01-04 13:04:52.000000000 +0800 | @@ -1093,10 +1093,14 @@ | | static int __init kswapd_init(void) | { | + int ret; | pg_data_t *pgdat; | swap_setup(); | - for_each_pgdat(pgdat) | - kernel_thread(kswapd, pgdat, CLONE_KERNEL); | + for_each_pgdat(pgdat) { | + ret = kernel_thread(kswapd, pgdat, CLONE_KERNEL); | + if (ret < 0) | + panic("%s: unable to initialise kswapd\n", __FUNCTION__); | + } | total_memory = nr_free_pagecache_pages(); | return 0; | } |
--
~Randy
kernel-janitors project: http://janitor.kernelnewbies.org/
_______________________________________________
Kernel-janitors mailing list [email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [Kernel-janitors] [PATCH] Check return code in
In reply to Eugene TeoQuoted 6 lines · Eugene Teo
http://www.anomalistic.org/patches/setup-check-ret-alloc_bootmem_low-fix-2.6.1-rc1-mm1.patch
diff -Naur -X
/home/amnesia/w/dontdiff2.6.1-rc1-mm1/arch/i386/kernel/setup.c2.6.1-rc1-mm1-fix/arch/i386/kernel/setup.c
arch/i386/kernel/setup.c line 886
Quoted 10 lines
arch/i386/kernel/setup.c +4
-0@@ -875,6 +877,10 @@if (e820.map[i].addr + e820.map[i].size >0x100000000ULL )continue ; res =alloc_bootmem_low (sizeof (struct resource )); +if (!res) { +printk (KERN_ERR "Cannot allocate lowmem\n" ); +return ; + }switch (e820.map[i].type) {case E820_RAM : res->name ="System RAM" ;break ;case E820_ACPI : res->name ="ACPI Tables" ;break ;
I'd rather panic() at this point, otherwise we're going to start allocating areas twice and have some really unexplainable crashes. say something like ... panic("Insufficient memory to boot\n");
Signature · 10 lines
"Next the statesmen will invent cheap lies, putting the blame upon the nation that is attacked, and every man will be glad of those conscience-soothing falsities, and will diligently study them, and refuse to examine any refutations of them; and thus he will by and by convince himself that the war is just, and will thank God for the better sleep he enjoys after this process of grotesque self-deception." -- Mark Twain _______________________________________________ Kernel-janitors mailing list [email protected] http://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [Kernel-janitors] [PATCH] Check return code in
In reply to Eugene Teo<quote sender="Matthew Wilcox">
Quoted 4 lines · Eugene Teo
Quoted 3 lines
http://www.anomalistic.org/patches/setup-check-ret-alloc_bootmem_low-fix-2.6.1-rc1-mm1.patch
diff -Naur -X
/home/amnesia/w/dontdiff2.6.1-rc1-mm1/arch/i386/kernel/setup.c2.6.1-rc1-mm1-fix/arch/i386/kernel/setup.c
[snip]
Quoted 3 lines
I'd rather
panic()at this point, otherwise we're going to start allocating areas twice and have some really unexplainable crashes. say something like ...panic("Insufficient memory to boot\n");
Hehe, I can't imagine how nasty it would be if we didn't panic :)
http://www.anomalistic.org/patches/setup-check-ret-alloc_bootmem_low-fix-2.6.1-rc1-mm1.patch
arch/i386/kernel/setup.c +2 -0
@@ -875,6 +875,8 @@if (e820.map[i].addr + e820.map[i].size >0x100000000ULL )continue ; res =alloc_bootmem_low (sizeof (struct resource )); +if (!res) +panic ("Insufficient memory to boot\n" );switch (e820.map[i].type) {case E820_RAM : res->name ="System RAM" ;break ;case E820_ACPI : res->name ="ACPI Tables" ;break ;
Signature · 8 lines
Eugene TEO <[email protected]> <http://www.anomalistic.org/> 1024D/14A0DDE5 print D851 4574 E357 469C D308 A01E 7321 A38A 14A0 DDE5 main(i) { putchar(182623909 >> (i-1) * 5&31|!!(i<7)<<6) && main(++i); } _______________________________________________ Kernel-janitors mailing list [email protected] http://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [Kernel-janitors] [PATCH] Check return code in mm/pdflush.c
In reply to Eugene TeoOn Sat, 3 Jan 2004 21:26:56 +0800 Eugene Teo <[email protected]> wrote:
| http://www.anomalistic.org/patches/pdflush-check-ret-kernel_thread-fix-2.6.1-rc1-mm1.patch | | diff -Naur -X /home/amnesia/w/dontdiff 2.6.1-rc1-mm1/mm/pdflush.c 2.6.1-rc1-mm1-fix/mm/pdflush.c | --- 2.6.1-rc1-mm1/mm/pdflush.c 2004-01-03 17:58:11.000000000 +0800 | +++ 2.6.1-rc1-mm1-fix/mm/pdflush.c 2004-01-03 20:25:30.000000000 +0800 | @@ -223,7 +223,11 @@ | | static void start_one_pdflush_thread(void) | { | - kernel_thread(pdflush, NULL, CLONE_KERNEL); | + int ret; | + | + ret = kernel_thread(pdflush, NULL, CLONE_KERNEL); | + if (ret < 0) | + printk("%s: unable to start kernel thread\n", __FUNCTION__);
This patch adds trailing whitespace (on the "if" line). Please be more careful about that -- we don't want that. I fixed this one.
I run a simple script that searches for gotchas like this:
grep -nH "^+.*[ ]$" $1 | more
(that's SPACE and TAB inside the square brackets)
--
~Randy
MOTD: Always include version info.
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [Kernel-janitors] [PATCH] Check return code in mm/pdflush.c
In reply to Eugene Teo<quote sender="Randy.Dunlap">
Quoted 18 lines · On Sat, 3 Jan 2004 21:26:56 +0800 Eugene Teo <[email protected]> wrote:
| http://www.anomalistic.org/patches/pdflush-check-ret-kernel_thread-fix-2.6.1-rc1-mm1.patch | | diff -Naur -X /home/amnesia/w/dontdiff 2.6.1-rc1-mm1/mm/pdflush.c 2.6.1-rc1-mm1-fix/mm/pdflush.c | --- 2.6.1-rc1-mm1/mm/pdflush.c 2004-01-03 17:58:11.000000000 +0800 | +++ 2.6.1-rc1-mm1-fix/mm/pdflush.c 2004-01-03 20:25:30.000000000 +0800 | @@ -223,7 +223,11 @@ | | static void start_one_pdflush_thread(void) | { | - kernel_thread(pdflush, NULL, CLONE_KERNEL); | + int ret; | + | + ret = kernel_thread(pdflush, NULL, CLONE_KERNEL); | + if (ret < 0) | + printk("%s: unable to start kernel thread\n", __FUNCTION__);
Quoted 8 lines
This patch adds trailing whitespace (on the "if" line). Please be more careful about that -- we don't want that. I fixed this one.
I run a simple script that searches for gotchas like this:
grep -nH "^+.*[ ]$" $1 | more(that's SPACE and TAB inside the square brackets)
Useful regexp. Will be careful.
Eugene
Quoted 5 lines
--
~Randy
MOTD: Always include version info.
Signature · 8 lines
Eugene TEO <[email protected]> <http://www.anomalistic.org/> 1024D/14A0DDE5 print D851 4574 E357 469C D308 A01E 7321 A38A 14A0 DDE5 main(i) { putchar(182623909 >> (i-1) * 5&31|!!(i<7)<<6) && main(++i); } _______________________________________________ Kernel-janitors mailing list [email protected] http://lists.osdl.org/mailman/listinfo/kernel-janitors