public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Li, Aubrey" <aubrey.li@linux.intel.com>
To: Tim Chen <tim.c.chen@linux.intel.com>,
	Aubrey Li <aubrey.li@intel.com>,
	tglx@linutronix.de, mingo@redhat.com, peterz@infradead.org,
	hpa@zytor.com
Cc: ak@linux.intel.com, arjan@linux.intel.com, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v1 1/2] x86/fpu: detect AVX task
Date: Thu, 8 Nov 2018 08:31:53 +0800	[thread overview]
Message-ID: <216189f0-a411-8bba-99d2-c4661de0ff93@linux.intel.com> (raw)
In-Reply-To: <cd83910a-7197-9c49-3b93-22d699d887c4@linux.intel.com>

On 2018/11/8 1:41, Tim Chen wrote:
> On 11/06/2018 10:23 AM, Aubrey Li wrote:
> 
>> +static inline void update_avx_state(struct avx_state *avx)
>> +{
>> +	/*
>> +	 * Check if XGETBV with ECX = 1 supported. XGETBV with ECX = 1
>> +	 * returns the logical-AND of XCR0 and XINUSE. XINUSE is a bitmap
>> +	 * by which the processor tracks the status of various components.
>> +	 */
>> +	if (!use_xgetbv1()) {
>> +		avx->state = 0;
>> +		return;
>> +	}
>> +	/*
>> +	 * XINUSE is dynamic to track component state because VZEROUPPER
>> +	 * happens on every function end and reset the bitmap to the
>> +	 * initial configuration.
>> +	 *
>> +	 * State decay is introduced to solve the race condition between
>> +	 * context switch and a function end. State is aggressively set
>> +	 * once it's detected but need to be cleared by decay 3 context
>> +	 * switches
>> +	 */
>> +	if (xgetbv(XINUSE_STATE_BITMAP_INDEX) & XFEATURE_MASK_Hi16_ZMM) {
>> +		avx->state = 1;
>> +		avx->decay_count = AVX_STATE_DECAY_COUNT;
>> +	} else {
>> +		if (!avx->decay_count)
> 
> Seems like the check should be
> 
> 		if (avx->decay_count)
> 
> as we decrement the decay_count if it is non-zero.

Right, thanks to point this out, will fix in v2 soon.

Thanks,
-Aubrey
> 
>> +			avx->decay_count--;
>> +		else
>> +			avx->state = 0;
>> +	}
>> +}
> 
> Tim
> 


      reply	other threads:[~2018-11-08  0:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-06 18:23 [RFC PATCH v1 1/2] x86/fpu: detect AVX task Aubrey Li
2018-11-06 18:23 ` [RFC PATCH v1 2/2] proc: add /proc/<pid>/thread_state Aubrey Li
2018-11-08  6:32   ` Ingo Molnar
2018-11-08 10:17     ` Peter Zijlstra
2018-11-08 14:03       ` Li, Aubrey
2018-11-12  5:31       ` Ingo Molnar
2018-11-12  7:53         ` Li, Aubrey
2018-11-12  8:56         ` Peter Zijlstra
2018-11-12 14:21           ` Arjan van de Ven
2018-11-07 17:41 ` [RFC PATCH v1 1/2] x86/fpu: detect AVX task Tim Chen
2018-11-08  0:31   ` Li, Aubrey [this message]

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=216189f0-a411-8bba-99d2-c4661de0ff93@linux.intel.com \
    --to=aubrey.li@linux.intel.com \
    --cc=ak@linux.intel.com \
    --cc=arjan@linux.intel.com \
    --cc=aubrey.li@intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tim.c.chen@linux.intel.com \
    /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