diff options
| author | Oleg Nesterov <[email protected]> | 2009-09-22 16:45:34 -0700 | 
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2009-09-23 07:39:40 -0700 | 
| commit | 9b4d1cbef8f41aff2b3e4ca31f566c071fe601de (patch) | |
| tree | fc64d537b5142646d917ad928e3fb1df4caf4655 /fs/proc/array.c | |
| parent | cff4edb591c153a779a27a3fd8e7bc1217f2f6b8 (diff) | |
proc_flush_task: flush /proc/tid/task/pid when a sub-thread exits
The exiting sub-thread flushes /proc/pid only, but this doesn't buy too
much: ps and friends mostly use /proc/tid/task/pid.
Remove "if (thread_group_leader())" checks from proc_flush_task() path,
this means we always remove /proc/tid/task/pid dentry on exit, and this
actually matches the comment above proc_flush_task().
The test-case:
	static void* tfunc(void *arg)
	{
		char name[256];
		sprintf(name, "/proc/%d/task/%ld/status", getpid(), gettid());
		close(open(name, O_RDONLY));
		return NULL;
	}
	int main(void)
	{
		pthread_t t;
		for (;;) {
			if (!pthread_create(&t, NULL, &tfunc, NULL))
				pthread_join(t, NULL);
		}
	}
slabtop shows that pid/proc_inode_cache/etc grow quickly and
"indefinitely" until the task is killed or shrink_slab() is called, not
good.  And the main thread needs a lot of time to exit.
The same can happen if something like "ps -efL" runs continuously, while
some application spawns short-living threads.
Reported-by: "James M. Leddy" <[email protected]>
Signed-off-by: Oleg Nesterov <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Dominic Duval <[email protected]>
Cc: Frank Hirtz <[email protected]>
Cc: "Fuller, Johnray" <[email protected]>
Cc: Larry Woodman <[email protected]>
Cc: Paul Batkowski <[email protected]>
Cc: Roland McGrath <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'fs/proc/array.c')
0 files changed, 0 insertions, 0 deletions