All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xishi Qiu <qiuxishi@huawei.com>
To: LKML <linux-kernel@vger.kernel.org>, Linux MM <linux-mm@kvack.org>
Cc: Xishi Qiu <qiuxishi@huawei.com>, zhong jiang <zhongjiang@huawei.com>
Subject: [RFC] a question about stack size form /proc/pid/task/child pid/limits
Date: Wed, 6 Sep 2017 10:14:56 +0800	[thread overview]
Message-ID: <59AF5A20.2000101@huawei.com> (raw)

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>

WARNING: multiple messages have this Message-ID (diff)
From: Xishi Qiu <qiuxishi@huawei.com>
To: LKML <linux-kernel@vger.kernel.org>, Linux MM <linux-mm@kvack.org>
Cc: Xishi Qiu <qiuxishi@huawei.com>, zhong jiang <zhongjiang@huawei.com>
Subject: [RFC] a question about stack size form /proc/pid/task/child pid/limits
Date: Wed, 6 Sep 2017 10:14:56 +0800	[thread overview]
Message-ID: <59AF5A20.2000101@huawei.com> (raw)

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

             reply	other threads:[~2017-09-06  2:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-06  2:14 Xishi Qiu [this message]
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
2017-11-27 11:33   ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=59AF5A20.2000101@huawei.com \
    --to=qiuxishi@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=zhongjiang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.