From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7844) id C7ADC3858288; Mon, 28 Aug 2023 20:02:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C7ADC3858288 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1693252968; bh=rTzzU2kx3d4e/W8sEGU7gbMAgU479ACt/7ocEOI/2aU=; h=From:To:Subject:Date:From; b=vbeio1iwrWgtfHEEsiTj7CWwBMWuwDU18L8JT4iHAbE7ZrXVRIj1WxD7HTQ0zwR46 X/igXkWR904APeGPoUk8eIsG3HNt7uG5ItfYJq6OX7viLu0XdKUDUjwThV+9hfkKK4 8JlvkuPA7rw6385Y7OWJv5l/Jb4b9S8TXjt7mU1s= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Noah Goldstein To: glibc-cvs@sourceware.org Subject: [glibc/release/2.37/master] x86: Fix slight bug in `shared_per_thread` cache size calculation. X-Act-Checkin: glibc X-Git-Author: Noah Goldstein X-Git-Refname: refs/heads/release/2.37/master X-Git-Oldrev: 1caf9552699a79573e4202a592b3e819e63bc020 X-Git-Newrev: 80a8c858a59e963f546a23a745f505ff9b6b1699 Message-Id: <20230828200248.C7ADC3858288@sourceware.org> Date: Mon, 28 Aug 2023 20:02:48 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=80a8c858a59e963f546a23a745f505ff9b6b1699 commit 80a8c858a59e963f546a23a745f505ff9b6b1699 Author: Noah Goldstein Date: Mon Jul 17 23:14:33 2023 -0500 x86: Fix slight bug in `shared_per_thread` cache size calculation. 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`. Reviewed-by: DJ Delorie (cherry picked from commit 47f747217811db35854ea06741be3685e8bbd44d) Diff: --- 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 d7a501ad9a..f5b04f489e 100644 --- a/sysdeps/x86/dl-cacheinfo.h +++ b/sysdeps/x86/dl-cacheinfo.h @@ -615,8 +615,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; }