From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2063.outbound.protection.outlook.com [40.107.104.63]) by sourceware.org (Postfix) with ESMTPS id 15CA03858D35 for ; Tue, 23 May 2023 09:48:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 15CA03858D35 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=NOJiF7NyBtg/MQ5hvK+bmH1u0VOInjLfXGifFd4bTy0=; b=t20W5bQhpVtBpsXMahE2cPXhutpuWcR+lPRRinMg3sIu+S+n214Lse/kHztlnjBnooVnc2a61oqhQyYOA3ss5IN+kOp+BcFd6siHqxxQkIgrg+jc3g4QZXS/xErfmzZHWjgn/TTf4CFMh+/7ynBMPKp+mJUuVbkP647qCwOBhBs= Received: from AM3PR07CA0067.eurprd07.prod.outlook.com (2603:10a6:207:4::25) by DU0PR08MB8977.eurprd08.prod.outlook.com (2603:10a6:10:465::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 09:48:18 +0000 Received: from AM7EUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:207:4:cafe::b) by AM3PR07CA0067.outlook.office365.com (2603:10a6:207:4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.14 via Frontend Transport; Tue, 23 May 2023 09:48:18 +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 AM7EUR03FT029.mail.protection.outlook.com (100.127.140.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.14 via Frontend Transport; Tue, 23 May 2023 09:48:18 +0000 Received: ("Tessian outbound 3570909035da:v136"); Tue, 23 May 2023 09:48:18 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 176e187a733975ed X-CR-MTA-TID: 64aa7808 Received: from 30f71e74a236.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6488CC3B-900B-4FA4-BD94-3BE57B91B23C.1; Tue, 23 May 2023 09:48:12 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 30f71e74a236.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 23 May 2023 09:48:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kH7Rar/32dk9ZifwA5DFaYJ+uFjd3J600hW3Vpcr7sBEs5pJjanWs0zyOa84+xjcTsNivjoICE7F3tar8gK8pu/Oh+mimXPEzoMFWczfY1JgnyviM5lbKJERx6MpEJE9HoRk8l3o9JK6M74yvwtW0/kxB+P6NrDfQJ8ZmogRQgJJEbDH40eO+OtpWraL29rz/Vf/04Mk+SipZB18mUA87+j7W/s2/paYguWazVPGw/ci9xE+QkttCkU5s70MzjUmCKUh6S3o4vXKa03N/T3e8AmCzbVfJO8o0OkHbBdK9ezYcUT1QYErs7JRtrC8tsN9pCmTuwYfU2GuLbwQ1xJ9zg== 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=NOJiF7NyBtg/MQ5hvK+bmH1u0VOInjLfXGifFd4bTy0=; b=EPjQah40M8ODlyotUsNT7RJnIuLZbvO7aK6k1xPiNDf0+vyraZMK6CafR/TBGldCCZ+vzTwXn4yoaT9G+XWCBAmOqJTdgpp/lGpOHcTMZHIGr7yinGU5Z3BX9pueFa92UG9OmKvfJbqkr49OKvn4nMu8zBjMafHy5d+oaEZQIDckgJ85zgYZ5N5Q19glsbM7105oFb24jVc5KSm/yQh/sOxNOrxpN2jEZ2s5w33MshgBzqo1nZ1rVWbXI1Au9j6eziPS8HpYHeX/n0CCaK39cxCwvx2NC0T4NR5vW1Csk9LIspRF3wzJAb32tS+V13SFnngu05heZ9NmiOHOBdP30w== 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=NOJiF7NyBtg/MQ5hvK+bmH1u0VOInjLfXGifFd4bTy0=; b=t20W5bQhpVtBpsXMahE2cPXhutpuWcR+lPRRinMg3sIu+S+n214Lse/kHztlnjBnooVnc2a61oqhQyYOA3ss5IN+kOp+BcFd6siHqxxQkIgrg+jc3g4QZXS/xErfmzZHWjgn/TTf4CFMh+/7ynBMPKp+mJUuVbkP647qCwOBhBs= Received: from PAWPR08MB8982.eurprd08.prod.outlook.com (2603:10a6:102:33f::20) by AS2PR08MB9269.eurprd08.prod.outlook.com (2603:10a6:20b:59e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Tue, 23 May 2023 09:48:10 +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.6411.028; Tue, 23 May 2023 09:48:09 +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+AAAokAIAACg08gAAwkoCAABOVEYABP4QAgAaA5FE= Date: Tue, 23 May 2023 09:48:09 +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: 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_|AS2PR08MB9269:EE_|AM7EUR03FT029:EE_|DU0PR08MB8977:EE_ X-MS-Office365-Filtering-Correlation-Id: e289c7a4-a7a6-43a0-f920-08db5b72d691 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: GgReo111YabJlO9fIInVFd9enWOFD9Try12pq0Ub4z5jAaLGcSgrYPnsAXbLthz+8u/nR/lC57NG5VI1HGIAbQ7tWzYlRhRY+pM4i7K/LlhblrLipLvc89WnCCUv5NlC4+JH4yO8/YxPG9sKXRa1QYnE7lUuL/wfeoEfZmsZKPJBYVJne4IP432v3MU+pQDTDPF3mURr0SwI1M0OkYNmo3s1N9YaS3L0skssOh3biXcwYda3DETpR+TOJxj8hzrAt9mwZUfku+krAZxI7qm/Xyyp4vlKBBWKA+kGVDq0LAAFEaruNqj821d6dZkJiMq7nOgFSgDBymM3xRaRudRPZUJKUArC/6I2LIA9HNnMI9WjHjoZKCNWBGCx529EWZbKNEYyg73rXOexAg8KoeUMxAgUWxzTR5R1cPSKLkE0sKccqj8WuK7ifIt5IakqpkJW3HFvhtxmuOwngs8w5iCOMKnkCalvhLikc4I7etKEJMro1gCPcN7ufygGWSnF+9IQqddV5ooIaQKwwYIfrz+Jlni5hBsa7NzW0q3jtvasDgoGTjkkLDkNqQkP4JkEX43h9JkV/RryVNxPsVNjo2K4FZ1T8lVvt9odDc7Bq2MvJpWaPqk46S1qVEF6q5NeiDPA 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)(376002)(346002)(366004)(39860400002)(396003)(136003)(451199021)(122000001)(38100700002)(8676002)(8936002)(38070700005)(5660300002)(52536014)(9686003)(6506007)(55016003)(26005)(186003)(2906002)(83380400001)(33656002)(86362001)(110136005)(316002)(71200400001)(66446008)(66476007)(64756008)(66556008)(66946007)(91956017)(76116006)(478600001)(41300700001)(7696005);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: AS2PR08MB9269 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: AM7EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 4b69cc64-a033-4a74-7bf3-08db5b72d136 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tZZAiZdUezrapNwj+RHGG6m76e8gIsympKcGeXkRSiQ+YIN2/GN4yNxPVW/PoPbshwqWJYiItGcpuaGURVyZfEjOp4gc8BDm7N/xKJ8lDGT9WKpPkM6hcFIsYUDio6GjhU62KjTxdOLqUQni+dpihtPbNqSszHznahVEo+QukZJo8zziFPf1DhvGoBJ63AfvndL939JNAEcpqKVU7NUtjvpH/Ony/Ca1mYrkqgFDqCj5VUlktK+8D8J8Uw8nkP5fggKwhcSEuvWUg/WWsRvXfOtpo7/h8k0iwN6okMP/S5B/OlspiCM5YBN5sKSvfVCavL8Dg4WXdadRuSm8F43LwFIeMQ1/HPF9mfeuWGtoA2+vShXPwBT5a4ytOL0aCKYG0DFpKRsxMhaPkH7eJTTHokgfTj+jomvMdlnbSu2mYlZmANYLbzONUV57R1hT6DdtwpQREF5/NZJ7SwaQ5yA+xdJJA+Wmyd5sUC0SgEx0OlGdDan81Z9zX8H9HhedKAGQ7nG/lQLoYJQwo85OmujSTaSc4Nn7HyVZDb6pK1KmOiqjX2NhYRmIi5L0sKPsW4YUYDiXAaXd1NShszwGgh2iXfYuXr1DYJTYP+g0pOOZ1Sg+zHCiEQcKsseIcMiyZsicwFDshtsMkdxR1wolKDSyFAb/Bmeeip5XBgCz6nTDJuCL0bZB8b8+gib3H2J2wWegK/KVBbeVKrxVmbBGpTCKFaZ+rA2bSS8PcSXekXbcMa/naAffLDQH8+HjB+zWXmDG 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)(39860400002)(346002)(136003)(396003)(376002)(451199021)(36840700001)(46966006)(40470700004)(316002)(70206006)(70586007)(336012)(478600001)(82310400005)(110136005)(8676002)(8936002)(7696005)(86362001)(41300700001)(52536014)(5660300002)(26005)(6506007)(36860700001)(82740400003)(83380400001)(33656002)(81166007)(356005)(47076005)(9686003)(55016003)(186003)(40460700003)(2906002)(40480700001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 09:48:18.6566 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e289c7a4-a7a6-43a0-f920-08db5b72d691 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: AM7EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8977 X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,KAM_DMARC_NONE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,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= > Right, I was using the wrong assumption then on how THP acts (mostly due = the=0A= > two threads discussion).=A0 Running more tests I see your point and it se= ems=0A= > what is happening in fact.=A0 I will drop this patch since it really does= not=0A= > make much sense.=0A= >=0A= > So, do you think adding a pthread extension to control it would be a impr= ovement=0A= > or maybe work towards a heuristic to check if THP would be indeed valuabl= e would=0A= > be better?=0A= =0A= Adding something to pthread to make it more configurable seems reasonable, = but=0A= like with tunables, I bet most applications won't ever use this. So adding = heuristics=0A= that work well for most applications would be best.=0A= =0A= It seems Linux doesn't support aligning large mmaps, and as a result the co= de in=0A= alloc_new_heap looks very messy and complex. We'd need something similar to= =0A= ensure deterministic alignment of the top of the stack for the cases where = we=0A= decide to use huge pages. We could reserve a number of default pages for th= e=0A= initial stack so you avoid increasing RSS size if you use a small amount of= stack.=0A= =0A= However even switching off THP for all small stacks (eg. default size or sm= aller)=0A= would avoid the random use of THP without needing to set the tunable.=0A= =0A= Cheers,=0A= Wilco=