From patchwork Tue May 9 03:10:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 68932 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 A37773858004 for ; Tue, 9 May 2023 03:10:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A37773858004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1683601850; bh=2LZzUvbU1721/LaeBBD3tzLgXri+A7JnEmaEQ1W0abw=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=VsDUjEajg/v3IIE//YdWfpjvpvzCyMBreQLAT+2YwwUWgF3OvTHXxEaBsigN71mZq nTe9TiWjpiAV112UGiOX37UVjfCwLY2LroFcmJOYqx0QIu5hZJHa+Znz2P5tUCuOec 9TTPswUgaxwpW/JytqWAefxlVQO6mM1KGOFt3Lgw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id C76143858C50 for ; Tue, 9 May 2023 03:10:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C76143858C50 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1aaed87d8bdso37464915ad.3 for ; Mon, 08 May 2023 20:10:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683601826; x=1686193826; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2LZzUvbU1721/LaeBBD3tzLgXri+A7JnEmaEQ1W0abw=; b=dEFt98IlqmbshHPyKRONLORSg2obHAXUmWQx/kO6jTYJbjIGIXoFUt8y8YlLeoqX5C KODzrluSjYrjQwQi4FhZm7zDd1POT3LvGtLUg9uKXSobL0djTUIA2hvCqF121r//PDc4 w15hhKPLzkQe6LWCa18lx/WwvE13/yllK5EoIThpRshnKpPIHwR2xLMhmT8we33WKyIr dhxJJgziPS2CfFVvYZEtOu1O4ePRtQ/La7om57N5OMb/5LQlKvVqgkiTwFzUIvmNJbYi R9EII+niaut3Ppe7R0dW3t/iU0BVAOEh4S1JOiJJ5/P6dVI4SWT2HCbulhdHpTwXS/c7 VE5A== X-Gm-Message-State: AC+VfDzQvRD2JKVpKpC7M52eG8slwCIS+rMpMYT1mxvCbROk0fjxfIwM 92uGLxtBigucaItkIinA4ndTzNYjFeI= X-Google-Smtp-Source: ACHHUZ5qI8KQhbeIUUjccBRn9by7Ed7QsYpsFCoYhl+0o0aFwDRfhIbttb9EiLRnXwGb5poTFPfpjQ== X-Received: by 2002:a17:902:db04:b0:1ac:8dae:d842 with SMTP id m4-20020a170902db0400b001ac8daed842mr3006537plx.46.1683601826333; Mon, 08 May 2023 20:10:26 -0700 (PDT) Received: from noahgold-desk.. ([192.55.60.44]) by smtp.gmail.com with ESMTPSA id l6-20020a170902d34600b001ac7ab3e97csm214659plk.260.2023.05.08.20.10.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 May 2023 20:10:25 -0700 (PDT) To: libc-alpha@sourceware.org Cc: goldstein.w.n@gmail.com, hjl.tools@gmail.com, carlos@systemhalted.org Subject: [PATCH v1] x86: Use 64MB as nt-store threshold if no cacheinfo [BZ #30429] Date: Mon, 8 May 2023 22:10:20 -0500 Message-Id: <20230509031020.3496291-1-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Noah Goldstein via Libc-alpha From: Noah Goldstein Reply-To: Noah Goldstein Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" If `non_temporal_threshold` is below `minimum_non_temporal_threshold`, it almost certainly means we failed to read the systems cache info. In this case, rather than defaulting the minimum correct value, we should default to a value that gets at least reasonable performance. 64MB is chosen conservatively to be at the very high end. This should never cause non-temporal stores when, if we had read cache info, we wouldn't have otherwise. Reviewed-by: Florian Weimer --- sysdeps/x86/dl-cacheinfo.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h index 864b00a521..6225c852f6 100644 --- a/sysdeps/x86/dl-cacheinfo.h +++ b/sysdeps/x86/dl-cacheinfo.h @@ -771,8 +771,16 @@ dl_init_cacheinfo (struct cpu_features *cpu_features) reflected in the manual. */ unsigned long int maximum_non_temporal_threshold = SIZE_MAX >> 4; unsigned long int minimum_non_temporal_threshold = 0x4040; + + /* If `non_temporal_threshold` less than `minimum_non_temporal_threshold` + it most likely means we failed to detect the cache info. We don't want + to default to `minimum_non_temporal_threshold` as such a small value, + while correct, has bad performance. We default to 64MB as reasonable + default bound. 64MB is likely conservative in that most/all systems would + choose a lower value so it should never forcing non-temporal stores when + they otherwise wouldn't be used. */ if (non_temporal_threshold < minimum_non_temporal_threshold) - non_temporal_threshold = minimum_non_temporal_threshold; + non_temporal_threshold = 64 * 1024 * 1024; else if (non_temporal_threshold > maximum_non_temporal_threshold) non_temporal_threshold = maximum_non_temporal_threshold;