Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1666108pxb; Mon, 20 Sep 2021 02:16:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDxokQPWmxvpIrrixwV1fs+6Tvp1cmpi8HOmhHy7ybtzZw9CSVtlnMZhAlXg7zEn/DNCOz X-Received: by 2002:a17:906:341b:: with SMTP id c27mr28282218ejb.61.1632129366682; Mon, 20 Sep 2021 02:16:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632129366; cv=none; d=google.com; s=arc-20160816; b=Rk4zkxIJGct8CLdJ3vI4C3+Av7e77tpiSWqYx8SvRDc7yIBIqvA4lZk2Hp17Y387at YwNW3jIoxeUohVU056UJeM48S9kruIrbHctXkgH+VR9Becqu0c3aJdgn5XQmc247pXGp PenT3o3M2wXSVGtRsig8OaZewwve9GeSISIgqTcgKVPqq6e/3zz4rz+jjSjyt2CnuEAq CSRIllVJmO+UwRoJx72ApNsQmsFNe7N+2fg/VmSpYbUtOfb96kl15sQ9CWayMUJikI8a P8BJDRB+adBEwYEEF7s3tzS2eiSXLR3ISGycmV6d4/lSjsYueCsxR152ARJRuRT6VfQj XL5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=1DjZAydXYzsdy9pCHIcJ/nHjYhS+wh3B+BCzHPEFxGM=; b=dhUfBelgua26a1Zf1DWE6xIiA28zmHmSkUoq3S6kWZ5VaVOTOU1L/VFDOC59RpdROf 3rhvYaAVonUBDVy/7U82TAJBGirIggTF2iGJcqLOo/HQe4lVh9fBEozt/PK1xkMWPs7A 1YFCnWIYghATrNf2cxVeG+ac96GOBznepxfW7YVxuDZU9lJ9JQNI+1dfhQtDJgEYF/Mm Ecnk2IPVilShfBVOxbe9X7lMoC6HjFgava6/kaaXq7LJPgYH/0zQVOazWps3mFYZnWul ifojvyej6aZkAl4HxfHN38CIqAKDwHUZpbKMQ1rt/U5XwTbA96/DP7fUxf/KqQIdBc4M XAbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=ZSy9M462; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 11si9286828eja.248.2021.09.20.02.15.43; Mon, 20 Sep 2021 02:16:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=ZSy9M462; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232525AbhITFmN (ORCPT + 99 others); Mon, 20 Sep 2021 01:42:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231250AbhITFmN (ORCPT ); Mon, 20 Sep 2021 01:42:13 -0400 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42443C061574 for ; Sun, 19 Sep 2021 22:40:47 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id j18so20406270ioj.8 for ; Sun, 19 Sep 2021 22:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1DjZAydXYzsdy9pCHIcJ/nHjYhS+wh3B+BCzHPEFxGM=; b=ZSy9M462yzXAyhrDLIKaEt0Za7KeqPrfuk/ph5LD12+FSewZB/7FIoeswo83+8z52w qjCKQJ4k7Y9yxcCTu8gdzPnsL3R/NYcIi1LZ7j/ZAtpKZfey+/fVVx84zrmTI4T+vvbU hdN9mmQYcVh558c7+wVBosHtkoTkKOvFN6HT3IHEn+DUz36B+Q9cQJwF9gPLrzZ18Uyr u65fgMEb0khMPuYMbl//p+xY8QnkxSXo0slxqzTCfJR+gNyFOKpCcG33PaytMPf5DslG yyqeztn+KE5+jlq+rkmRd1GKt/HmJipePfNlXh+C1feN3BrSiKgqZ0RWu7RXGQjsDnLo B0EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1DjZAydXYzsdy9pCHIcJ/nHjYhS+wh3B+BCzHPEFxGM=; b=Owcm7UFcB7SR40caN2SdDIsIhSCcCYW3kjNm9cb7mi9SPO2Kl5iFDu2+l13etakkNF DPCFwC/9P9DUiErwH9FpC3uN/7qGbCd4mkZIR9om/M5Q1jraDMyplef/wMCl5XYjHNE3 +PdLUOUFlOaLYTK6CPdRRivImecm/wa8oiPB+a5DcdwqyXn+pA0Yni4BWlmTv+GxgJ4M nuMqpWA76otAuUaG1THnb0sxQRX4JvW5Sy3WK30x4K1v3nKhUeTbC/55iMBvdv7mXIOG eW9PjKm9OELlj/wE18vlHRqb5PYShMMw2/iiKjbZrriHy0foKUbLK+paXz9iRKp9jrbm nyxQ== X-Gm-Message-State: AOAM530tLzaUMefaRJDQ54wKCW/9obzJPwCiy70l6knQpjLgmyRQI2p7 S7om4gElob95jUCIkCkZoww= X-Received: by 2002:a05:6638:1514:: with SMTP id b20mr17887659jat.47.1632116440409; Sun, 19 Sep 2021 22:40:40 -0700 (PDT) Received: from localhost.localdomain (node-17-161.flex.volo.net. [76.191.17.161]) by smtp.googlemail.com with ESMTPSA id c11sm8032398ile.22.2021.09.19.22.40.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 22:40:40 -0700 (PDT) From: Noah Goldstein Cc: goldstein.w.n@gmail.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, luto@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1] x86/fpu: Remove opmask state from avx512_timestamp check Date: Mon, 20 Sep 2021 00:39:53 -0500 Message-Id: <20210920053951.4093668-1-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit creates a new mask, XFEATURE_MASK_ZMM, to test against xfeatures for conditionally updating the axx512_timestamp. Based on the comments, the avx512 state is meant to track when the state would cause frequencey throttling. The opmasks (k0-k7) do not cause frequency throttling, so they don't make sense to include. The current implementation, as well as the old, still does have a false positive on ymm16-ymm31 and xmm16-31 because XFEATURE_MASK_Hi16_ZMM includes them. Signed-off-by: Noah Goldstein --- Issue is reproducible with the following code on x86_64: ``` .global _start .text _start: korq %k0, %k0, %k0 loop: jmp loop movl $60, %eax xorl %edi, %edi syscall ``` Pretending run as executable named "foo": $> cat /proc/$(pidof foo)/arch_status This should yield -1 as no frequency changing AVX512 instructions where used but instead tracks the process. Note there still is a false positive with ymm16-ymm31 and xmm16-xmm31 but since there is no state to distinguish between there use and zmm16-31 that seems inevitable. arch/x86/include/asm/fpu/types.h | 2 ++ arch/x86/kernel/fpu/core.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/fpu/types.h b/arch/x86/include/asm/fpu/types.h index f5a38a5f3ae1..a4816fa7d541 100644 --- a/arch/x86/include/asm/fpu/types.h +++ b/arch/x86/include/asm/fpu/types.h @@ -141,6 +141,8 @@ enum xfeature { #define XFEATURE_MASK_AVX512 (XFEATURE_MASK_OPMASK \ | XFEATURE_MASK_ZMM_Hi256 \ | XFEATURE_MASK_Hi16_ZMM) +#define XFEATURE_MASK_ZMM (XFEATURE_MASK_ZMM_Hi256 \ + | XFEATURE_MASK_Hi16_ZMM) #define FIRST_EXTENDED_XFEATURE XFEATURE_YMM diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 7ada7bd03a32..342620a2e8ef 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -104,8 +104,10 @@ void save_fpregs_to_fpstate(struct fpu *fpu) /* * AVX512 state is tracked here because its use is * known to slow the max clock speed of the core. + * Note: This has a false positive on Hi16 ymm and + * xmm registers. */ - if (fpu->state.xsave.header.xfeatures & XFEATURE_MASK_AVX512) + if (fpu->state.xsave.header.xfeatures & XFEATURE_MASK_ZMM) fpu->avx512_timestamp = jiffies; return; } -- 2.25.1