2002-11-15 11:25:45

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH] use thread_info.h in uaccess.h

Hi Linus,

Please consider pulling from:

bk://oops.kerneljanitors.org:hell_header-2.5

Comments on the changeset, but its fairly trivial. Tested
with 'make allmodconfig' and 'make allyesconfig'.

- Arnaldo

You can import this changeset into BK by piping this whole message to:
'| bk receive [path to repository]' or apply the patch as usual.

===================================================================


[email protected], 2002-11-15 09:05:29-02:00, [email protected]
o includes: remove include sched.h from asm-i386/uaccess.h

It only needs current_thread_info, so now it includes just
asm/thread_info.h, this way sched.h will not be included indirectly
hundreds of times when all that is needed is copy_to_user and friends.


fs/autofs/autofs_i.h | 2 ++
fs/autofs4/autofs_i.h | 2 ++
fs/ext2/ioctl.c | 2 ++
include/asm-i386/uaccess.h | 2 +-
ipc/msg.c | 2 ++
5 files changed, 9 insertions(+), 1 deletion(-)


diff -Nru a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h
--- a/fs/autofs/autofs_i.h Fri Nov 15 09:07:06 2002
+++ b/fs/autofs/autofs_i.h Fri Nov 15 09:07:06 2002
@@ -25,6 +25,8 @@
#include <linux/wait.h>
#include <linux/dcache.h>
#include <linux/namei.h>
+#include <asm/current.h>
+#include <linux/sched.h>
#include <asm/uaccess.h>

#ifdef DEBUG
diff -Nru a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
--- a/fs/autofs4/autofs_i.h Fri Nov 15 09:07:06 2002
+++ b/fs/autofs4/autofs_i.h Fri Nov 15 09:07:06 2002
@@ -24,6 +24,8 @@
#include <linux/time.h>
#include <linux/string.h>
#include <linux/wait.h>
+#include <linux/sched.h>
+#include <asm/current.h>
#include <asm/uaccess.h>

/* #define DEBUG */
diff -Nru a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
--- a/fs/ext2/ioctl.c Fri Nov 15 09:07:06 2002
+++ b/fs/ext2/ioctl.c Fri Nov 15 09:07:06 2002
@@ -9,6 +9,8 @@

#include "ext2.h"
#include <linux/time.h>
+#include <linux/sched.h>
+#include <asm/current.h>
#include <asm/uaccess.h>


diff -Nru a/include/asm-i386/uaccess.h b/include/asm-i386/uaccess.h
--- a/include/asm-i386/uaccess.h Fri Nov 15 09:07:06 2002
+++ b/include/asm-i386/uaccess.h Fri Nov 15 09:07:06 2002
@@ -6,7 +6,7 @@
*/
#include <linux/config.h>
#include <linux/errno.h>
-#include <linux/sched.h>
+#include <linux/thread_info.h>
#include <linux/prefetch.h>
#include <asm/page.h>

diff -Nru a/ipc/msg.c b/ipc/msg.c
--- a/ipc/msg.c Fri Nov 15 09:07:06 2002
+++ b/ipc/msg.c Fri Nov 15 09:07:06 2002
@@ -23,6 +23,8 @@
#include <linux/proc_fs.h>
#include <linux/list.h>
#include <linux/security.h>
+#include <linux/sched.h>
+#include <asm/current.h>
#include <asm/uaccess.h>
#include "util.h"


===================================================================


This BitKeeper patch contains the following changesets:
1.851
## Wrapped with gzip_uu ##


