public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Noah Goldstein <nwg@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc/release/2.31/master] x86: Fix slight bug in `shared_per_thread` cache size calculation.
Date: Tue, 12 Sep 2023 03:48:10 +0000 (GMT)	[thread overview]
Message-ID: <20230912034810.DC0FF385841F@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=047968e81d03836253beef81f376abe0a82e6857

commit 047968e81d03836253beef81f376abe0a82e6857
Author: Noah Goldstein <goldstein.w.n@gmail.com>
Date:   Fri Aug 11 18:48:18 2023 -0500

    x86: Fix slight bug in `shared_per_thread` cache size calculation.
    
    After:
    ```
        commit af992e7abdc9049714da76cae1e5e18bc4838fb8
        Author: Noah Goldstein <goldstein.w.n@gmail.com>
        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 <dj@redhat.com>
    
    (cherry picked from commit 47f747217811db35854ea06741be3685e8bbd44d)

Diff:
---
 sysdeps/x86/cacheinfo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sysdeps/x86/cacheinfo.c b/sysdeps/x86/cacheinfo.c
index a30d0bcfc6..67173970e1 100644
--- a/sysdeps/x86/cacheinfo.c
+++ b/sysdeps/x86/cacheinfo.c
@@ -696,8 +696,8 @@ init_cacheinfo (void)
       /* 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;
 	}
     }

                 reply	other threads:[~2023-09-12  3:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230912034810.DC0FF385841F@sourceware.org \
    --to=nwg@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).