From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) by sourceware.org (Postfix) with ESMTPS id 2799E3858D1E for ; Mon, 13 Mar 2023 17:15:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2799E3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-176261d7f45so14468492fac.11 for ; Mon, 13 Mar 2023 10:15:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678727715; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=Fx0cbBSJgHrUOdWLfNmiFwUun5Hiya+R7o5WEXk+Vas=; b=MXswfbZtsI7xiVjB/kWqEOyCWBrgilgbIaPrSc2ZA2IZ6P09IgGVtdgMSCuzhuaZP7 SERPKb19OOC6BfQGNAQdl3liKh9l6/uOD1ChsewZxuci8246IYku0K2gBV95x8phTDjB 2XoLyPWrIaMJt7g8nyNptPfQiGH+Xs8PRUL/+7IvE++EGijcvrk4UfHrDBC9u8nEUiRg 2f/7q1oI6JzlUfwKWmHMXz+mon+bwpZRm5L+KM392IGDruwk3G9+7YGPcnEfbwF94AZO NyKZ+YKELdVZDgkS9gK8yMU2HdS+4C5ga1smGZlL57LYtrq6l8IUxAIdg+HlHILPPk52 ypCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678727715; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Fx0cbBSJgHrUOdWLfNmiFwUun5Hiya+R7o5WEXk+Vas=; b=3dQSVAj2oLL9aJIWkew2xQG1jrcOxzEMcT2VnwmD4e0nnbfIgkAbG94w31jQCCfGlA ZzNGqHsn0FjpmR0Sjfgn71wtg7sWhqDyPF2PU/QXcmyqxVRD+LUMfiveOT8aj70d+y9t OtFwfsq5j8tXgS2OawGxL5/apPCW3OOu1WSFeQp/I4dXyutEhIKfUsPbg8fcGWVQz5rK E9LJIw9z2MatPHSAkrnJc6yKAYRm3Tm2TpUSRmG1UY8e75ajNFKDVcyQ1RaT3hxvs//+ 12dCnhMTOzT4I2TtZQNux8o+VYgM8lFYZOsYgjxgnPEyJaR421pnMak/zgyvdIU478L5 b74g== X-Gm-Message-State: AO0yUKVJU5Dg/npN6Y6HHn8RcqTZETTJ4ZOX5Tz+G1XOoosYvUxsi3Jg T9acl+v3d38rmYtL0c5apP00jg== X-Google-Smtp-Source: AK7set/UIDnz7UVj2J06oMnh3tPLKv8tS4OunjgN7qztrTGPqsksnnJYfkMT/RhRwNyoIhnHwQzBug== X-Received: by 2002:a05:6870:6094:b0:176:7d49:b06b with SMTP id t20-20020a056870609400b001767d49b06bmr20797443oae.23.1678727715496; Mon, 13 Mar 2023 10:15:15 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c0:544b:655d:5559:758d:90f7? ([2804:1b3:a7c0:544b:655d:5559:758d:90f7]) by smtp.gmail.com with ESMTPSA id x17-20020a9d7051000000b0068d59d15a93sm189189otj.40.2023.03.13.10.15.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Mar 2023 10:15:14 -0700 (PDT) Message-ID: Date: Mon, 13 Mar 2023 14:15:11 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH] Created tunable to force small pages on stack allocation. Content-Language: en-US To: Cupertino Miranda , Florian Weimer Cc: Cupertino Miranda via Libc-alpha , jose.marchesi@oracle.com, elena.zannoni@oracle.com References: <20230310143558.361825-1-cupertino.miranda@oracle.com> <20230310143558.361825-2-cupertino.miranda@oracle.com> <87edptulvd.fsf@oldenburg.str.redhat.com> <87y1o10xs7.fsf@oracle.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <87y1o10xs7.fsf@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: On 13/03/23 07:07, Cupertino Miranda wrote: > > Hi Florian > >> * Cupertino Miranda via Libc-alpha: >> >>> +static void >>> +TUNABLE_CALLBACK (set_stack_hugetlb) (tunable_val_t *valp) >>> +{ >>> + enum malloc_thp_mode_t thp_mode = __malloc_thp_mode (); >>> + /* >>> + Only allow to change the default of this tunable if the system >>> + does support and has either 'madvise' or 'always' mode. Otherwise >>> + the madvise() call is wasteful. >>> + */ >>> + switch(thp_mode) >>> + { >>> + case malloc_thp_mode_always: >>> + case malloc_thp_mode_madvise: >>> + __nptl_stack_hugetlb = (int32_t) valp->numval; >>> + break; >>> + default: >>> + break; >>> + } >>> +} >> >> I suspect that quite a few failing madvise calls are cheaper than the >> those three system calls in __malloc_thp_mode. In addition, >> __malloc_thp_mode may fail due to future kernel changes, disabling the >> tunable by accident. > Thanks for your review. Ok, I did not check the inner workings of > malloc_thp_mode. I used it by suggestion from the RFC thread. > I will prepare a version removing it. It only make sense to madvise iff __malloc_thp_mode is set as 'always', and tunable is a opt-in feature. So I think it would make sense to check the sysfs is tunable is used; the startup code will be amortized on high threads workloads.