From patchwork Tue Jul 18 04:14:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 1808973 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=pzRUsmu0; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R4lwM0cbPz20Bh for ; Tue, 18 Jul 2023 14:14:59 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C0380385842C for ; Tue, 18 Jul 2023 04:14:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C0380385842C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1689653696; bh=yHwvUgVKfkjXCzh9cesNWTZRXzAosHQjPE6c6/TdqvA=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=pzRUsmu0WjXfUpdc2PpxSplIPuEafeA0u2NVqms99qcbiFWsIVCko6u4MKgiNTkhi tHN0f4d7mahCxaDGB1ULLF6C0fKw46UBjT0ZPe/S0KgyvU8UzSyN0PXdBWR9rrdGJ0 s6KgFlRL+Saz235BHU22fpqA3y4JF6BEerbpJCYc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id 679853858D20 for ; Tue, 18 Jul 2023 04:14:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 679853858D20 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1b9c5e07c1bso41487395ad.2 for ; Mon, 17 Jul 2023 21:14:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689653680; x=1692245680; 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=yHwvUgVKfkjXCzh9cesNWTZRXzAosHQjPE6c6/TdqvA=; b=AxEj+WomIa17HZntJV2DGHz1xapywwI3rVUTXRXeRCT1xjO7XEQqnPAl6lNmNF2hpV 6JOsZZ6wxuu9AUBiZcSZXBwQWZvvs6ufWDPkbKEc/L+c/kcqRQ5gzP7rVX6Iwp6FmSR8 ybVkMjXb0MpPwzuNmmXLoadBes9m2UqSzTXB6LD3lzPot8goblbOzUSxh62d0pJodAQX qBEYcB/hF7OlSAot6/SY84N8Pt/gQtx5txoVGJ4WhfkzmW9RfURJB25YPtydE1A368kQ nk/CEPExttUmIVCWu5BSf6BL9JlkdFPpuxKrVe4JIg4zAcquQ3xGyZJ+dUNacCylFykK pB2g== X-Gm-Message-State: ABy/qLZieIhXU6+WqzN2zxO7sBnmstD0FgdQ5eyAOZ0IyNM1Y3wZq+Om gDfUJSiLTdtyhijjJpaP3rua2XySCiRJ7g== X-Google-Smtp-Source: APBJJlGtw1KsgrVAFZFaEDI7EttJef8ZT1WqhyI6zpiA3ezYR5Qilc02lJO8GY5yHYxV6ZH3rnf4qA== X-Received: by 2002:a17:902:7893:b0:1b8:76fc:5bf6 with SMTP id q19-20020a170902789300b001b876fc5bf6mr12046078pll.43.1689653679938; Mon, 17 Jul 2023 21:14:39 -0700 (PDT) Received: from noahgold-DESK.. ([192.55.60.41]) by smtp.gmail.com with ESMTPSA id d3-20020a170902c18300b001b830d8bc40sm678572pld.74.2023.07.17.21.14.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 21:14:39 -0700 (PDT) To: libc-alpha@sourceware.org Cc: goldstein.w.n@gmail.com, hjl.tools@gmail.com, carlos@systemhalted.org Subject: [PATCH v1] x86: Fix slight bug in `shared_per_thread` cache size calculation. Date: Mon, 17 Jul 2023 23:14:33 -0500 Message-Id: <20230718041433.217111-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+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" After: ``` commit af992e7abdc9049714da76cae1e5e18bc4838fb8 Author: Noah Goldstein Date: Wed Jun 7 13:18:01 2023 -0500 x86: Increase `non_temporal_threshold` to roughly `sizeof_L3 / 4` ``` Split `shared` (cumulative cache size) from `shared_per_thread` (cache size per socket), the `shared_per_thread` *can* be slightly off from the previous calculation. Previously we added `core` even if `threads_l2` was invalid, and only used `threads_l2` to divide `core` if it was present. The changed version only included `core` if `threads_l2` was valid. This change restores the old behavior if `threads_l2` is invalid by adding the entire value of `core`. --- sysdeps/x86/dl-cacheinfo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h index c98fa57a7b..43be2c1229 100644 --- a/sysdeps/x86/dl-cacheinfo.h +++ b/sysdeps/x86/dl-cacheinfo.h @@ -614,8 +614,8 @@ get_common_cache_info (long int *shared_ptr, long int * shared_per_thread_ptr, u /* Account for non-inclusive L2 and L3 caches. */ if (!inclusive_cache) { - if (threads_l2 > 0) - shared_per_thread += core / threads_l2; + long int core_per_thread = threads_l2 > 0 ? (core / threads_l2) : core; + shared_per_thread += core_per_thread; shared += core; }