begin 664 bkpatch25755
M'XL(`%K5U#T``^V876_;-A2&KZ-?02"7JR5^ZL-8@JSML`4=L"!#KX;!H$DJ
MTB*)@4C'-:`?OR,[=FPGBA-W=XTMV(9$'KXZ?/@>RJ?HJS/M^$2JV@2GZ'?K
M_/A$V<8H7][+4-DZG+9PX=I:N!`5MC;1QR]18:IJ4ABI33NBH0B@Q97TJD#W
MIG7C$Q*RS1F_N#/CD^M??_OZQR_707!VACX5LKDQ?QF/SLX";]M[66EW(7U1
MV2;TK6Q<;?QR[&[3M*,84W@+DC`LXH[$F">=(IH0R8G1F/(TYH_1>J$OQB*$
M"!P31D2'<49X\!F1,!4$81H1$A&!<#;&8DRS$:9CC%&?H8O]S*"?!!KAX"/Z
M?V_C4Z"0166CJIDV;HQ:4]M[LSZ!G"J,#@N4M[9&TM6CDJ5Q-)-*&>?"`CK#
M<>F1;:H%:HS1#JE9VYK&3WS1PJQ-RB:W'Y"SJ+%S5/K-4.C?F?/0&8)&6TW#
MX@/R1>G07"XVH\_+JH+^'DTWRC3\T&4+*:H6$*68-;KM1[<Y\F4-X>>%:9"$
M?KZ0,*I;JNN[@4)[MYAX.YD!CT@V&NZN-(UV8?`%Q3PC++AZ)"<8O?$5!%CB
MX/S`/)5W*JK=3:BVYHECC#M,XX1W7"6"Y5F>")-.I1E@8B]*#QHAF#'1B8R2
M]*"(W$7FFZ=1:2&-.U)8QM*.T(QF74K%-#,)3G(N<QA@0,ISL;8$<9)R\1I!
M<N;MYFM2AL6^*A8+G'0IT0+K/%><PLJ:JF%5SP?<DD8P%\GKI?%!;5G'<3]Y
M=$JT,8PEAG*<Q=DA;4\B;HFC3"3D,$VK11$]7:$["CGO!.,$=X)KGH`A:97'
MN<C8$%XOA]WA+<%L:;G/9?RP^QX_\<'T!@J!O]"E;KR>J=O0MC<OS#O&*>24
M@B/B&#^8,<&[7LS&3+SLQ?3'\&(PQ-7J^!.-VOGR`(.[>G:2CS#*2YH@&IRN
M;_#G?OP'R6%QOG6A*IO9M^@A`>>[G/'C0'O[,CY`VM-5_(@:R0A-EZ@E[Z0-
MD;:RNB'2^/>B%N^@MD?4((,/J&V7ME=!]O:Z&DA=5D#8!0AQWK2Y&XX5`UR"
M,0*F"+L&NB0K?B=KB*S5YN,I6=N)/88I0HYF:KBT'L;K>ZO]LT;V]WK,?PZ6
M?<Q@H\I@MPIE'YQR54+96_$C:$1^#/Q6FZ,]_(:3?`2)GS-$@LO^8Y_&'2T/
MZ*T?&EY!VMN>4@)Y>U<#5C?&]MVWD=I[4,&PK<"9`$)YDH@E0=F[?PT#U#_-
D[0.T3NE1U5`<YUSKOUJ@I;IUL_J,Q(I"#9/!?SP3!.#?$0``
`
end


2002-11-15 16:43:32

by Matthew Wilcox

[permalink] [raw]
Subject: Re: [PATCH] use thread_info.h in uaccess.h


While we're janitoring headers...

This patch removes all the wait_queue handling code from sched.h and puts
it in wait.h with the rest of the wait_queue handling code. Note that
sched.h must continue to include wait.h for the wait_queue_head_t embedded
in struct task. However there may be files which only need wait.h now.

diff -urpNX dontdiff linux-2.5.47/include/linux/sched.h linux-2.5.47-wait/include/linux/sched.h
--- linux-2.5.47/include/linux/sched.h 2002-11-15 05:42:21.000000000 -0800
+++ linux-2.5.47-wait/include/linux/sched.h 2002-11-15 05:44:44.000000000 -0800
@@ -488,31 +488,10 @@ extern unsigned long itimer_ticks;
extern unsigned long itimer_next;
extern void do_timer(struct pt_regs *);

-extern void FASTCALL(__wake_up(wait_queue_head_t *q, unsigned int mode, int nr));
-extern void FASTCALL(__wake_up_locked(wait_queue_head_t *q, unsigned int mode));
-extern void FASTCALL(__wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr));
-extern void FASTCALL(sleep_on(wait_queue_head_t *q));
-extern long FASTCALL(sleep_on_timeout(wait_queue_head_t *q,
- signed long timeout));
-extern void FASTCALL(interruptible_sleep_on(wait_queue_head_t *q));
-extern long FASTCALL(interruptible_sleep_on_timeout(wait_queue_head_t *q,
- signed long timeout));
extern int FASTCALL(wake_up_process(struct task_struct * tsk));
extern void FASTCALL(wake_up_forked_process(struct task_struct * tsk));
extern void FASTCALL(sched_exit(task_t * p));

-#define wake_up(x) __wake_up((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 1)
-#define wake_up_nr(x, nr) __wake_up((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, nr)
-#define wake_up_all(x) __wake_up((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 0)
-#define wake_up_interruptible(x) __wake_up((x),TASK_INTERRUPTIBLE, 1)
-#define wake_up_interruptible_nr(x, nr) __wake_up((x),TASK_INTERRUPTIBLE, nr)
-#define wake_up_interruptible_all(x) __wake_up((x),TASK_INTERRUPTIBLE, 0)
-#define wake_up_locked(x) __wake_up_locked((x), TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE)
-#ifdef CONFIG_SMP
-#define wake_up_interruptible_sync(x) __wake_up_sync((x),TASK_INTERRUPTIBLE, 1)
-#else
-#define wake_up_interruptible_sync(x) __wake_up((x),TASK_INTERRUPTIBLE, 1)
-#endif
asmlinkage long sys_wait4(pid_t pid,unsigned int * stat_addr, int options, struct rusage * ru);

extern int in_group_p(gid_t);
@@ -654,10 +633,6 @@ extern task_t *child_reaper;
extern int do_execve(char *, char **, char **, struct pt_regs *);
extern struct task_struct *do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int *);

