From patchwork Thu Oct 28 22:31:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Patrick McGehearty X-Patchwork-Id: 46766 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 901E33857802 for ; Thu, 28 Oct 2021 22:32:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 901E33857802 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1635460334; bh=wsQiP/brDoUA2DX7cJqy0MoaIYJoibKzarUiBDMgdoU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=VtRuhV4/GooJkcOUz2ZOMaRGqCMGGd2UYgfw6efT7M3dPBwLCq/XxRl6hHxjaaqOX gZzVYu5uPpfmh+NjwDVmOR1TNNHHfx3FurIeddxa5T0YGcwgevuwg0DwBaULkDX8PV /i6XEMU7FGCeVTukqTWS+SaM1HHrpShiAqfG7l9Q= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id E5A2B3858416 for ; Thu, 28 Oct 2021 22:31:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E5A2B3858416 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19SM6Ec3032299 for ; Thu, 28 Oct 2021 22:31:49 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3byedap1mh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 28 Oct 2021 22:31:49 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 19SMM4S0019320 for ; Thu, 28 Oct 2021 22:31:48 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2045.outbound.protection.outlook.com [104.47.66.45]) by userp3030.oracle.com with ESMTP id 3bx4h4vp7e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 28 Oct 2021 22:31:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CNr8JgQP98LXAO8VWHQ81NyiHEgtUFoLRZANj7heLKhLo/aI6di76oT6zMD384qHiSExzKFQuN3kMl82Kl8RJKBi7xvXuSWTumKHeKGXgvWsoNpECwRG2k/PEo/EkpD8cNEsz45S5aMgzVb8ncqb3wmnp6l3bDBrWGNNd1qONYg8iAryPLLeOSA3BUVBHPghKY5YWxnbuNG5nf2l2d1wVXD6CIKPfycy6otm0BjkTdOuuS6hTcjQZsoKo+yK0p55gKc2zjnSKw+lMWr2oocLw8gLa9Wt1cW3hYSBRrc6w/+ADQhpg9aBI3KOvGNlFb+ARjKiA9oaSPu/bDdmEnHtWw== 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=wsQiP/brDoUA2DX7cJqy0MoaIYJoibKzarUiBDMgdoU=; b=ai6QpiVsAD9UMoHsnoFfB2csblBpkCgaVzYU3DS02UTo6YnAAqsZfPqoNalprmRTqp/90x31dPi47sj//m9X5sUY+KbZZtgxbCARkOV9p0pWcMpYXjKHekoMzEMKX4jhny5PU6lOnZtmt9sWZd7b4pskXMjcZK0pj3O9x1nDkwxOk69pxNMgd2UkYBJe3dZwtEy6jtA9zovK0H7hb4TT1/S+iDTpJmpQn5sq93rtd3CiD7I6RPyyaluKVcPUNXd0RJ5QBMpw68tHrZtAZ47QFlR+wqlEh8fvyaOdm91L+SNcZV4lgIkf7t77jtvjtqg4bummFdpEKtRlIdRjt9igjg== 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 Received: from BYAPR10MB3208.namprd10.prod.outlook.com (2603:10b6:a03:159::10) by BY5PR10MB3809.namprd10.prod.outlook.com (2603:10b6:a03:1fe::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14; Thu, 28 Oct 2021 22:31:45 +0000 Received: from BYAPR10MB3208.namprd10.prod.outlook.com ([fe80::cdd5:fa7c:b36d:dfd2]) by BYAPR10MB3208.namprd10.prod.outlook.com ([fe80::cdd5:fa7c:b36d:dfd2%2]) with mapi id 15.20.4649.015; Thu, 28 Oct 2021 22:31:45 +0000 Message-ID: Date: Thu, 28 Oct 2021 17:31:41 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Content-Language: en-US To: GNU C Library Subject: [PATCH] Remove upper limit on tunable MALLOC_MMAP_THRESHOLD X-ClientProxiedBy: SN7PR04CA0171.namprd04.prod.outlook.com (2603:10b6:806:125::26) To BYAPR10MB3208.namprd10.prod.outlook.com (2603:10b6:a03:159::10) MIME-Version: 1.0 Received: from [10.39.208.237] (138.3.201.45) by SN7PR04CA0171.namprd04.prod.outlook.com (2603:10b6:806:125::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14 via Frontend Transport; Thu, 28 Oct 2021 22:31:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eb455c78-a368-4410-667d-08d99a62b8f1 X-MS-TrafficTypeDiagnostic: BY5PR10MB3809: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tR1sR+b5AeNPlv1PEebpXEiFwBnJpjBVEUQS2b6dr0YhAFKxwHCOxq0l3zkNXRNYC+7o4eJ/avBwwexB8nW/zZKwsh1gQ8Te45QqstsnZqXh6NPuOxfjpMaQvGqkrn+eJ/1jhYtS1RQHYyCnfeuKAp34uJrTNY+3yZiQcuFHtXiiOQPHsrTvq8YrBFyk8nbAROuS9eib/q4qQqs7iCF3IOXv2plR+CwS9xLS3DZ/TTLli1oS66slnk+B0uD1niBvKwwDEb8WDQgZy3g+TRsCVh/jcwaoKG7h7M6CGS78x8hZ1qpWaVx0M1j4ht49q5AgQFQVrUzZu8e3WNSvLqAtkpuCNO/2Hd8OWqLfyQlcxCBnsJ5y9YsGhO872CYjg9rBt6/pCN90Umoj1VnU2u6grn5u2t6tHC6+aVlxnLidPXcOFnNfuoD4MRs067RXAJLKYTZlp7h8PzEJxpxM7a66E+SKre7zodmbsPmolvn+IZOs63cLUzg/XvzF6CXNn3At0NPihebHNjXkVDNlGyCBaCBRQWc/sGc9nsXVCCAseiV8Dae14Ml3pXybu1LLFkenwvY/DEvw+MgErk1ES1AqFHZLOsipsmjBkXvAjvK+Ei3wcPmGcEB77aZGa7fIWfZF1PlRbwdN+C1KYGxese4WYPzCYyR7z10M73pq+k5wWszi8wXPs8xveUt5P0W2Q6B6ia7vwO+XvVMaxREMpT0f1fN10zHOF7JAJena220mojdo67GQpZD4gTRbd5WgvEcysvImR8xK0zOg0Owk5kSLfA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3208.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(6916009)(2906002)(52116002)(6486002)(5660300002)(8676002)(508600001)(31696002)(8936002)(83380400001)(66476007)(86362001)(66946007)(186003)(31686004)(16576012)(38100700002)(36756003)(38350700002)(956004)(2616005)(26005)(66556008)(6666004)(316002)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?WYc4C2rz+sJ31V7phZ0NRfCa/Gy9?= =?utf-8?q?9UmmoXu0SPFqzK19iHXGdJtNN0XJyyYMbpYHgDzlc0uqXo2n89LHsTGsIaBJwmOYL?= =?utf-8?q?eZM43q/m1up/2bEiQoXv4dqneGD745pLlCCF+kcHNeM7xGOXJRHDIMvLpPMz1fPyt?= =?utf-8?q?0q2FEvFCyodSZooPByoMk9RhxEZnx/KFqoQGdnodC2KLDOnzxhtBK+bu7bmc5MRw0?= =?utf-8?q?1O+PlxVfw/MC+DQg4nj9Pwhd7tirVrqsBXtctz6M2PfHEjcOrsBRQf+ecfIjBsFKr?= =?utf-8?q?qBHIonaYpeAzQT5pFCQ/g1iJjkc0uMh4aiieRAjhcvKE9akWtoqHhXGgdBa9OveIs?= =?utf-8?q?OcDGFvXHlYTD3azGf/4kdv36C2IJTXDVsVvNwAQYfkmqw1RBg7ImDc4AnSqrnnANg?= =?utf-8?q?SLIWp4jthKneStG2oTBETs28PaDbv6ZqyIKRS9ZYEWNvIvr5SiNBdTzvyZ+93IYPr?= =?utf-8?q?uP4LkbQk/f/7cdSpUeySbHQ7QvH8qLFKOZUPblwNTO3xXUVyhCpZLKWZuo9bGihHO?= =?utf-8?q?MbP8/pJI+JsseD34sL3iInItS5e5hJH7QAOSSTNcuzUa0W4fbt0N6ePhnpu0070VX?= =?utf-8?q?J32VB80qqKyxIysgblYWNfeSnG+RUXEgEg165EeJn7meYC7hvpp/taBvTh/kqvzCq?= =?utf-8?q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JgGEzA5yk+w1DOx2/RvBytQPAcg+fpQY4W9T8v3JtMqLcV43?= =?utf-8?q?qhdIjx2pGT6izn6iIYVhFS1QMhkza1c3A=3D=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb455c78-a368-4410-667d-08d99a62b8f1 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3208.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 22:31:45.2325 (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: WQyRQPZXlFr5f3SDpyQrFIhykD2CcHt4TnnbHoBmxM7JCQBOfAeHaUQDZefWKseH02P37Z1K1j4ps8RVKfnDPs2gV+j5xBVDniDGWTsm1bE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB3809 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10151 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 suspectscore=0 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2110280118 X-Proofpoint-ORIG-GUID: 25n72zfGqgY1xp-Yc__273Me6Vx4RnqA X-Proofpoint-GUID: 25n72zfGqgY1xp-Yc__273Me6Vx4RnqA X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Patrick McGehearty via Libc-alpha From: Patrick McGehearty Reply-To: Patrick McGehearty Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Attempts to set the MALLOC_MMAP_THRESHOLD higher than 1 Mbyte (for 32-bit apps) or 32 Mbytes (for 64-bit apps) are ignored with no warnings issues. These limits are not documented in the manual where malloc tuning is discussed. This value was set by a patch patch dated 2006 (15 years ago). The default behavior is appropriate for many highly parallel applications where many processes or threads are sharing RAM. In other situations where the number of active processes or threads closely matches the number of cores, a much higher limit may be desired by the application designer. By today's standards on personal computers and small servers, 2 Gbytes of RAM per core is commonly available. On larger systems 4 Gbytes or more of RAM is sometimes available. Instead of raising the limit to match current needs, this patch proposed to remove the limit of the tunable, leaving the decision up to the user of a tunable to judge the best value for their needs. No defaults for malloc tunables are changed. The default behavior of malloc including the code to make dynamic changes to the mmap threshold is unchanged. Therefore there will be no performance impact of this change for those who accept the default behavior. Only advanced users will be considering changing the limits. They might be expected to only change these limits after profiling shows that frequent mmap calls from malloc are a performance issue. They will set the threshold according to the needs of their application and will get the currently documented behavior instead of malloc quietly ignoring their request when it was over the hidden threshold. One might ask if there is a risk in allowing an extremely large threshold, even larger than all available memory. If the user were to use an 'extremely large' value for the mmap threshold, the effect will be the same as when the user uses tunables to totally disable the use of mmap. As that is currently allowed, no additional harm is done if the user finds an alternate way to get the same behavior. The limitations of the current threshold was discovered by an advanced researcher who was investigating setting the mmap threshold larger than 32MBytes. By removing the limit, we free the user to experiment with large values that might be appropriate for future systems that have extremely large memory per core by today's standards. modified: malloc/malloc.c ---  malloc/malloc.c | 15 +++++----------  1 file changed, 5 insertions(+), 10 deletions(-)  static __always_inline int diff --git a/malloc/malloc.c b/malloc/malloc.c index 2ba1fee..ce355e5 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -5223,16 +5223,11 @@ do_set_top_pad (size_t value)  static __always_inline int  do_set_mmap_threshold (size_t value)  { -  /* Forbid setting the threshold too high.  */ -  if (value <= HEAP_MAX_SIZE / 2) -    { -      LIBC_PROBE (memory_mallopt_mmap_threshold, 3, value, mp_.mmap_threshold, -          mp_.no_dyn_threshold); -      mp_.mmap_threshold = value; -      mp_.no_dyn_threshold = 1; -      return 1; -    } -  return 0; +  LIBC_PROBE (memory_mallopt_mmap_threshold, 3, value, mp_.mmap_threshold, +          mp_.no_dyn_threshold); +  mp_.mmap_threshold = value; +  mp_.no_dyn_threshold = 1; +  return 1;  }