From patchwork Fri Aug 11 17:29:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 1820368 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=P1p1pBnf; 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 4RMrQK1N36z1yf7 for ; Sat, 12 Aug 2023 03:29:41 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EBD773856DE8 for ; Fri, 11 Aug 2023 17:29:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EBD773856DE8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691774978; bh=rOuhLt0TDDXYiOPwysIef1uM+uTD5/whiFmgf7hare0=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=P1p1pBnfvoWjWJfqgCxZx4e6/6Gd9m5aGmRB2PS4/Og5cHe1J2XS7AeMhthqfZxLO LB4CK0JKjdRIKMshu6Wz3PN46eYQ6dAXDC8agRbCmW/otmLTEfYHCxxurMm6rZaRUw 6cuOZZnX10cAad701lUnTGomOQn9sx1IH8g1PadU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by sourceware.org (Postfix) with ESMTPS id D26D13858D32 for ; Fri, 11 Aug 2023 17:29:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D26D13858D32 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-1a28de15c8aso1877233fac.2 for ; Fri, 11 Aug 2023 10:29:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691774961; x=1692379761; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rOuhLt0TDDXYiOPwysIef1uM+uTD5/whiFmgf7hare0=; b=hBeamhmY+0uzowtDvWQtSHWR1Ji05D/lu/K9ALI/uapYqVtjUc33wYwW2u2eQCS8v6 /YhtnpRCLVdDIfMBasqbBP7mB6+Zm1zjGhR4pMwBsG+xPhY2pXuJAWenRhyzgOLL+rnQ haMD+LEIr+uLqQ/qLv5lRvoZT7BQOMax1rBs0Eq8or7GmMiIeox+gbnWQZUk56KYsI0x WKLXCPWjVbLER1cLI/oz42NCLM0DAhTmI4vTF97n/Y5O+u94XicyXLMTuSvgwb/113bb AdPFTIvyFpSx0C8uczzLHZF0h8k2JvOEFxswsrnt89eEThNOvD1bZNrmZb871SX/c47/ Czfg== X-Gm-Message-State: AOJu0YxK6pVKmF+xK/0i7+vWnuGDDRUg+ZLYAs3+z1FMtVfGUZLJwybo UDXfQqQSFgXEcJXByrVtEpzWbbiaHpg= X-Google-Smtp-Source: AGHT+IHz/wJf9BqxGyuiSeYzmXMZHvrC5406k0qMls1FdHhYohU7ApT8SrP/lHI+61zEOCx3xLiiqg== X-Received: by 2002:a05:6870:c594:b0:1ba:2a58:b15e with SMTP id ba20-20020a056870c59400b001ba2a58b15emr3172598oab.2.1691774961346; Fri, 11 Aug 2023 10:29:21 -0700 (PDT) Received: from noahgold-DESK.. (66.sub-174-246-202.myvzw.com. [174.246.202.66]) by smtp.gmail.com with ESMTPSA id j5-20020a056870530500b001bb947fa220sm2183024oan.32.2023.08.11.10.29.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 10:29:20 -0700 (PDT) To: libc-alpha@sourceware.org Cc: goldstein.w.n@gmail.com, hjl.tools@gmail.com, carlos@systemhalted.org Subject: [PATCH v3] x86: Fix incorrect scope of setting `shared_per_thread` [BZ# 30745] Date: Fri, 11 Aug 2023 12:29:11 -0500 Message-Id: <20230811172911.3705552-1-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230811003109.3046769-1-goldstein.w.n@gmail.com> References: <20230811003109.3046769-1-goldstein.w.n@gmail.com> 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 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" The: ``` if (shared_per_thread > 0 && threads > 0) shared_per_thread /= threads; ``` Code was accidentally moved to inside the else scope. This doesn't match how it was previously (before af992e7abd). This patch fixes that by putting the division after the `else` block. Tested-by: Carlos O'Donell Reviewed-by: Carlos O'Donell --- sysdeps/x86/dl-cacheinfo.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h index 285773039f..5ddb35c9d9 100644 --- a/sysdeps/x86/dl-cacheinfo.h +++ b/sysdeps/x86/dl-cacheinfo.h @@ -770,11 +770,10 @@ get_common_cache_info (long int *shared_ptr, long int * shared_per_thread_ptr, u level. */ threads = ((cpu_features->features[CPUID_INDEX_1].cpuid.ebx >> 16) & 0xff); - - /* Get per-thread size of highest level cache. */ - if (shared_per_thread > 0 && threads > 0) - shared_per_thread /= threads; } + /* Get per-thread size of highest level cache. */ + if (shared_per_thread > 0 && threads > 0) + shared_per_thread /= threads; } /* Account for non-inclusive L2 and L3 caches. */