From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2058.outbound.protection.outlook.com [40.107.22.58]) by sourceware.org (Postfix) with ESMTPS id 278DF385840C for ; Fri, 14 Apr 2023 15:32:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 278DF385840C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KSh91/9m2wgZezmbKZ2zhZWeFGu81JvllQqfTFAtAAc=; b=G9D39dVwcpq80We4jSrhqUduQ8l1NCMCYAlnxnn62Do50SkoOQkR5qz7Z5LwzDSGuHslca2VLjlX3ZY6s7FqKz9vpwqv6k4zKexaAkKi6zqyP5TL9aSh3ITtdagIZr1Egh4RHL3CJQpl7eMMKzcYexSeQhcKM8ftxTSwCQpumTA= Received: from DUZPR01CA0169.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b3::13) by DU2PR08MB10107.eurprd08.prod.outlook.com (2603:10a6:10:46f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Fri, 14 Apr 2023 15:32:43 +0000 Received: from DBAEUR03FT011.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4b3:cafe::b3) by DUZPR01CA0169.outlook.office365.com (2603:10a6:10:4b3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.36 via Frontend Transport; Fri, 14 Apr 2023 15:32:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT011.mail.protection.outlook.com (100.127.142.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.29 via Frontend Transport; Fri, 14 Apr 2023 15:32:42 +0000 Received: ("Tessian outbound 99a3040377ca:v136"); Fri, 14 Apr 2023 15:32:42 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 96009742f5361879 X-CR-MTA-TID: 64aa7808 Received: from e4ee2e5c6b32.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4A5FE3A1-74F0-4427-911C-A9B344A1D878.1; Fri, 14 Apr 2023 15:32:36 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e4ee2e5c6b32.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 14 Apr 2023 15:32:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NX4gBQOvNjeYSL3EvEXB7HrxqWTfBEtMq32Hm0Ob4syN6n4eCX4UeDr5IadAISX6sMs/kpqTbOQeq/W9GCr1lSdVrGImAEYi3CJO6QHUrpZSqTKLVB1a240WAjMnnLjfN/AuvAQTQqaGcKrMteIuov7MOpHJRsD5xJRobwU/fHt832XwdnDViKkSDY0TmEssBTc8WVfCpPtsr8BpZR49SI03sICR91lLqJqbVgO8GpqRdti9FUY/6ikHUmBSHe3zd4HOJFiGYOM87JfLJZw+liS+wR98xWGcEKEZU3XkW9I4e23ZaoGkHYe7nd/6jg8//x35F8iGjPcyu0X6aFuNEQ== 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=KSh91/9m2wgZezmbKZ2zhZWeFGu81JvllQqfTFAtAAc=; b=iaWtLXlYt0mrZT88gobL+B9sDRODwz+Of0/1AxZG/+GEO3tpXuv4WnLV/S0D1LegqnVEHyv7t4ZBC+TqctG6VwgrJwo/17K9Jfj5rvWnojP9YmbxR7FSvnhkFJ/uBT62D4nM9UuJsfKt01x6uoH0fWUB+CYd3fmi01vYmyrz2NbNumR1YCLP3Gx7nlZBQaruEl2iImpL7BGk7jGTjRw8tEO6X8RbZo981NI7xMFYv+9vR1gUfVz7Pvvx2zD1C/mwcBCMzWcMesi+DgtkOf3agjeXsIX41FxrII8WDmdVOdREh/CMZkkyDyOKxKyerTZ4DpNh7vrt3fYpIRx/62srUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KSh91/9m2wgZezmbKZ2zhZWeFGu81JvllQqfTFAtAAc=; b=G9D39dVwcpq80We4jSrhqUduQ8l1NCMCYAlnxnn62Do50SkoOQkR5qz7Z5LwzDSGuHslca2VLjlX3ZY6s7FqKz9vpwqv6k4zKexaAkKi6zqyP5TL9aSh3ITtdagIZr1Egh4RHL3CJQpl7eMMKzcYexSeQhcKM8ftxTSwCQpumTA= Received: from PAWPR08MB8982.eurprd08.prod.outlook.com (2603:10a6:102:33f::20) by AS1PR08MB7561.eurprd08.prod.outlook.com (2603:10a6:20b:470::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Fri, 14 Apr 2023 15:32:32 +0000 Received: from PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::13be:967d:6e80:432f]) by PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::13be:967d:6e80:432f%9]) with mapi id 15.20.6277.036; Fri, 14 Apr 2023 15:32:31 +0000 From: Wilco Dijkstra To: Cupertino Miranda CC: Adhemerval Zanella Netto , 'GNU C Library' Subject: Re: [PATCH v5 1/1] Created tunable to force small pages on stack allocation. Thread-Topic: [PATCH v5 1/1] Created tunable to force small pages on stack allocation. Thread-Index: AQHZbhxsfEOqL4dfGEK3hU3sOOmz0K8pbEaAgAAXtwCAAShfgIAAEeDZgAAmDgCAAAPg/A== Date: Fri, 14 Apr 2023 15:32:30 +0000 Message-ID: References: <87mt3bda4s.fsf@oracle.com> <7fd2f7b1-73d3-1bc3-cabf-c67d1930cefc@linaro.org> <878reud7nu.fsf@oracle.com> <87y1mubjtr.fsf@oracle.com> In-Reply-To: <87y1mubjtr.fsf@oracle.com> Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-traffictypediagnostic: PAWPR08MB8982:EE_|AS1PR08MB7561:EE_|DBAEUR03FT011:EE_|DU2PR08MB10107:EE_ X-MS-Office365-Filtering-Correlation-Id: 984657e0-c16f-4609-868c-08db3cfd7d47 x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: uszIlZVtVnJNJVtz0nSNYZxo2XzAlpsMcHEp1y0kHqJFz9SNVyYTP4qsqeg0B5YeeTa/1I5YvdfWdAyyZpi4qzxNeJ8FUAIVq6j0JCRoRwxPKX8hVqAWrZJ99CzHgQWwGHUwmCpfoxTBnrfSW7ryHA3OC2ET+Zx+7dEJHtJUueUVxbwxsrZwKkmeid2+s4cx/umAaiEjaGadAMbvdskgYkbNsMlru3xdvm5MIQqTfUsNgrc8er8lfBMsvGb7c34Fm2s8nSXy+LBumkGOrWv9REQixsR42pJVwTGJtLzOZO8Wq5ToToeXt0S+Kfmtlz678zmDAgEeHzqYInKbFvut9QEf4v4T4PFznLIuZMprID5KrI6muM1bF6Hk04yY12LTOIWgr4zUb66VEcJu2kDy0OPQN76XWGPmcjutOjPLuZ6w5wLeB7VluYe9400ZZnyX/2RVlM+5kAvPBslPjzkz+6oAmMHId4vadOl+lh5+nvwpx08Sjn19Hn08KovnTdk6rYnf362wQ/bK2MniA4UJ0nQ3DvynY1Or0xLnGseWtZkW00n5sYmc7XrzKnYdtjFlPziW5vdyU6THy3gyuvTFKBm2ZQe7l8s8kEKmB5ozKZWoKXZEKK2pOp29rKV7OpRV X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAWPR08MB8982.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(396003)(39860400002)(136003)(366004)(451199021)(66946007)(38070700005)(91956017)(76116006)(66446008)(4326008)(64756008)(66556008)(55016003)(66476007)(6506007)(9686003)(26005)(71200400001)(2906002)(83380400001)(7696005)(6916009)(186003)(86362001)(54906003)(52536014)(5660300002)(8936002)(8676002)(122000001)(38100700002)(33656002)(478600001)(41300700001)(316002);DIR:OUT;SFP:1101; Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR08MB7561 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT011.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 2d7638ba-6517-4d83-e4f9-08db3cfd75f1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5T1taIUOgxrMATEEWo4sVb06YciUMMjQyDeZt3iQHsL3TCm2ZCnJh+Yzyp1Y2IM2tnB9F4ZfnzLMIRKm0m/sCGJaBgsMSVj1OZfc7FY+5mEoOfJlvEPNRezUykD65XpDg6PWLUAy7eHUHO8HmNGmcOeVd0AGOdJgnKnsonnFVQd5H7Qigfk6FBOZhWBFMuQoJXcw9KIu9j9TFeYs4ckBAAnZRJH7MPVNGD2xcmYshy3YmF8OuhxiwP9K618va+Bsxgen9wjUE6X8cPjG1Vsf41wMb7TGfadtIdxjcjToBcscx3zHwnqQjjnzvjaS3d1motC6MVgCWSueSNQ20AwnVzVs7YrQZb4cSNt+rYwoOVWuFKM64ctSJxF3LhMy4DB0nrVa81MWzvIjXVQxNu3qYDJX+SvqUdQ13mS/PrfEpHxohQ84e3NnDYYr20Hz6KYQVUvWb3tSMMb7OnWOh/EyBmnCgoAhYNneXv+GXIDTi2o96q3JUNefVb1VHLunPOJjI2G59gcSElVppgyYlwg9f+0Aa/vZbpd0Q0bKct8GgczSWiC76qWrOHWgM3iIg7TUy7pT8xKJhdu3m1rYQbA409Ozi5Frrd67IY2/Ns4AXgTiqSwnaZlbIUlkgUoFDxneg4QXVkv395yAlan8Zp1We5yM0IRgZen60IkdOIoONs+tPFIWs6EJW2SY4SjkCtKTMmJD/oOwnVRv1MIWNkWFuw== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230028)(4636009)(136003)(346002)(376002)(396003)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(36860700001)(40480700001)(82740400003)(9686003)(55016003)(47076005)(336012)(40460700003)(2906002)(6506007)(33656002)(186003)(26005)(82310400005)(81166007)(356005)(8936002)(83380400001)(86362001)(70206006)(70586007)(7696005)(478600001)(5660300002)(6862004)(52536014)(4326008)(316002)(8676002)(54906003)(41300700001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2023 15:32:42.9289 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 984657e0-c16f-4609-868c-08db3cfd7d47 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT011.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR08MB10107 X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,KAM_DMARC_NONE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Cupertino,=0A= =0A= > To contextualize the tunable was proposed to reduce stack memory usage wh= ile=0A= > still having THP enabled in the kernel for all other allocation types.=0A= > We identified a scenario which THP will be initially used for stack=0A= > allocation, but once protection gets set for the guard region, it will=0A= > split the huge page into 4k pages, when the 2M page is already marked=0A= > dirty, not really making use of THP benefits, but bloating RSS as all=0A= > the small pages are assumed as touch.=0A= =0A= So after the guard region is reserved, we lose 2MB of real memory that will= =0A= never be used (as only the top of the stack is used), right?=0A= =0A= The next question is whether the splitting of one huge page causes the whol= e=0A= stack mmap to use small pages too. If so then it never makes sense to use h= uge=0A= pages for the stack if the guard page is smaller than a huge page (since yo= u lose=0A= 2MB of memory and never use huge pages anyway).=0A= =0A= Alternatively, if the rest of the stack can still use huge pages, we actual= ly lose 4MB=0A= of RSS (since the top of the stack is a large page and is obviously used). = As I=0A= explained, huge pages for stack can still make sense for applications that = need=0A= a large amount of stack. For these cases you could just increase the guard = size=0A= to avoid wasting the extra 2MB of memory.=0A= =0A= > I think you are suggesting the oposite, i.e. it would increase RSS.=0A= =0A= Where did I suggest increasing RSS?=0A= =0A= > Also Adhemerval patch intention is not to detect when the THP for stack= =0A= > allocation makes sense, but rather the oposite. It is to detect when THP= =0A= > will not bring any benefit.=0A= =0A= It doesn't matter which way around you do it - it is absolutely trivial eit= her way.=0A= =0A= Cheers,=0A= Wilco=