From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2082.outbound.protection.outlook.com [40.107.14.82]) by sourceware.org (Postfix) with ESMTPS id D2A9A3858D1E for ; Wed, 17 May 2023 14:22:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D2A9A3858D1E 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=fm6nRswBlH1hUJqeV3bY8AIOeluePiYpeW6i0IwnP/I=; b=dzd3S5iyhAMP4lspr6cmfq0NS40PFlLu0D/Ix4z3trOSKaZK7P6ONqUn6FctLGrVHgJLGcwKIkBa76UtkW1KXtPbOczxir1Dvkke4Bqx4ay8hiQfwd5+KxcPNs1fX4W0WCknWWjLYjxm1BT7anOe+Z19YqpqpYapUrdb9orTT30= Received: from AM0PR10CA0027.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::37) by DB3PR08MB8915.eurprd08.prod.outlook.com (2603:10a6:10:43d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Wed, 17 May 2023 14:22:45 +0000 Received: from AM7EUR03FT008.eop-EUR03.prod.protection.outlook.com (2603:10a6:208:17c:cafe::42) by AM0PR10CA0027.outlook.office365.com (2603:10a6:208:17c::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17 via Frontend Transport; Wed, 17 May 2023 14:22:45 +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 AM7EUR03FT008.mail.protection.outlook.com (100.127.141.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17 via Frontend Transport; Wed, 17 May 2023 14:22:45 +0000 Received: ("Tessian outbound 3a01b65b5aad:v136"); Wed, 17 May 2023 14:22:45 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: edadd6b588c33b2d X-CR-MTA-TID: 64aa7808 Received: from e8f65585947a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1104B374-14AD-4F3F-BF3F-B3BA2A778976.1; Wed, 17 May 2023 14:22:38 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e8f65585947a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 17 May 2023 14:22:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=grlLEV75POHIyBgtA/GOY/pmG9MRw2RLynS0WCiJrpC9Fwnpsib8eJki4VcC8pFtRTb0l7gfCbORrij6KaAHy3S/9kwhnrsG5mNMmY6wRHHKxtXTWlzpdPaUuMl+lp7id46Y6m1qn2QKRurT0DzPb52+6NyUdKw9cE3eTYKvW0on6arbvkgi9/JE3JsG6nJk4f2X2o7R8BOPyLW+mL+6DO8eJRlknT+OM04aezqaY/Ue529ZbJzpNwv+JH7hiIR0PK3ARerDzeZgUbtzKOgS30DD+Ij4d4KXBEgQxbeuVCt36ksoCM+VitXuJY1ew0mw1O1m2A22av3uywqWBy//tw== 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=fm6nRswBlH1hUJqeV3bY8AIOeluePiYpeW6i0IwnP/I=; b=Ha5q55CUga5UVIY8gDALwWNGQp61hoLjyhcsvVqf+Ty4Ln2jacfoFxE0toA2Pqd5li4yF5Eez66F+PJuSN3wNI09ncaDQrNs6c8oK5QF4xBtDD1TB1giglb45DPge5ZZoOe21bq+RUU77ikyG3BdGxrOWkpKLr/gnusM8auaxiyvA7jaWIH2+CR+RiJlBvaa5G00kMEhGIpiIrTA6Z4LWbjO3nDLhP13ttGBT6n27E6EJx7wppJIZnRopLEtUkUHTc8EWXkX31BQSvsa/TkOVexaCr32W+5mpTIvGw4iMGnoN3UFpiCpaCp3HdHyJGFRkvB8V8tuy6EKv4BhF1byTg== 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=fm6nRswBlH1hUJqeV3bY8AIOeluePiYpeW6i0IwnP/I=; b=dzd3S5iyhAMP4lspr6cmfq0NS40PFlLu0D/Ix4z3trOSKaZK7P6ONqUn6FctLGrVHgJLGcwKIkBa76UtkW1KXtPbOczxir1Dvkke4Bqx4ay8hiQfwd5+KxcPNs1fX4W0WCknWWjLYjxm1BT7anOe+Z19YqpqpYapUrdb9orTT30= Received: from PAWPR08MB8982.eurprd08.prod.outlook.com (2603:10a6:102:33f::20) by PAXPR08MB7367.eurprd08.prod.outlook.com (2603:10a6:102:229::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.34; Wed, 17 May 2023 14:22:35 +0000 Received: from PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::13be:967d:6e80:432f]) by PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::13be:967d:6e80:432f%5]) with mapi id 15.20.6387.030; Wed, 17 May 2023 14:22:35 +0000 From: Wilco Dijkstra To: Adhemerval Zanella Netto , "libc-alpha@sourceware.org" , Cupertino Miranda Subject: Re: [PATCH] nptl: Disable THP on thread stack if it incurs in large RSS usage Thread-Topic: [PATCH] nptl: Disable THP on thread stack if it incurs in large RSS usage Thread-Index: AQHZc60G15loQEfRP0Ssp6oo6IG39K9IhkbigBM/uICAAWQLPoAAF2IAgAFR3n+AAAokAIAACg08 Date: Wed, 17 May 2023 14:22:35 +0000 Message-ID: References: <20230420172436.2013698-1-adhemerval.zanella@linaro.org> <4115d7fd-d7a7-cdb1-3833-daf45186480f@linaro.org> <967b94b4-d819-278f-1782-6b758d0841b6@linaro.org> In-Reply-To: <967b94b4-d819-278f-1782-6b758d0841b6@linaro.org> 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_|PAXPR08MB7367:EE_|AM7EUR03FT008:EE_|DB3PR08MB8915:EE_ X-MS-Office365-Filtering-Correlation-Id: ec3ec3b5-7e1f-4a53-1994-08db56e22f0a 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: eP90Wj7byMiH+5X8E6PiisYyz2d3cpaGZ0Kv/4zlsryfE15KyGxfQFS6UqTeemYSYDLwbJrKLYkpo3/dnPAwxVhRip8Bj3ckCYujABKDkFTRBy8tIKh+a6/aT8VbSe6YPH/56LVXy14vgZePKQ2+JPqw4JyiAnura/wLW+NcAs/GWT484Hm4rjjWKYn15rsn0zxJjtsUKGIOqWckkjZOnwrqzAtQG8PyWotUCty0VdC9wotiFjUmYCmN03v8phvXhdU/ibxfzvqqyNSN+FtbDoe8ShmvBz2wW94zgxi/B/QcNgmBiGVJxblXFogYYJSdQ0SquKhvhuFg6IOv9qhx6EfznyDLI/HLlnOsP36l7TfFMNgcZx6e7ZvBwPa25OQd879t9bN2r1pCTiuv0LsX3uycvBqiNPTA/Om3futz5EgB6WWXes/D0WYJCL7UAaLx1ugLcqpNlVfn+PUZKBG4aG7nEnacvKePGLWWAWjjE/xEqjnAzwuuIf8vboJmBXn/Be73sqdmbym/4PA1yT+l6eO/2s6n8Q9xVuOAWzGk3WndsZKsywn+bdFD//EnQcB7JJTWsYQEaPsoFZpv+GJiXlsA6SF1yXMSiWAILMh3kMkkXhz/hUqm5RA7zEtzw244 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)(366004)(346002)(136003)(376002)(39860400002)(396003)(451199021)(8936002)(8676002)(83380400001)(52536014)(5660300002)(6506007)(9686003)(186003)(26005)(86362001)(38100700002)(38070700005)(122000001)(66946007)(478600001)(71200400001)(33656002)(55016003)(41300700001)(76116006)(7696005)(91956017)(66476007)(66446008)(66556008)(64756008)(316002)(110136005)(2906002);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: PAXPR08MB7367 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: AM7EUR03FT008.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: f796af6a-a1f2-47b2-52ae-08db56e228f2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NKtC9BVriEfsf0JPq0/aXWhSARjNQkty2eZfU8qXTqSopbNPzGfQZwCRFJudaG9FLUBf8RQg3STyoR0Qsdij7dnStllmN+CBVl1uRPVo+QCY2wHyT61lVR+Q2iirVTgnt0QbeCCDV6Y7VPrON50arck5NrHEQM5c2NvjYpdzucWFLiuTd/HSwa9hENJHxZ574ivT2/+WpKjroQaBgvkNw04DzSYbCCvQuh91YDvXf9ZfD4aYxlphGZQRZDKlPdqkDrfZ4C0tm3npSwi8XCWcRy9eXw3gf2vwZMEAkyq/6IFgIc+5qIQt+ktRGLi/tIhNrncMZ7ws8rnHMuuALxCkpWRQjUv9iFhzaigXLaj1we92C7myGyq1SD6Kc40vGCcbSzqrEN40JHYjlj1xr5Old7Rnzwb8kgpBnMvS7dH1l0QxE9oQMMu0G13Nb6ApdCqJOT0ldD0SF6TrPTc+LPITRU0ABLKIopNKGwDgJBOcPdJ2tzKKi1Z7lG+rsPptXf6kzCJhY2LldpdpOUi7diJ+mCtgOg32gBZqJnvQI1Qctom7IIGrMI3UxD4Fa9keB3JUvLgpDdz8hyfPlAAO1sSG23xPicFFHnUTJsdC3meEZTNdvDIIKFdHePukit/ASCg9TgbxfUCq2FPFrhmmok30KqVdgRYMeWhK/bQwtn/RYPDBnYFVNqHfZbCpp3yDyb2eW0dwRjYlZsBkYPqgF/SFhxR77l50E53vGw7OxiW/unOrcp8BvRn62oXHCWjt4c30 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)(346002)(136003)(396003)(376002)(39860400002)(451199021)(40470700004)(46966006)(36840700001)(40460700003)(316002)(70586007)(70206006)(478600001)(110136005)(33656002)(86362001)(7696005)(47076005)(83380400001)(6506007)(26005)(336012)(36860700001)(186003)(9686003)(52536014)(41300700001)(8936002)(8676002)(5660300002)(2906002)(40480700001)(55016003)(82310400005)(81166007)(82740400003)(356005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 14:22:45.4220 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec3ec3b5-7e1f-4a53-1994-08db56e22f0a 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: AM7EUR03FT008.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR08MB8915 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 Adhemerval,=0A= =0A= > AFAIU the issue is after the stack is allocated with huge pages, the=0A= > kernel needs to fallback to standard pages because the guard 'page'=0A= > will be also within the same huge page allocated for the stack.=A0 =0A= =0A= The stack allocation explicitly never overlaps with the guard page, ie. the= re=0A= is no such fallback. All that matters is the mapped address range of the=0A= stack - if this fits huge pages, you'll get them.=0A= =0A= > My understanding is, once kernel needs to fallback to use default pages, = =0A= > it allocates *all* the large page range.=A0 This is what the RSS increase= =0A= > make me believe, I am not sure if there is technical limitation to just = =0A= > making the range COW (since at the time of guard protection setup, no=0A= > the page has not been touched yet).=0A= =0A= That's not what happens. The RSS size increases because you actually get=0A= a huge page (as requested). There is no fallback to standard pages.=0A= =0A= >> So the real question is when do huge pages make sense for stacks?=0A= >=0A= > But that's not what the patch is trying to do, it only tries tot mitigate= =0A= > a specific corner case where THP will be ineffective.=A0 I agree with=0A= =0A= So far there is no evidence this corner case exists, but even ignoring that= ,=0A= the expression used is incorrect.=0A= =0A= > Cupertino that this question is really hard to answer and it will be=0A= > really depended of the workload and/or runtime characteristics that we wi= ll=0A= > need to plug in kernel feedback to have some answer.=0A= =0A= It should be feasible to run benchmarks to get an idea whether huge stack p= ages=0A= help or not. And similarly whether the RSS increase is worth it or not.=0A= =0A= Cheers,=0A= Wilco=