linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC] a question about stack size form /proc/pid/task/child pid/limits
@ 2017-09-06  2:14 Xishi Qiu
  2017-11-27 11:33 ` Florian Weimer
  0 siblings, 1 reply; 2+ messages in thread
From: Xishi Qiu @ 2017-09-06  2:14 UTC (permalink / raw)
  To: LKML, Linux MM; +Cc: Xishi Qiu, zhong jiang

Hi, I find if I use a defined stack size to create a child thread,
then the max stack size from /proc/pid/task/child pid/limits still
shows "Max stack size            8388608", it doesn't update to
the user defined size, is it a problem?

Here is the test code:
		...
                pthread_attr_t attr;
                ret = pthread_attr_init(&attr);
                if (ret)
                        printf("error\n");
                ret = pthread_attr_setstacksize(&attr, 83886080);
                if (ret)
                        printf("error\n");
                ret = pthread_create(&id_1[i], &attr, (void  *)thread_alloc, NULL);
		...

I use strace to track the app, it shows glibc will call mmap to
alloc the child thread stack. So should gilbc call setrlimit to
update the stack limit too?

And glibc will only insert a guard at the start of the stack vma,
so the stack vma maybe merged to another vma at the end, right?

...
mmap(NULL, 83890176, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7fca1d6a6000
mprotect(0x7fca1d6a6000, 4096, PROT_NONE) = 0
clone(child_stack=0x7fca226a5fb0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7fca226a69d0, tls=0x7fca226a6700, child_tidptr=0x7fca226a69d0) = 21043
...

Thanks,
Xishi Qiu

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [RFC] a question about stack size form /proc/pid/task/child pid/limits
  2017-09-06  2:14 [RFC] a question about stack size form /proc/pid/task/child pid/limits Xishi Qiu
@ 2017-11-27 11:33 ` Florian Weimer
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Weimer @ 2017-11-27 11:33 UTC (permalink / raw)
  To: Xishi Qiu, LKML, Linux MM; +Cc: zhong jiang

On 09/06/2017 04:14 AM, Xishi Qiu wrote:
> Hi, I find if I use a defined stack size to create a child thread,
> then the max stack size from /proc/pid/task/child pid/limits still
> shows "Max stack size            8388608", it doesn't update to
> the user defined size, is it a problem?

This reflects the maximum stack size of the main thread after execve. 
The size of the stack of the current thread is a separate matter; it can 
be located anywhere in the process image and much smaller or larger than 
the maximum size of the initial stack of the main thread.

Thanks,
Florian

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-11-27 11:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-06  2:14 [RFC] a question about stack size form /proc/pid/task/child pid/limits Xishi Qiu
2017-11-27 11:33 ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).