[2.4] build error with latest BK
Hi all,
Just pulled latest bk of 2.4 and it appears to be broken. The recent rwsem race fixes seem to be the culprit (see
http://linux.bkbits.net:8080/linux-2.4/cset@40cee86dCLGhZc1lEOWZV6K7FysQlw?nav=index.html|
ChangeSet@-1d). Reversing it fixes the problem.
gcc -D__KERNEL__ -I/usr/local/src/linux-2.4/include -Wall -Wstrict- prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-
frame-pointer -pipe -mpreferred-stack-boundary=2 -march=athlon -
nostdinc -iwithprefix include -DKBUILD_BASENAME=rwsem -DEXPORT_SYMTAB -c rwsem.crwsem.c: In function `__rwsem_do_wake':
rwsem.c:67: warning: implicit declaration of function put_task_struct' rwsem.c: In function rwsem_down_failed_common':
rwsem.c:131: error: `mem_map' undeclared (first use in this function) rwsem.c:131: error: (Each undeclared identifier is reported only once rwsem.c:131: error: for each function it appears in.) make[2]: *** [rwsem.o] Error 1
make[2]: Leaving directory `/usr/local/src/linux-2.4/lib' make[1]: *** [first_rule] Error 2
make[1]: Leaving directory `/usr/local/src/linux-2.4/lib'
make: *** [_dir_lib] Error 2
x86 target, gcc 3.3.2 (or 2.95.4 prerelease). Ping me if you need .config or anything else.
[nuno@calvin] /usr/local/src/linux-2.4$ patch -Rp1 < fix-rwsem-race patching file lib/rwsem-spinlock.c
patching file lib/rwsem.c
[nuno@calvin] /usr/local/src/linux-2.4$ cd lib
[nuno@calvin] ..src/linux-2.4/lib$ gcc -D__KERNEL__ -I/usr/local/src/ linux-2.4/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno- strict-aliasing -fno-common -fomit-frame-pointer -pipe -mpreferred-stack-
boundary=2 -march=athlon -nostdinc -iwithprefix include -
DKBUILD_BASENAME=rwsem -DEXPORT_SYMTAB -c rwsem.c [nuno@calvin] ..src/linux-2.4/lib$ echo $?
0
Regards,
Nuno
Quoted 6 lines · Nuno Monteiro
Hi all,
Just pulled latest bk of 2.4 and it appears to be broken. The recent rwsem race fixes seem to be the culprit (see http://linux.bkbits.net:8080/linux-2.4/cset@40cee86dCLGhZc1lEOWZV6K7FysQlw?nav=index.html| ChangeSet@-1d). Reversing it fixes the problem.
Sorry, that was stupid of me.
Does the attached patch look acceptable? In particular, should task_lock be used in this manner? (ie. to guarantee the task doesn't go away).
lib/rwsem.c renamed from lib/rwsem.c.orig +4 -5
@@ -61,10 +61,10 @@ static inline struct rw_semaphore *__rwslist_del (&waiter->list); tsk = waiter->task; -mb (); +task_lock (tsk);/* task_lock is an implicit memory barrier */ waiter->task =NULL ;wake_up_process (tsk); -put_task_struct (tsk); +task_unlock (tsk); goto out;/* grant an infinite number of read locks to the readers at the front of the queue
@@ -93,10 +93,10 @@ static inline struct rw_semaphore *__rws waiter = list_entry(next,struct rwsem_waiter,list); next = waiter->list.next; tsk = waiter->task; -mb (); +task_lock (tsk); waiter->task =NULL ;wake_up_process (tsk); -put_task_struct (tsk); +task_unlock (tsk); } sem->wait_list.next = next;
@@ -128,7 +128,6 @@ static inline struct rw_semaphore *rwsem/* set up my own style of waitqueue */ spin_lock (&sem->wait_lock); waiter->task = tsk; -get_task_struct (tsk);list_add_tail (&waiter->list,&sem->wait_list);
lib/rwsem-spinlock.c renamed from lib/rwsem-spinlock.c.orig +6 -8
@@ -66,10 +66,10 @@ static inline struct rw_semaphore *__rws sem->activity =-1 ;list_del (&waiter->list); tsk = waiter->task; -mb (); +task_lock (tsk);/* implicit memory barrier */ waiter->task =NULL ;wake_up_process (tsk); -put_task_struct (tsk); +task_unlock (tsk); goto out; }
@@ -78,10 +78,10 @@ static inline struct rw_semaphore *__rws do { list_del(&waiter->list); tsk = waiter->task; - mb(); + task_lock(tsk); waiter->task = NULL; wake_up_process(tsk); - put_task_struct(tsk); + task_unlock(tsk); woken++; if (list_empty(&sem->wait_list)) break;
@@ -108,10 +108,10 @@ static inline struct rw_semaphore *__rwslist_del (&waiter->list); tsk = waiter->task; -mb (); +task_lock (tsk); waiter->task =NULL ;wake_up_process (tsk); -put_task_struct (tsk); +task_unlock (tsk);return sem; }
@@ -140,7 +140,6 @@ void __down_read(struct rw_semaphore *se/* set up my own style of waitqueue */ waiter.task = tsk; waiter.flags =RWSEM_WAITING_FOR_READ ; -get_task_struct (tsk);list_add_tail (&waiter.list,&sem->wait_list);
@@ -209,7 +208,6 @@ void __down_write(struct rw_semaphore *s/* set up my own style of waitqueue */ waiter.task = tsk; waiter.flags =RWSEM_WAITING_FOR_WRITE ; -get_task_struct (tsk);list_add_tail (&waiter.list,&sem->wait_list);
Review
Quoted 3 lines
(quoted diff) +1
-1- put_task_struct(tsk); + task_unlock(tsk);
Ummm... that doesn't look right.
Review
Quoted 1 line
(quoted diff) +0
-1- get_task_struct(tsk);
This is necessary to stop someone deallocating the task structure, can the task structure be deallocated whilst locked?
David
Quoted 7 lines · David Howells
Review
Quoted 2 lines
(quoted diff) +1
-1- put_task_struct(tsk); + task_unlock(tsk);Ummm... that doesn't look right.
Quoted 6 lines
Review
Quoted 1 line
(quoted diff) +0
-1- get_task_struct(tsk);This is necessary to stop someone deallocating the task structure, can the task structure be deallocated whilst locked?
Ooh maybe it can. Should that be a read_lock of the tasklist lock then?
Quoted 8 lines · Nick Piggin
Quoted 7 lines · David Howells
Review
Quoted 2 lines
(quoted diff) +1
-1- put_task_struct(tsk); + task_unlock(tsk);Ummm... that doesn't look right.
Quoted 8 lines
Quoted 6 lines
Review
Quoted 1 line
(quoted diff) +0
-1- get_task_struct(tsk);This is necessary to stop someone deallocating the task structure, can the task structure be deallocated whilst locked?
Ooh maybe it can. Should that be a
read_lockof the tasklist lock then?
For 2.4 kernels, use get_task_struct() and free_task_struct() [not put] for locking and unlocking a task.
Quoted 16 lines · Mikael Pettersson
Quoted 15 lines · Nick Piggin
Quoted 13 lines · David Howells
Review
Quoted 2 lines
(quoted diff) +1
-1- put_task_struct(tsk); + task_unlock(tsk);Ummm... that doesn't look right.
Review
Quoted 1 line
(quoted diff) +0
-1- get_task_struct(tsk);This is necessary to stop someone deallocating the task structure, can the task structure be deallocated whilst locked?
Quoted 5 lines
Quoted 1 line
Ooh maybe it can. Should that be a
read_lockof the tasklist lock then?For 2.4 kernels, use
get_task_struct()andfree_task_struct()[not put] for locking and unlocking a task.
Sorry I'm an idiot. I'm sure Marcelo has already fixed it. Just simply replace put_task_struct with free_task_struct.
Quoted 1 line · Nick Piggin
Just simply replace
put_task_structwithfree_task_struct.
Like this, maybe? It applies on top of what's currently in BK -- it fixed it for me, compiled and boot tested, running for the last 20 minutes. Also, linux/mm.h is needed because of free_pages().
Marcelo, please apply.
lib/rwsem.c renamed from lib/rwsem.c~fix-rwsem-race-fix +3 -2
@@ -5,6 +5,7 @@*/ #include <linux/rwsem.h> #include <linux/sched.h> +#include <linux/mm.h> #include <linux/module.h> struct rwsem_waiter {
@@ -64,7 +65,7 @@ static inline struct rw_semaphore *__rwsmb (); waiter->task =NULL ;wake_up_process (tsk); -put_task_struct (tsk); +free_task_struct (tsk); goto out;/* grant an infinite number of read locks to the readers at the front of the queue
@@ -96,7 +97,7 @@ static inline struct rw_semaphore *__rwsmb (); waiter->task =NULL ;wake_up_process (tsk); -put_task_struct (tsk); +free_task_struct (tsk); } sem->wait_list.next = next;
Quoted 6 lines · Nuno Monteiro
Quoted 1 line · Nick Piggin
Just simply replace
put_task_structwithfree_task_struct.Like this, maybe? It applies on top of what's currently in BK -- it fixed it for me, compiled and boot tested, running for the last 20 minutes. Also,
linux/mm.his needed because offree_pages().
Ok, applied, thanks everyone. Should be releasing -pre6 in a few moments with this.
Re: [2.4] build error with latest BK [fixed patch]
In reply to Nick PigginQuoted 1 line · Nick Piggin
Just simply replace
put_task_structwithfree_task_struct.
Sorry, only sent half of the patch the first time around. Here it is, with the second hunk touching rwsem-spinlock.c.
This applies on top of what's currently in BK, and fixes the problems for me -- it is compiled and boot tested, running for the last 20 minutes. Also, linux/mm.h is needed because of free_pages().
I don't have any arch around here that actually needs rwsem-spinlock.c so that part is untested, although it should be ok.
Marcelo, please apply.
lib/rwsem.c renamed from lib/rwsem.c~fix-rwsem-race-fix +3 -2
@@ -5,6 +5,7 @@*/ #include <linux/rwsem.h> #include <linux/sched.h> +#include <linux/mm.h> #include <linux/module.h> struct rwsem_waiter {
@@ -64,7 +65,7 @@ static inline struct rw_semaphore *__rwsmb (); waiter->task =NULL ;wake_up_process (tsk); -put_task_struct (tsk); +free_task_struct (tsk); goto out;/* grant an infinite number of read locks to the readers at the front of the queue
@@ -96,7 +97,7 @@ static inline struct rw_semaphore *__rwsmb (); waiter->task =NULL ;wake_up_process (tsk); -put_task_struct (tsk); +free_task_struct (tsk); } sem->wait_list.next = next;
lib/rwsem-spinlock.c renamed from lib/rwsem-spinlock.c~fix-rwsem-race-fix +4 -3
@@ -9,6 +9,7 @@*/ #include <linux/rwsem.h> #include <linux/sched.h> +#include <linux/mm.h> #include <linux/module.h> struct rwsem_waiter {
@@ -69,7 +70,7 @@ static inline struct rw_semaphore *__rwsmb (); waiter->task =NULL ;wake_up_process (tsk); -put_task_struct (tsk); +free_task_struct (tsk); goto out; }
@@ -81,7 +82,7 @@ static inline struct rw_semaphore *__rwsmb (); waiter->task =NULL ;wake_up_process (tsk); -put_task_struct (tsk); +free_task_struct (tsk); woken++;if (list_empty (&sem->wait_list))break ;
@@ -111,7 +112,7 @@ static inline struct rw_semaphore *__rwsmb (); waiter->task =NULL ;wake_up_process (tsk); -put_task_struct (tsk); +free_task_struct (tsk);return sem; }