Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
ac3e3c5b
Commit
ac3e3c5b
authored
Apr 28, 2013
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't bother with deferred freeing of fdtables
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
094dd33b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
67 deletions
+2
-67
fs/file.c
fs/file.c
+2
-66
include/linux/fdtable.h
include/linux/fdtable.h
+0
-1
No files found.
fs/file.c
View file @
ac3e3c5b
...
...
@@ -23,24 +23,10 @@
#include <linux/rcupdate.h>
#include <linux/workqueue.h>
struct
fdtable_defer
{
spinlock_t
lock
;
struct
work_struct
wq
;
struct
fdtable
*
next
;
};
int
sysctl_nr_open
__read_mostly
=
1024
*
1024
;
int
sysctl_nr_open_min
=
BITS_PER_LONG
;
int
sysctl_nr_open_max
=
1024
*
1024
;
/* raised later */
/*
* We use this list to defer free fdtables that have vmalloced
* sets/arrays. By keeping a per-cpu list, we avoid having to embed
* the work_struct in fdtable itself which avoids a 64 byte (i386) increase in
* this per-task structure.
*/
static
DEFINE_PER_CPU
(
struct
fdtable_defer
,
fdtable_defer_list
);
static
void
*
alloc_fdmem
(
size_t
size
)
{
/*
...
...
@@ -67,46 +53,9 @@ static void __free_fdtable(struct fdtable *fdt)
kfree
(
fdt
);
}
static
void
free_fdtable_work
(
struct
work_struct
*
work
)
{
struct
fdtable_defer
*
f
=
container_of
(
work
,
struct
fdtable_defer
,
wq
);
struct
fdtable
*
fdt
;
spin_lock_bh
(
&
f
->
lock
);
fdt
=
f
->
next
;
f
->
next
=
NULL
;
spin_unlock_bh
(
&
f
->
lock
);
while
(
fdt
)
{
struct
fdtable
*
next
=
fdt
->
next
;
__free_fdtable
(
fdt
);
fdt
=
next
;
}
}
static
void
free_fdtable_rcu
(
struct
rcu_head
*
rcu
)
{
struct
fdtable
*
fdt
=
container_of
(
rcu
,
struct
fdtable
,
rcu
);
struct
fdtable_defer
*
fddef
;
BUG_ON
(
!
fdt
);
BUG_ON
(
fdt
->
max_fds
<=
NR_OPEN_DEFAULT
);
if
(
!
is_vmalloc_addr
(
fdt
->
fd
)
&&
!
is_vmalloc_addr
(
fdt
->
open_fds
))
{
kfree
(
fdt
->
fd
);
kfree
(
fdt
->
open_fds
);
kfree
(
fdt
);
}
else
{
fddef
=
&
get_cpu_var
(
fdtable_defer_list
);
spin_lock
(
&
fddef
->
lock
);
fdt
->
next
=
fddef
->
next
;
fddef
->
next
=
fdt
;
/* vmallocs are handled from the workqueue context */
schedule_work
(
&
fddef
->
wq
);
spin_unlock
(
&
fddef
->
lock
);
put_cpu_var
(
fdtable_defer_list
);
}
__free_fdtable
(
container_of
(
rcu
,
struct
fdtable
,
rcu
));
}
/*
...
...
@@ -174,7 +123,6 @@ static struct fdtable * alloc_fdtable(unsigned int nr)
fdt
->
open_fds
=
data
;
data
+=
nr
/
BITS_PER_BYTE
;
fdt
->
close_on_exec
=
data
;
fdt
->
next
=
NULL
;
return
fdt
;
...
...
@@ -221,7 +169,7 @@ static int expand_fdtable(struct files_struct *files, int nr)
/* Continue as planned */
copy_fdtable
(
new_fdt
,
cur_fdt
);
rcu_assign_pointer
(
files
->
fdt
,
new_fdt
);
if
(
cur_fdt
->
max_fds
>
NR_OPEN_DEFAULT
)
if
(
cur_fdt
!=
&
files
->
fdtab
)
call_rcu
(
&
cur_fdt
->
rcu
,
free_fdtable_rcu
);
}
else
{
/* Somebody else expanded, so undo our attempt */
...
...
@@ -316,7 +264,6 @@ struct files_struct *dup_fd(struct files_struct *oldf, int *errorp)
new_fdt
->
close_on_exec
=
newf
->
close_on_exec_init
;
new_fdt
->
open_fds
=
newf
->
open_fds_init
;
new_fdt
->
fd
=
&
newf
->
fd_array
[
0
];
new_fdt
->
next
=
NULL
;
spin_lock
(
&
oldf
->
file_lock
);
old_fdt
=
files_fdtable
(
oldf
);
...
...
@@ -490,19 +437,8 @@ void exit_files(struct task_struct *tsk)
}
}
static
void
fdtable_defer_list_init
(
int
cpu
)
{
struct
fdtable_defer
*
fddef
=
&
per_cpu
(
fdtable_defer_list
,
cpu
);
spin_lock_init
(
&
fddef
->
lock
);
INIT_WORK
(
&
fddef
->
wq
,
free_fdtable_work
);
fddef
->
next
=
NULL
;
}
void
__init
files_defer_init
(
void
)
{
int
i
;
for_each_possible_cpu
(
i
)
fdtable_defer_list_init
(
i
);
sysctl_nr_open_max
=
min
((
size_t
)
INT_MAX
,
~
(
size_t
)
0
/
sizeof
(
void
*
))
&
-
BITS_PER_LONG
;
}
...
...
include/linux/fdtable.h
View file @
ac3e3c5b
...
...
@@ -27,7 +27,6 @@ struct fdtable {
unsigned
long
*
close_on_exec
;
unsigned
long
*
open_fds
;
struct
rcu_head
rcu
;
struct
fdtable
*
next
;
};
static
inline
bool
close_on_exec
(
int
fd
,
const
struct
fdtable
*
fdt
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment