Skip to content

Commit c7af77b

Browse files
Livio SoaresIngo Molnar
authored andcommitted
sched: mark rwsem functions as __sched for wchan/profiling
This following commit http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=fdf8cb0909b531f9ae8f9b9d7e4eb35ba3505f07 un-inlined a low-level rwsem function, but did not mark it as __sched. The result is that it now shows up as thread wchan (which also affects /proc/profile stats). The following simple patch fixes this by properly marking rwsem_down_failed_common() as a __sched function. Also in this patch, which is up for discussion, marks down_read() and down_write() proper as __sched. For profiling, it is pretty much useless to know that a semaphore is beig help - it is necessary to know _which_ one. By going up another frame on the stack, the information becomes much more useful. In summary, the below change to lib/rwsem.c should be applied; the changes to kernel/rwsem.c could be applied if other kernel hackers agree with my proposal that down_read()/down_write() in the profile is not enough. [ akpm@linux-foundation.org: build fix ] Signed-off-by: Livio Soares <livio@eecg.toronto.edu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 051a1d1 commit c7af77b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

kernel/rwsem.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <linux/types.h>
88
#include <linux/kernel.h>
9+
#include <linux/sched.h>
910
#include <linux/module.h>
1011
#include <linux/rwsem.h>
1112

@@ -15,7 +16,7 @@
1516
/*
1617
* lock for reading
1718
*/
18-
void down_read(struct rw_semaphore *sem)
19+
void __sched down_read(struct rw_semaphore *sem)
1920
{
2021
might_sleep();
2122
rwsem_acquire_read(&sem->dep_map, 0, 0, _RET_IP_);
@@ -42,7 +43,7 @@ EXPORT_SYMBOL(down_read_trylock);
4243
/*
4344
* lock for writing
4445
*/
45-
void down_write(struct rw_semaphore *sem)
46+
void __sched down_write(struct rw_semaphore *sem)
4647
{
4748
might_sleep();
4849
rwsem_acquire(&sem->dep_map, 0, 0, _RET_IP_);

lib/rwsem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ __rwsem_do_wake(struct rw_semaphore *sem, int downgrading)
146146
/*
147147
* wait for a lock to be granted
148148
*/
149-
static struct rw_semaphore *
149+
static struct rw_semaphore __sched *
150150
rwsem_down_failed_common(struct rw_semaphore *sem,
151151
struct rwsem_waiter *waiter, signed long adjustment)
152152
{

0 commit comments

Comments
 (0)