* [patch] 2.5.22 add __fput for aio
@ 2002-06-17 19:47 Benjamin LaHaise
2002-06-17 20:11 ` Linus Torvalds
0 siblings, 1 reply; 6+ messages in thread
From: Benjamin LaHaise @ 2002-06-17 19:47 UTC (permalink / raw)
To: Linus Torvalds, Linux Kernel
Hello Linus,
This patch splits fput into fput and __fput. __fput is needed by aio
to construct a mechanism for performing fput during io completion,
which typically occurs during interrupt context.
-ben
--
"You will be reincarnated as a toad; and you will be much happier."
diff -urN v2.5.22/fs/file_table.c fput-v2.5.22/fs/file_table.c
--- v2.5.22/fs/file_table.c Thu Jun 6 00:35:32 2002
+++ fput-v2.5.22/fs/file_table.c Mon Jun 17 15:43:10 2002
@@ -100,31 +100,38 @@
void fput(struct file * file)
{
+ if (atomic_dec_and_test(&file->f_count))
+ __fput(file);
+}
+
+/* __fput is needed for aio, which provides a mechanism for doing fput
+ * from an interrupt handler.
+ */
+void __fput(struct file * file)
+{
struct dentry * dentry = file->f_dentry;
struct vfsmount * mnt = file->f_vfsmnt;
struct inode * inode = dentry->d_inode;
- if (atomic_dec_and_test(&file->f_count)) {
- locks_remove_flock(file);
+ locks_remove_flock(file);
- if (file->f_iobuf)
- free_kiovec(1, &file->f_iobuf);
+ if (file->f_iobuf)
+ free_kiovec(1, &file->f_iobuf);
- if (file->f_op && file->f_op->release)
- file->f_op->release(inode, file);
- fops_put(file->f_op);
- if (file->f_mode & FMODE_WRITE)
- put_write_access(inode);
- file_list_lock();
- file->f_dentry = NULL;
- file->f_vfsmnt = NULL;
- list_del(&file->f_list);
- list_add(&file->f_list, &free_list);
- files_stat.nr_free_files++;
- file_list_unlock();
- dput(dentry);
- mntput(mnt);
- }
+ if (file->f_op && file->f_op->release)
+ file->f_op->release(inode, file);
+ fops_put(file->f_op);
+ if (file->f_mode & FMODE_WRITE)
+ put_write_access(inode);
+ file_list_lock();
+ file->f_dentry = NULL;
+ file->f_vfsmnt = NULL;
+ list_del(&file->f_list);
+ list_add(&file->f_list, &free_list);
+ files_stat.nr_free_files++;
+ file_list_unlock();
+ dput(dentry);
+ mntput(mnt);
}
struct file * fget(unsigned int fd)
diff -urN v2.5.22/include/linux/file.h fput-v2.5.22/include/linux/file.h
--- v2.5.22/include/linux/file.h Thu Jun 6 00:35:16 2002
+++ fput-v2.5.22/include/linux/file.h Mon Jun 17 15:43:11 2002
@@ -33,6 +33,7 @@
struct file * fd_array[NR_OPEN_DEFAULT];
};
+extern void FASTCALL(__fput(struct file *));
extern void FASTCALL(fput(struct file *));
extern struct file * FASTCALL(fget(unsigned int fd));
extern void FASTCALL(set_close_on_exec(unsigned int fd, int flag));
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] 2.5.22 add __fput for aio
2002-06-17 19:47 [patch] 2.5.22 add __fput for aio Benjamin LaHaise
@ 2002-06-17 20:11 ` Linus Torvalds
2002-06-17 20:19 ` Benjamin LaHaise
0 siblings, 1 reply; 6+ messages in thread
From: Linus Torvalds @ 2002-06-17 20:11 UTC (permalink / raw)
To: Benjamin LaHaise; +Cc: Linux Kernel
On Mon, 17 Jun 2002, Benjamin LaHaise wrote:
>
> This patch splits fput into fput and __fput. __fput is needed by aio
> to construct a mechanism for performing fput during io completion,
> which typically occurs during interrupt context.
Ehh. Since you _cannot_ do __fput() from an interrupt context, something
is broken.
Possibly the comments.
If aio calls down to __fput() from an interrupt context, then aio is
clearly broken. Yet that's what the comments seem to imply.
The other alternative is that aio only does the book-keeping from
interrupt context, adds the "struct file * to be freed" to some list of
freeable files, and then does __fput() from _non_interrupt_ context on
those files.
Is that was aio actually _does_?
If so, the code may be fine, but the comments are misleading crap and
should be fixed asap.
Linus
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] 2.5.22 add __fput for aio
2002-06-17 20:11 ` Linus Torvalds
@ 2002-06-17 20:19 ` Benjamin LaHaise
2002-06-17 20:22 ` Linus Torvalds
0 siblings, 1 reply; 6+ messages in thread
From: Benjamin LaHaise @ 2002-06-17 20:19 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Linux Kernel
On Mon, Jun 17, 2002 at 01:11:04PM -0700, Linus Torvalds wrote:
> The other alternative is that aio only does the book-keeping from
> interrupt context, adds the "struct file * to be freed" to some list of
> freeable files, and then does __fput() from _non_interrupt_ context on
> those files.
>
> Is that was aio actually _does_?
Yes -- aio does the atomic_dec_and_test in the interrupt handler, and
if that was the last user of the struct file *, it queues the io handle
for cleanup from task context.
> If so, the code may be fine, but the comments are misleading crap and
> should be fixed asap.
Sure. How's changing it to:
+/* __fput is called from task task when aio completion releases the last
+ * use of a struct file *. Do not use otherwise.
+ */
instead?
-ben
--
"You will be reincarnated as a toad; and you will be much happier."
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] 2.5.22 add __fput for aio
2002-06-17 20:19 ` Benjamin LaHaise
@ 2002-06-17 20:22 ` Linus Torvalds
2002-06-17 20:41 ` Dynamic Timer X.Xiao
0 siblings, 1 reply; 6+ messages in thread
From: Linus Torvalds @ 2002-06-17 20:22 UTC (permalink / raw)
To: Benjamin LaHaise; +Cc: Linux Kernel
On Mon, 17 Jun 2002, Benjamin LaHaise wrote:
>
> Sure. How's changing it to:
>
> +/* __fput is called from task task when aio completion releases the last
> + * use of a struct file *. Do not use otherwise.
> + */
>
> instead?
Much better.
Linus
^ permalink raw reply [flat|nested] 6+ messages in thread
* Dynamic Timer
2002-06-17 20:22 ` Linus Torvalds
@ 2002-06-17 20:41 ` X.Xiao
2002-06-17 22:27 ` george anzinger
0 siblings, 1 reply; 6+ messages in thread
From: X.Xiao @ 2002-06-17 20:41 UTC (permalink / raw)
To: Linux Kernel
I have two questions about dynamic timer in Linux:
1. Kernel space: After add_timer is used, where is the
code used to poll the global 'struct timer_list' to
activate the related functions on time? It's not in
sched.c, is it in tasklet/bh?
2. User space: is there a way to set a dynamic timer
in userspace as well, such as create_timer(posix, not
in Linux)?
TIA
XH Xiao
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Dynamic Timer
2002-06-17 20:41 ` Dynamic Timer X.Xiao
@ 2002-06-17 22:27 ` george anzinger
0 siblings, 0 replies; 6+ messages in thread
From: george anzinger @ 2002-06-17 22:27 UTC (permalink / raw)
To: X.Xiao; +Cc: Linux Kernel
"X.Xiao" wrote:
>
> I have two questions about dynamic timer in Linux:
> 1. Kernel space: After add_timer is used, where is the
> code used to poll the global 'struct timer_list' to
> activate the related functions on time? It's not in
> sched.c, is it in tasklet/bh?
The "code" is in timer.c (same place you found "add_timer())
and is called run_timer_list(). It is called by timer_bh()
also in timer.c, which is scheduled by do_timer() (also in
timer.c) which is called each timer interrupt by code in the
arch/kernel/ area (in i386 it is time.c) which, in turn is
called by the interrupt code.
> 2. User space: is there a way to set a dynamic timer
> in userspace as well, such as create_timer(posix, not
> in Linux)?
The tried and true way is the setitimer() call. The POSIX
calls are also available as a patch from the high-res-timers
project (see signature).
--
George Anzinger george@mvista.com
High-res-timers:
http://sourceforge.net/projects/high-res-timers/
Real time sched: http://sourceforge.net/projects/rtsched/
Preemption patch:
http://www.kernel.org/pub/linux/kernel/people/rml
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2002-06-17 22:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-17 19:47 [patch] 2.5.22 add __fput for aio Benjamin LaHaise
2002-06-17 20:11 ` Linus Torvalds
2002-06-17 20:19 ` Benjamin LaHaise
2002-06-17 20:22 ` Linus Torvalds
2002-06-17 20:41 ` Dynamic Timer X.Xiao
2002-06-17 22:27 ` george anzinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox