Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp428571pxb; Wed, 27 Oct 2021 05:45:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQEzXI6iQCEHcj+b2cXH70yyWpsOYEe6cxPYcVntC68Daypge3hJFiYrhRfeddfw3KVtBY X-Received: by 2002:a05:6402:141:: with SMTP id s1mr44630758edu.317.1635338700026; Wed, 27 Oct 2021 05:45:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635338700; cv=none; d=google.com; s=arc-20160816; b=0N5YzNjCr+kZn9TN5XkNp6P/Z7ICyFccvFpPTBrvsBqqcmKIs18A9sJnQ6wFx+ZJWN EXye1dwn+eVJ/O802gF/bEQ0A5KTMSD71ADZmj1tvWsuK0tQM3blJSBX0GDkAaZ5VxFD GG3rBg++RP/HblZk/rOpwLpDw5oFcpALwYzxKlXwEbsvimEpHbBJlHF+gH0aVjrIg8ew SUZasQ7yj0rD/s9XJXQY9XGzS8raipPsMNCbkqJ1FV6rFBXVhgAPozILXVoEfSY9uvGM 4JBWVwQZkNyQwD+vUF+NS/1v3orjjrKz83BYWqWVsls4pzxgQ3m8p6J0aaBHw1Afr+40 cf0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:cc:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2/dPlzQXyUrhPSkM0+tKmxPBQy3NoWlkGO5NrhUnd4c=; b=z0r6X+hpGm2pocWEgEIZhAg9sKC47ABrW/w9AzqY5TWv8ZXfckvxq6ikE+TjiVnOyl hgKsA83geOBjuD/QIu76kXGwD0KFSovSQgfXwTvrc9xcu1bx0/YlEGjVNDzTieIteMUr BgVmcZx7MVYHrDCnLUJ47OfLjljR6zOTYZyFtDUl+eCZjtYupAMFZk0DCk+ZJcTI0RzU GOe4ojmhn3LXfYgnauCkiVsvMRH7yaPLsis9KAADbB5YWqPe1lPYzvLEMAsS+254//mT AEsjw6RUNr1PLzS3C4NhJb5evFq+RaIwsfmBhcYAAAQw01LfpMLuj3c6TCLW4zGR68Gw wihA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ltzgSzMh; 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=pass (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 h17si14835363ede.422.2021.10.27.05.44.35; Wed, 27 Oct 2021 05:45:00 -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=pass header.i=@gmail.com header.s=20210112 header.b=ltzgSzMh; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237374AbhJZXSC (ORCPT + 99 others); Tue, 26 Oct 2021 19:18:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231948AbhJZXR6 (ORCPT ); Tue, 26 Oct 2021 19:17:58 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45754C061570 for ; Tue, 26 Oct 2021 16:15:34 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id nn3-20020a17090b38c300b001a03bb6c4ebso669877pjb.1 for ; Tue, 26 Oct 2021 16:15:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:cc; bh=2/dPlzQXyUrhPSkM0+tKmxPBQy3NoWlkGO5NrhUnd4c=; b=ltzgSzMhRgcu+wB0oxx/kTBf5T9s7Hky/B/l4IU11VJhothOVyQQu6qmdTTGoVHvrP QPwlH7g1A95prZ/JTxNmMKxca9YIifD8lz1zTi94ejMJgm0sWUViONTpg+/u+qjv0jn5 Vg0hrocFAJ3MCx1RZcyko0B+YHswYgRPhAS9opgBlv4G28QL4a9aYMQpM+OL4BShCCW4 SGVQ1XS7MjFndbc2hsPfitB1MFdn6CW1pbNy7nk2CIZy+Z0HwayfVMvTeMZmbkBTMgNo a/eB83zX4itb2jzx6bYoj8WKScAWgEo0dpx9xNlqsBT+TZqFhpT6zvfuHWeiG1jzoUCq AKRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:cc; bh=2/dPlzQXyUrhPSkM0+tKmxPBQy3NoWlkGO5NrhUnd4c=; b=uvuwFdl0Bb2smKIhKfGdvvL+7uGskfnvt5udqwvQTuCqyLE7k4XI1gpm0+UxXa7MPb X99ZHdqFIUs9oXCV7bMAKRTMrh6YbLxMkVYZxN6Hii1bkPV1dsIDZ/FND3bi8tgZlOJM aYVgntEv2fL2mMMLYyUbNoe5WO9ZdkFLangcZHf16H2WNa38G2nF73EyKVW9j+eVl0O8 DN6kpcVgNETkiDZCPIh/pewkpQ7LN1LgJTb3o2RjORxa3iWChhqf0y2+06scpfg4ZNRE TJtI0en0kMikvoPxfAvgx1J9sun4IgDlTYgh06kOymC0FGBml1f5er4U9/AUarK0LA84 vjTw== X-Gm-Message-State: AOAM531Hj/gwUW7dtFFn0UA911n1yOW3fdpqSw9fBtwYSMGfxwXmWVLG FbsNxqLHtBXFEDLotVwTRVrvK0MEKO/OPYC8F6E= X-Received: by 2002:a17:902:848c:b0:13f:e969:3c26 with SMTP id c12-20020a170902848c00b0013fe9693c26mt17639390plo.34.1635290133591; Tue, 26 Oct 2021 16:15:33 -0700 (PDT) MIME-Version: 1.0 References: <20210920053951.4093668-1-goldstein.w.n@gmail.com> <20211015204713.2855996-1-goldstein.w.n@gmail.com> In-Reply-To: <20211015204713.2855996-1-goldstein.w.n@gmail.com> From: Noah Goldstein Date: Tue, 26 Oct 2021 18:15:22 -0500 Message-ID: Subject: Re: [PATCH v2 1/2] x86/fpu: Add helper function for tracking AVX512 status Cc: tglx@linutronix.de, mingo@redhat.com, Borislav Petkov , X86 ML , hpa@zytor.com, Andy Lutomirski , open list Content-Type: text/plain; charset="UTF-8" To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 15, 2021 at 3:57 PM Noah Goldstein wrote: > > This commit adds a new helper function 'fpu_update_avx_timestamp' to > perform the logic from tracking AVX512 feature use. > > Signed-off-by: Noah Goldstein > --- > Since Borislav Petkov is concerned about adding more macro masks and > inlining the AVX512 status this patch adds a new helper function. This > patch does not change the behavior of the current AVX512 status. > > arch/x86/include/asm/fpu/xstate.h | 1 + > arch/x86/kernel/fpu/core.c | 6 ++---- > arch/x86/kernel/fpu/xstate.c | 13 +++++++++++++ > 3 files changed, 16 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/include/asm/fpu/xstate.h b/arch/x86/include/asm/fpu/xstate.h > index 109dfcc75299..fe84ac5fb039 100644 > --- a/arch/x86/include/asm/fpu/xstate.h > +++ b/arch/x86/include/asm/fpu/xstate.h > @@ -134,6 +134,7 @@ extern u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS]; > extern void __init update_regset_xstate_info(unsigned int size, > u64 xstate_mask); > > +void fpu_update_avx_timestamp(struct fpu *fpu); > void *get_xsave_addr(struct xregs_state *xsave, int xfeature_nr); > int xfeature_size(int xfeature_nr); > int copy_uabi_from_kernel_to_xstate(struct xregs_state *xsave, const void *kbuf); > diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c > index 7ada7bd03a32..6dbf3ee642f9 100644 > --- a/arch/x86/kernel/fpu/core.c > +++ b/arch/x86/kernel/fpu/core.c > @@ -102,11 +102,9 @@ void save_fpregs_to_fpstate(struct fpu *fpu) > os_xsave(&fpu->state.xsave); > > /* > - * AVX512 state is tracked here because its use is > - * known to slow the max clock speed of the core. > + * Track of the state of desired avx related xfeatures. > */ > - if (fpu->state.xsave.header.xfeatures & XFEATURE_MASK_AVX512) > - fpu->avx512_timestamp = jiffies; > + fpu_update_avx_timestamp(fpu); > return; > } > > diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c > index c8def1b7f8fb..00b495914be2 100644 > --- a/arch/x86/kernel/fpu/xstate.c > +++ b/arch/x86/kernel/fpu/xstate.c > @@ -1245,6 +1245,19 @@ void xrstors(struct xregs_state *xstate, u64 mask) > WARN_ON_ONCE(err); > } > > +/* > + * Track of the state of desired avx architecture features. > + */ > +void fpu_update_avx_timestamp(struct fpu *fpu) > +{ > + /* > + * AVX512 state is tracked here because its use is known to slow > + * the max clock speed of the core. > + */ > + if (fpu->state.xsave.header.xfeatures & XFEATURE_MASK_AVX512) > + fpu->avx512_timestamp = jiffies; > +} > + > #ifdef CONFIG_PROC_PID_ARCH_STATUS > /* > * Report the amount of time elapsed in millisecond since last AVX512 > -- > 2.25.1 > Ping.