Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754431AbdIFCPI (ORCPT ); Tue, 5 Sep 2017 22:15:08 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5974 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753895AbdIFCPG (ORCPT ); Tue, 5 Sep 2017 22:15:06 -0400 Message-ID: <59AF5A20.2000101@huawei.com> Date: Wed, 6 Sep 2017 10:14:56 +0800 From: Xishi Qiu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: LKML , Linux MM CC: Xishi Qiu , zhong jiang Subject: [RFC] a question about stack size form /proc/pid/task/child pid/limits Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.25.179] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.59AF5A28.0099,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 79a85117c1473e0fc54b39504b1df32b Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1364 Lines: 32 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