From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id 703AF3858C50 for ; Tue, 28 Mar 2023 15:05:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 703AF3858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32SExmaR006053; Tue, 28 Mar 2023 15:05:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=references : from : to : cc : subject : in-reply-to : date : message-id : content-type : mime-version; s=corp-2022-7-12; bh=BIe2V8gP1UP7pbjBTt/tr1Towz5D/2KtDZWRWjECz+U=; b=TCse8060dv+LjVstOUoPRa1K8SjGevjUyiXkzG6O+7Oxz7PaKaBhvGZFEPXXsPoxtKjO la0hOxk5Qfxgz6bhhUHywAGrQenSK/+qcsC15+sumlS0efY42EiqD2vYmdm0Ks/C1uve jxz/cGelFGtmwMUnxLwbyFHYlbcPH06HVYgQ7xqIRWE/uA61IAeByvDYk615WgFkvInZ NcpxL2ASwKVpl1xsghGudlPmnp+j8LMqyw629dHz4l4iTviHHmgfGE4zPOuzAOHHKoPn riFtWR+q6/IRmdcR1WEfmPrE4Mm6RGriiH6N/wbXllkn+FbiW/Nee9Q7+k/TpPnf5Ggk pw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3pm2fx815x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Mar 2023 15:05:18 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 32SDxow2027729; Tue, 28 Mar 2023 15:05:16 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2105.outbound.protection.outlook.com [104.47.58.105]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3phqd6ha44-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Mar 2023 15:05:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=faP2sJh8f/L9cdl6uSTA6Cn7LLKKUYkscO3oQxXEk9wPVwvHx6Yo4V9KDjNHhl9O/KY46eGeEL7B++6g+WIlDKWKhLFCauZ14xKzk7vo9qoJOywMy5AV4hAWlEt2DRC4Z8iNLb972b5v3N9xZ0ITsTvXZgpHRxp4eMrspxKSgjYrwNQNWZyVsbzRTesCxPHjlVurGA7xGwtCfdKc0ZeHy+XhAGuoIhFnpAV9xPUpb9cHqbctpQbuiQBoYRsGvZNHgap199o4Hw3Y15V2EouRuTFehgB7H0oxz9UUyeQY6O6iNERhv32UAjfWOaq7w7Kgm6ghHoIRWw+/cz1khtQyBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BIe2V8gP1UP7pbjBTt/tr1Towz5D/2KtDZWRWjECz+U=; b=S0MYGrF1W4EsIjr2t5wnkszLMW97f6pOkxOr8T7gBj9d0iEm2bSv58TlgBQNB4jfYtfCJU3D5FEi+K/Nyl4pI11QYk9DHqKmFOyIH+xfNyYK7z8v55iK14hEbKrBOsXtt0xMGvPeGcZyjoQ1Zijb5lCSbQRkQNAyDbbnznDJdrIYRLvBs+4eO6SrxkegRAsAk8bbJfCnoY+79WbFuNa27YidvGBHWp4Eel5iR5CfOE//n7nXtqbc3QbNBHIof3oCXseeyeEfh2IR3CkpF237r6DCiojkiqC1/bL1jJm50aa8VeCKRQU5SizKmsi+T7LldqHOjkVO1LO9y2OAR6OosA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BIe2V8gP1UP7pbjBTt/tr1Towz5D/2KtDZWRWjECz+U=; b=SLQwQAwxILXoiB5XMYn+NSTJGnYLmLfE33U7N8ZH1vFR4Wd05wKsYWAzo2aGmDCNpaVhBmLUvjicK8iJXP11fqZcqXWljU9zN4yq7B9UvZK94b3W4uTFnyAIumPPjeFG5g3D92kqUg5K7buwButeVdL0WesjXVb4RMKuaUhLR5Q= Received: from BN6PR1001MB2340.namprd10.prod.outlook.com (2603:10b6:405:30::36) by MW4PR10MB6560.namprd10.prod.outlook.com (2603:10b6:303:226::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Tue, 28 Mar 2023 15:05:14 +0000 Received: from BN6PR1001MB2340.namprd10.prod.outlook.com ([fe80::a502:c948:c3f6:9728]) by BN6PR1001MB2340.namprd10.prod.outlook.com ([fe80::a502:c948:c3f6:9728%6]) with mapi id 15.20.6178.038; Tue, 28 Mar 2023 15:05:13 +0000 References: <20230328085538.48080-1-cupertino.miranda@oracle.com> <20230328085538.48080-2-cupertino.miranda@oracle.com> <0324d4f3-6e0e-5cc3-90a3-ca042d42f000@linaro.org> User-agent: mu4e 1.4.15; emacs 28.1 From: Cupertino Miranda To: Adhemerval Zanella Netto Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v4 1/1] Created tunable to force small pages on stack allocation. In-reply-to: <0324d4f3-6e0e-5cc3-90a3-ca042d42f000@linaro.org> Date: Tue, 28 Mar 2023 16:05:07 +0100 Message-ID: <87bkkcj4rg.fsf@oracle.com> Content-Type: text/plain X-ClientProxiedBy: AM0PR01CA0093.eurprd01.prod.exchangelabs.com (2603:10a6:208:10e::34) To BN6PR1001MB2340.namprd10.prod.outlook.com (2603:10b6:405:30::36) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN6PR1001MB2340:EE_|MW4PR10MB6560:EE_ X-MS-Office365-Filtering-Correlation-Id: 23242bfb-0de2-4e02-ca54-08db2f9dd4dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: prCVyT87AGjY57bgsSYgSYWxsIPI+n6GfMXFEjFzUBm3wAWYui+a9QW26mmVTsFIk0xQIdvphZ3+1u7i2JviCIKrLy2/eHVUCVwcJIq9IyyOKkwkklGli3MkJt3uodw6Ah3pErCPpkvkhBW3vTuPKgHbLnbcYIbITcW9ckIQ/ADtiYhBzNFoC19Mn18ee3ZgFEWnu2jBTtBKOha01MNRfLN7nEUNn3V8iSKRa/bTZJyW1fCzECqS6jrQctSSPYs4aFETCZhXmXkbyBv9gNo/zNholVIvx5TOHMSm6/3yENAPIg6K1+s289JxTMQ/TAlsKwBoav8xqI2qgfVRKqa5zUoP1/+1lAkcRNmDq8Qmxj5OP78geaYLiZoutDIplQZLJ7g8D78y28suJz6H5KFimAdT/xUGl1eE6E50iiqHODH9AyhJlinKVgaUljvnCfSNWVti3G7jHA1cYc/n0WiYN1iX6ohcDb0+3DIyWKFcM+h7781VIZmamchzmf2K8OaF70BFQqF1RWkNxQQMTG9OhZpYGtbnJQvBA5W0csLfLF0nh2evP5XD3AV7EucoRXed X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR1001MB2340.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(136003)(396003)(376002)(346002)(366004)(451199021)(36756003)(66556008)(44832011)(41300700001)(2906002)(8676002)(4326008)(6512007)(53546011)(5660300002)(316002)(8936002)(2616005)(186003)(66476007)(6506007)(478600001)(86362001)(6486002)(6666004)(38100700002)(6916009)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?A3/uRnpueAljVz2wkd/irXDORTiJjDb74U0QBDxNhkTPWCCZe2uP3ec19V3n?= =?us-ascii?Q?bWBtRFYVv2zxX4HOggr6VQoIVJNRJ88riNKFziALJz4IkQGXlGQWNoIqWfiN?= =?us-ascii?Q?NsnapkSq+z98m12VfOpY5MWECDN3ebe6uelUP5M/fkagUe7rn++5NMyjJPLG?= =?us-ascii?Q?N3WgAgSn4Q05IiisZoJ+s25EZ/LRKMAy49CLYUCHTLLiPtLUVioGkDZ4STMy?= =?us-ascii?Q?M0s7CFnEeA+l97lpK4R0ETFiw3/Iq/ZfJ3fExwZYgFZPZVnWzTq7PM4Rvu7k?= =?us-ascii?Q?aPLp25ZTefsf/glZhNwSUiXyiZ6tVTs2t5omTKIBvEfpYpBvB1y/Ws9AsA61?= =?us-ascii?Q?ocZGi+oDZsWPrwO3RQggZ3F0bc9HM4I8/hV4CCZ2vsMhbiUtEcK7JkK4jFdo?= =?us-ascii?Q?uFMWrwug2JBnUOKo8nqjiOHwQ2UlNEFhmTTmGFA8SIi5gwcC391oAAd7RJBn?= =?us-ascii?Q?p3pnGDoKUGgoi8YVkL/cdIHitOSIolDiLFKh12DTsxaJSRN+7iPTiYjVfJyd?= =?us-ascii?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2/IyaNxoJyAMMYlxiD4ImYfE3xIDkot3BZRBHM7CBpV+jlNx38Q/qTBJ8/YqFtpx5ZL783EWQ+KJ+Dg62kFOAVJhuCApgc5KQ+xjArXaPj0JMLr7eTg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 23242bfb-0de2-4e02-ca54-08db2f9dd4dd X-MS-Exchange-CrossTenant-AuthSource: BN6PR1001MB2340.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2023 15:05:13.2920 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MI+rjVe5MUGMEAinE7b7F73x4HRcm6pN3IZVqv8JcOoX5UR+Z5bN5sBjLJ6ndxbOlWYzKc+UlaDKnxAWKDyxS9XLmv1bscTJ64W6JV70RtA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6560 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-24_11,2023-03-28_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2303280118 X-Proofpoint-ORIG-GUID: XoDI8ogonHcweDkwIeVhgtpAmhiE0Nam X-Proofpoint-GUID: XoDI8ogonHcweDkwIeVhgtpAmhiE0Nam X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Adhemerval Zanella Netto writes: > On 28/03/23 05:55, Cupertino Miranda via Libc-alpha wrote: >> Created tunable glibc.pthread.stack_hugetlb to control when hugepages >> can be used for stack allocation. >> In case THP are enabled and glibc.pthread.stack_hugetlb is set to >> 0, glibc will madvise the kernel not to use allow hugepages for stack >> allocations. >> >> Changed from v1: >> - removed the __malloc_thp_mode calls to check if hugetlb is >> enabled. >> >> Changed from v2: >> - Added entry in manual/tunables.texi >> - Fixed tunable default to description >> - Code style corrections. >> >> Changes from v3: >> - Improve tunables.texi. >> --- >> manual/tunables.texi | 14 ++++++++++++++ >> nptl/allocatestack.c | 6 ++++++ >> nptl/nptl-stack.c | 1 + >> nptl/nptl-stack.h | 3 +++ >> nptl/pthread_mutex_conf.c | 8 ++++++++ >> sysdeps/nptl/dl-tunables.list | 6 ++++++ >> 6 files changed, 38 insertions(+) >> >> diff --git a/manual/tunables.texi b/manual/tunables.texi >> index 70dd2264c5..182f644851 100644 >> --- a/manual/tunables.texi >> +++ b/manual/tunables.texi >> @@ -459,6 +459,20 @@ registration on behalf of the application. >> Restartable sequences are a Linux-specific extension. >> @end deftp >> >> +@deftp Tunable glibc.pthread.stack_hugetlb >> +This tunable allows to configure pthread creation stack allocation never to use >> +hugetlbs. >> +This is more of an RSS optimization, for example in scenarios where many >> +threads get created, keeping RSS to a minimum, but also allowing hugestlbs to >> +be used for malloc allocations. >> +This tunable only affects stacks allocated through thread creation process, >> +i.e. it has no effect on stacks assigned with pthread_attr_setstack. >> + >> +The default is @samp{1} and preservs glibc default behaviour. >> +When set to @samp{0}, it advises the kernel not to use hugetlbs for stack >> +allocation. >> +@end deftp >> + > > We use 'Huge Pages' on glibc.malloc.hugetlb (hugestlbs sounds strange), RSS is not > defined in any place (even it is a common Linux VM term), pthread_attr_setstack > needs to be within a @code. > > What about the following: > > This tunable controls whether to use Huge Pages in the stacks created by > @code{pthread_create}. This tunable only affects the stacks created by > @theglibc{}, it has not effect on stack assigned with @code{pthread_attr_setstack}. > > The default is @samp{1} where the system default value is used. Setting > its value to @code{0} enables the use of @code{madvise} with @code{MADV_NOHUGEPAGE} > after stack creation with @code{mmap}. > > This is a memory utilization optimization, since internal glibc setup of either > the thread descriptor and the guard page might force the kernel to move the > thread stack originally backup by Huge Pages to default pages. > > (maybe expand a bit the problem this tunable aims to improve) > It looks good to me. Apologies for the documentation problems and thanks for the correction. Next time I will be more careful. Cupertino >> @node Hardware Capability Tunables >> @section Hardware Capability Tunables >> @cindex hardware capability tunables >> diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c >> index c7adbccd6f..f9d8cdfd08 100644 >> --- a/nptl/allocatestack.c >> +++ b/nptl/allocatestack.c >> @@ -369,6 +369,12 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, >> if (__glibc_unlikely (mem == MAP_FAILED)) >> return errno; >> >> + /* Do madvise in case the tunable glibc.pthread.stack_hugetlb is >> + set to 0, disabling hugetlb. */ >> + if (__glibc_unlikely (__nptl_stack_hugetlb == 0) >> + && __madvise (mem, size, MADV_NOHUGEPAGE) != 0) >> + return errno; >> + >> /* SIZE is guaranteed to be greater than zero. >> So we can never get a null pointer back from mmap. */ >> assert (mem != NULL); >> diff --git a/nptl/nptl-stack.c b/nptl/nptl-stack.c >> index 5eb7773575..e829711cb5 100644 >> --- a/nptl/nptl-stack.c >> +++ b/nptl/nptl-stack.c >> @@ -21,6 +21,7 @@ >> #include >> >> size_t __nptl_stack_cache_maxsize = 40 * 1024 * 1024; >> +int32_t __nptl_stack_hugetlb = 1; >> >> void >> __nptl_stack_list_del (list_t *elem) >> diff --git a/nptl/nptl-stack.h b/nptl/nptl-stack.h >> index 34f8bbb15e..cf90b27c2b 100644 >> --- a/nptl/nptl-stack.h >> +++ b/nptl/nptl-stack.h >> @@ -27,6 +27,9 @@ >> /* Maximum size of the cache, in bytes. 40 MiB by default. */ >> extern size_t __nptl_stack_cache_maxsize attribute_hidden; >> >> +/* Should allow stacks to use hugetlb. (1) is default. */ >> +extern int32_t __nptl_stack_hugetlb; >> + >> /* Check whether the stack is still used or not. */ >> static inline bool >> __nptl_stack_in_use (struct pthread *pd) >> diff --git a/nptl/pthread_mutex_conf.c b/nptl/pthread_mutex_conf.c >> index 329c4cbb8f..60ef9095aa 100644 >> --- a/nptl/pthread_mutex_conf.c >> +++ b/nptl/pthread_mutex_conf.c >> @@ -45,6 +45,12 @@ TUNABLE_CALLBACK (set_stack_cache_size) (tunable_val_t *valp) >> __nptl_stack_cache_maxsize = valp->numval; >> } >> >> +static void >> +TUNABLE_CALLBACK (set_stack_hugetlb) (tunable_val_t *valp) >> +{ >> + __nptl_stack_hugetlb = (int32_t) valp->numval; >> +} >> + >> void >> __pthread_tunables_init (void) >> { >> @@ -52,5 +58,7 @@ __pthread_tunables_init (void) >> TUNABLE_CALLBACK (set_mutex_spin_count)); >> TUNABLE_GET (stack_cache_size, size_t, >> TUNABLE_CALLBACK (set_stack_cache_size)); >> + TUNABLE_GET (stack_hugetlb, int32_t, >> + TUNABLE_CALLBACK (set_stack_hugetlb)); >> } >> #endif > > Different than glibc.malloc.hugetlb, we always enable it even if the system does not > support THP. I think it should be ok (although not in sync with glibc.malloc.hugetlb > support). > >> diff --git a/sysdeps/nptl/dl-tunables.list b/sysdeps/nptl/dl-tunables.list >> index bd1ddb121d..4cde9500b6 100644 >> --- a/sysdeps/nptl/dl-tunables.list >> +++ b/sysdeps/nptl/dl-tunables.list >> @@ -33,5 +33,11 @@ glibc { >> maxval: 1 >> default: 1 >> } >> + stack_hugetlb { >> + type: INT_32 >> + minval: 0 >> + maxval: 1 >> + default: 1 >> + } >> } >> }