-extern void FASTCALL(add_wait_queue(wait_queue_head_t *q, wait_queue_t * wait));
-extern void FASTCALL(add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t * wait));
-extern void FASTCALL(remove_wait_queue(wait_queue_head_t *q, wait_queue_t * wait));
-
#ifdef CONFIG_SMP
extern void wait_task_inactive(task_t * p);
#else
@@ -665,108 +640,6 @@ extern void wait_task_inactive(task_t *
#endif
extern void kick_if_running(task_t * p);

-#define __wait_event(wq, condition) \
-do { \
- wait_queue_t __wait; \
- init_waitqueue_entry(&__wait, current); \
- \
- add_wait_queue(&wq, &__wait); \
- for (;;) { \
- set_current_state(TASK_UNINTERRUPTIBLE); \
- if (condition) \
- break; \
- schedule(); \
- } \
- current->state = TASK_RUNNING; \
- remove_wait_queue(&wq, &__wait); \
-} while (0)
-
-#define wait_event(wq, condition) \
-do { \
- if (condition) \
- break; \
- __wait_event(wq, condition); \
-} while (0)
-
-#define __wait_event_interruptible(wq, condition, ret) \
-do { \
- wait_queue_t __wait; \
- init_waitqueue_entry(&__wait, current); \
- \
- add_wait_queue(&wq, &__wait); \
- for (;;) { \
- set_current_state(TASK_INTERRUPTIBLE); \
- if (condition) \
- break; \
- if (!signal_pending(current)) { \
- schedule(); \
- continue; \
- } \
- ret = -ERESTARTSYS; \
- break; \
- } \
- current->state = TASK_RUNNING; \
- remove_wait_queue(&wq, &__wait); \
-} while (0)
-
-#define wait_event_interruptible(wq, condition) \
-({ \
- int __ret = 0; \
- if (!(condition)) \
- __wait_event_interruptible(wq, condition, __ret); \
- __ret; \
-})
-
-#define __wait_event_interruptible_timeout(wq, condition, ret) \
-do { \
- wait_queue_t __wait; \
- init_waitqueue_entry(&__wait, current); \
- \
- add_wait_queue(&wq, &__wait); \
- for (;;) { \
- set_current_state(TASK_INTERRUPTIBLE); \
- if (condition) \
- break; \
- if (!signal_pending(current)) { \
- ret = schedule_timeout(ret); \
- if (!ret) \
- break; \
- continue; \
- } \
- ret = -ERESTARTSYS; \
- break; \
- } \
- current->state = TASK_RUNNING; \
- remove_wait_queue(&wq, &__wait); \
-} while (0)
-
-#define wait_event_interruptible_timeout(wq, condition, timeout) \
-({ \
- long __ret = timeout; \
- if (!(condition)) \
- __wait_event_interruptible_timeout(wq, condition, __ret); \
- __ret; \
-})
-
-/*
- * Must be called with the spinlock in the wait_queue_head_t held.
- */
-static inline void add_wait_queue_exclusive_locked(wait_queue_head_t *q,
- wait_queue_t * wait)
-{
- wait->flags |= WQ_FLAG_EXCLUSIVE;
- __add_wait_queue_tail(q, wait);
-}
-
-/*
- * Must be called with the spinlock in the wait_queue_head_t held.
- */
-static inline void remove_wait_queue_locked(wait_queue_head_t *q,
- wait_queue_t * wait)
-{
- __remove_wait_queue(q, wait);
-}
-
#define remove_parent(p) list_del_init(&(p)->sibling)
#define add_parent(p, parent) list_add_tail(&(p)->sibling,&(parent)->children)

diff -urpNX dontdiff linux-2.5.47/include/linux/wait.h linux-2.5.47-wait/include/linux/wait.h
--- linux-2.5.47/include/linux/wait.h 2002-09-27 20:10:43.000000000 -0700
+++ linux-2.5.47-wait/include/linux/wait.h 2002-11-15 07:36:32.000000000 -0800
@@ -10,14 +10,11 @@

#ifdef __KERNEL__

-#include <linux/kernel.h>
+#include <linux/config.h>
#include <linux/list.h>
#include <linux/stddef.h>
#include <linux/spinlock.h>
-#include <linux/config.h>
-
-#include <asm/page.h>
-#include <asm/processor.h>
+#include <asm/system.h>

typedef struct __wait_queue wait_queue_t;
typedef int (*wait_queue_func_t)(wait_queue_t *wait, unsigned mode, int sync);
@@ -83,6 +80,10 @@ static inline int waitqueue_active(wait_
return !list_empty(&q->task_list);
}

+extern void FASTCALL(add_wait_queue(wait_queue_head_t *q, wait_queue_t * wait));
+extern void FASTCALL(add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t * wait));
+extern void FASTCALL(remove_wait_queue(wait_queue_head_t *q, wait_queue_t * wait));
+
static inline void __add_wait_queue(wait_queue_head_t *head, wait_queue_t *new)
{
list_add(&new->task_list, &head->task_list);
@@ -103,6 +104,125 @@ static inline void __remove_wait_queue(w
list_del(&old->task_list);
}

+extern void FASTCALL(__wake_up(wait_queue_head_t *q, unsigned int mode, int nr));
+extern void FASTCALL(__wake_up_locked(wait_queue_head_t *q, unsigned int mode));
+extern void FASTCALL(__wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr));
+
+#define wake_up(x) __wake_up((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 1)
+#define wake_up_nr(x, nr) __wake_up((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, nr)
+#define wake_up_all(x) __wake_up((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 0)
+#define wake_up_interruptible(x) __wake_up((x),TASK_INTERRUPTIBLE, 1)
+#define wake_up_interruptible_nr(x, nr) __wake_up((x),TASK_INTERRUPTIBLE, nr)
+#define wake_up_interruptible_all(x) __wake_up((x),TASK_INTERRUPTIBLE, 0)
+#define wake_up_locked(x) __wake_up_locked((x), TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE)
+#ifdef CONFIG_SMP
+#define wake_up_interruptible_sync(x) __wake_up_sync((x),TASK_INTERRUPTIBLE, 1)
+#else
+#define wake_up_interruptible_sync(x) __wake_up((x),TASK_INTERRUPTIBLE, 1)
+#endif
+
+#define __wait_event(wq, condition) \
+do { \
+ wait_queue_t __wait; \
+ init_waitqueue_entry(&__wait, current); \
+ \
+ add_wait_queue(&wq, &__wait); \
+ for (;;) { \
+ set_current_state(TASK_UNINTERRUPTIBLE); \
+ if (condition) \
+ break; \
+ schedule(); \
+ } \
+ current->state = TASK_RUNNING; \
+ remove_wait_queue(&wq, &__wait); \
+} while (0)
+
+#define wait_event(wq, condition) \
+do { \
+ if (condition) \
+ break; \
+ __wait_event(wq, condition); \
+} while (0)
+
+#define __wait_event_interruptible(wq, condition, ret) \
+do { \
+ wait_queue_t __wait; \
+ init_waitqueue_entry(&__wait, current); \
+ \
+ add_wait_queue(&wq, &__wait); \
+ for (;;) { \
+ set_current_state(TASK_INTERRUPTIBLE); \
+ if (condition) \
+ break; \
+ if (!signal_pending(current)) { \
+ schedule(); \
+ continue; \
+ } \
+ ret = -ERESTARTSYS; \
+ break; \
+ } \
+ current->state = TASK_RUNNING; \
+ remove_wait_queue(&wq, &__wait); \
+} while (0)
+
+#define wait_event_interruptible(wq, condition) \
+({ \
+ int __ret = 0; \
+ if (!(condition)) \
+ __wait_event_interruptible(wq, condition, __ret); \
+ __ret; \
+})
+
+#define __wait_event_interruptible_timeout(wq, condition, ret) \
+do { \
+ wait_queue_t __wait; \
+ init_waitqueue_entry(&__wait, current); \
+ \
+ add_wait_queue(&wq, &__wait); \
+ for (;;) { \
+ set_current_state(TASK_INTERRUPTIBLE); \
+ if (condition) \
+ break; \
+ if (!signal_pending(current)) { \
+ ret = schedule_timeout(ret); \
+ if (!ret) \
+ break; \
+ continue; \
+ } \
+ ret = -ERESTARTSYS; \
+ break; \
+ } \
+ current->state = TASK_RUNNING; \
+ remove_wait_queue(&wq, &__wait); \
+} while (0)
+
+#define wait_event_interruptible_timeout(wq, condition, timeout) \
+({ \
+ long __ret = timeout; \
+ if (!(condition)) \
+ __wait_event_interruptible_timeout(wq, condition, __ret); \
+ __ret; \
+})
+
+/*
+ * Must be called with the spinlock in the wait_queue_head_t held.
+ */
+static inline void add_wait_queue_exclusive_locked(wait_queue_head_t *q,
+ wait_queue_t * wait)
+{
+ wait->flags |= WQ_FLAG_EXCLUSIVE;
+ __add_wait_queue_tail(q, wait);
+}
+
+/*
+ * Must be called with the spinlock in the wait_queue_head_t held.
+ */
+static inline void remove_wait_queue_locked(wait_queue_head_t *q,
+ wait_queue_t * wait)
+{
+ __remove_wait_queue(q, wait);
+}
+
#define add_wait_queue_cond(q, wait, cond) \
({ \
unsigned long flags; \
@@ -120,7 +240,19 @@ static inline void __remove_wait_queue(w
})

/*
- * Waitqueue's which are removed from the waitqueue_head at wakeup time
+ * These are the old interfaces to sleep waiting for an event.
+ * They are racy. DO NOT use them, use the wait_event* interfaces above.
+ * We plan to remove these interfaces during 2.7.
+ */
+extern void FASTCALL(sleep_on(wait_queue_head_t *q));
+extern long FASTCALL(sleep_on_timeout(wait_queue_head_t *q,
+ signed long timeout));
+extern void FASTCALL(interruptible_sleep_on(wait_queue_head_t *q));
+extern long FASTCALL(interruptible_sleep_on_timeout(wait_queue_head_t *q,
+ signed long timeout));
+
+/*
+ * Waitqueues which are removed from the waitqueue_head at wakeup time
*/
void FASTCALL(prepare_to_wait(wait_queue_head_t *q,
wait_queue_t *wait, int state));

--
Revolutions do not require corporate support.

2002-11-15 17:26:27

by Benjamin LaHaise

[permalink] [raw]
Subject: Re: [PATCH] use thread_info.h in uaccess.h

On Fri, Nov 15, 2002 at 04:49:27PM +0000, Matthew Wilcox wrote:
>
> While we're janitoring headers...
>
> This patch removes all the wait_queue handling code from sched.h and puts
> it in wait.h with the rest of the wait_queue handling code. Note that
> sched.h must continue to include wait.h for the wait_queue_head_t embedded
> in struct task. However there may be files which only need wait.h now.

Move the typedef into linux/types.h and that problem goes away.

-ben