aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/posix-cpu-timers.c
diff options
context:
space:
mode:
authorPavel Emelianov <xemul@sw.ru>2007-05-08 03:30:19 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:11 -0400
commitb5e618181a927210f8be1d3d2249d31904ba358d (patch)
tree731f1ae4ff1ba56d402bb329182b7d935bb439a1 /kernel/posix-cpu-timers.c
parentdb9c02fa8bd50eb104781a9f78cae923d8da1e74 (diff)
Introduce a handy list_first_entry macro
There are many places in the kernel where the construction like foo = list_entry(head->next, struct foo_struct, list); are used. The code might look more descriptive and neat if using the macro list_first_entry(head, type, member) \ list_entry((head)->next, type, member) Here is the macro itself and the examples of its usage in the generic code. If it will turn out to be useful, I can prepare the set of patches to inject in into arch-specific code, drivers, networking, etc. Signed-off-by: Pavel Emelianov <xemul@openvz.org> Signed-off-by: Kirill Korotaev <dev@openvz.org> Cc: Randy Dunlap <randy.dunlap@oracle.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: Zach Brown <zach.brown@oracle.com> Cc: Davide Libenzi <davidel@xmailserver.org> Cc: John McCutchan <ttb@tentacle.dhs.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@elte.hu> Cc: john stultz <johnstul@us.ibm.com> Cc: Ram Pai <linuxram@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/posix-cpu-timers.c')
-rw-r--r--kernel/posix-cpu-timers.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index 657f77697415..1de710e18373 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -971,7 +971,7 @@ static void check_thread_timers(struct task_struct *tsk,
971 maxfire = 20; 971 maxfire = 20;
972 tsk->it_prof_expires = cputime_zero; 972 tsk->it_prof_expires = cputime_zero;
973 while (!list_empty(timers)) { 973 while (!list_empty(timers)) {
974 struct cpu_timer_list *t = list_entry(timers->next, 974 struct cpu_timer_list *t = list_first_entry(timers,
975 struct cpu_timer_list, 975 struct cpu_timer_list,
976 entry); 976 entry);
977 if (!--maxfire || cputime_lt(prof_ticks(tsk), t->expires.cpu)) { 977 if (!--maxfire || cputime_lt(prof_ticks(tsk), t->expires.cpu)) {
@@ -986,7 +986,7 @@ static void check_thread_timers(struct task_struct *tsk,
986 maxfire = 20; 986 maxfire = 20;
987 tsk->it_virt_expires = cputime_zero; 987 tsk->it_virt_expires = cputime_zero;
988 while (!list_empty(timers)) { 988 while (!list_empty(timers)) {
989 struct cpu_timer_list *t = list_entry(timers->next, 989 struct cpu_timer_list *t = list_first_entry(timers,
990 struct cpu_timer_list, 990 struct cpu_timer_list,
991 entry); 991 entry);
992 if (!--maxfire || cputime_lt(virt_ticks(tsk), t->expires.cpu)) { 992 if (!--maxfire || cputime_lt(virt_ticks(tsk), t->expires.cpu)) {
@@ -1001,7 +1001,7 @@ static void check_thread_timers(struct task_struct *tsk,
1001 maxfire = 20; 1001 maxfire = 20;
1002 tsk->it_sched_expires = 0; 1002 tsk->it_sched_expires = 0;
1003 while (!list_empty(timers)) { 1003 while (!list_empty(timers)) {
1004 struct cpu_timer_list *t = list_entry(timers->next, 1004 struct cpu_timer_list *t = list_first_entry(timers,
1005 struct cpu_timer_list, 1005 struct cpu_timer_list,
1006 entry); 1006 entry);
1007 if (!--maxfire || tsk->sched_time < t->expires.sched) { 1007 if (!--maxfire || tsk->sched_time < t->expires.sched) {
@@ -1057,7 +1057,7 @@ static void check_process_timers(struct task_struct *tsk,
1057 maxfire = 20; 1057 maxfire = 20;
1058 prof_expires = cputime_zero; 1058 prof_expires = cputime_zero;
1059 while (!list_empty(timers)) { 1059 while (!list_empty(timers)) {
1060 struct cpu_timer_list *t = list_entry(timers->next, 1060 struct cpu_timer_list *t = list_first_entry(timers,
1061 struct cpu_timer_list, 1061 struct cpu_timer_list,
1062 entry); 1062 entry);
1063 if (!--maxfire || cputime_lt(ptime, t->expires.cpu)) { 1063 if (!--maxfire || cputime_lt(ptime, t->expires.cpu)) {
@@ -1072,7 +1072,7 @@ static void check_process_timers(struct task_struct *tsk,
1072 maxfire = 20; 1072 maxfire = 20;
1073 virt_expires = cputime_zero; 1073 virt_expires = cputime_zero;
1074 while (!list_empty(timers)) { 1074 while (!list_empty(timers)) {
1075 struct cpu_timer_list *t = list_entry(timers->next, 1075 struct cpu_timer_list *t = list_first_entry(timers,
1076 struct cpu_timer_list, 1076 struct cpu_timer_list,
1077 entry); 1077 entry);
1078 if (!--maxfire || cputime_lt(utime, t->expires.cpu)) { 1078 if (!--maxfire || cputime_lt(utime, t->expires.cpu)) {
@@ -1087,7 +1087,7 @@ static void check_process_timers(struct task_struct *tsk,
1087 maxfire = 20; 1087 maxfire = 20;
1088 sched_expires = 0; 1088 sched_expires = 0;
1089 while (!list_empty(timers)) { 1089 while (!list_empty(timers)) {
1090 struct cpu_timer_list *t = list_entry(timers->next, 1090 struct cpu_timer_list *t = list_first_entry(timers,
1091 struct cpu_timer_list, 1091 struct cpu_timer_list,
1092 entry); 1092 entry);
1093 if (!--maxfire || sched_time < t->expires.sched) { 1093 if (!--maxfire || sched_time < t->expires.sched) {
@@ -1400,7 +1400,7 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clock_idx,
1400 */ 1400 */
1401 head = &tsk->signal->cpu_timers[clock_idx]; 1401 head = &tsk->signal->cpu_timers[clock_idx];
1402 if (list_empty(head) || 1402 if (list_empty(head) ||
1403 cputime_ge(list_entry(head->next, 1403 cputime_ge(list_first_entry(head,
1404 struct cpu_timer_list, entry)->expires.cpu, 1404 struct cpu_timer_list, entry)->expires.cpu,
1405 *newval)) { 1405 *newval)) {
1406 /* 1406 /*