Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1679468

Re: [PATCH 17/21] x86/intel_rdt/cqm: Add sched_in support

From Thomas Gleixner <tglx@linutronix.de>
Newsgroups linux.kernel
Subject Re: [PATCH 17/21] x86/intel_rdt/cqm: Add sched_in support
Date 2017-07-02 15:40 +0200
Message-ID <tYNgu-2wM-21@gated-at.bofh.it> (permalink)
References <tWHoR-5Yd-3@gated-at.bofh.it> <tWHoT-5Yd-53@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, 26 Jun 2017, Vikas Shivappa wrote:
>  DECLARE_PER_CPU(struct intel_pqr_state, pqr_state);
>  DECLARE_PER_CPU_READ_MOSTLY(int, cpu_closid);
> +DECLARE_PER_CPU_READ_MOSTLY(int, cpu_rmid);
>  DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key);
> +DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key);
> +DECLARE_STATIC_KEY_FALSE(rdt_enable_key);

Please make this a two stage change. Add rdt_enable_key first and then the
monitoring stuff. Ideally you introduce rdt_enable_key here and in the
control code in one go.

> +static void __intel_rdt_sched_in(void)
>  {
> -	if (static_branch_likely(&rdt_alloc_enable_key)) {
> -		struct intel_pqr_state *state = this_cpu_ptr(&pqr_state);
> -		int closid;
> +	struct intel_pqr_state *state = this_cpu_ptr(&pqr_state);
> +	u32 closid = 0;
> +	u32 rmid = 0;
>  
> +	if (static_branch_likely(&rdt_alloc_enable_key)) {
>  		/*
>  		 * If this task has a closid assigned, use it.
>  		 * Else use the closid assigned to this cpu.
> @@ -55,14 +59,31 @@ static inline void intel_rdt_sched_in(void)
>  		closid = current->closid;
>  		if (closid == 0)
>  			closid = this_cpu_read(cpu_closid);
> +	}
> +
> +	if (static_branch_likely(&rdt_mon_enable_key)) {
> +		/*
> +		 * If this task has a rmid assigned, use it.
> +		 * Else use the rmid assigned to this cpu.
> +		 */
> +		rmid = current->rmid;
> +		if (rmid == 0)
> +			rmid = this_cpu_read(cpu_rmid);
> +	}
>  
> -		if (closid != state->closid) {
> -			state->closid = closid;
> -			wrmsr(IA32_PQR_ASSOC, state->rmid, closid);
> -		}
> +	if (closid != state->closid || rmid != state->rmid) {
> +		state->closid = closid;
> +		state->rmid = rmid;
> +		wrmsr(IA32_PQR_ASSOC, rmid, closid);

This can be written smarter.

	struct intel_pqr_state newstate = this_cpu_read(rdt_cpu_default);
	struct intel_pqr_state *curstate = this_cpu_ptr(&pqr_state);

	if (static_branch_likely(&rdt_alloc_enable_key)) {
		if (current->closid)
			newstate.closid = current->closid;
	}

	if (static_branch_likely(&rdt_mon_enable_key)) {
		if (current->rmid)
			newstate.rmid = current->rmid;
	}

	if (newstate != *curstate) {
		*curstate = newstate;
		wrmsr(IA32_PQR_ASSOC, newstate.rmid, newstate.closid);
	}

The unconditional read of rdt_cpu_default is the right thing to do because
the default behaviour is exactly this.

Thanks,

	tglx

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH V1 00/21] x86/cqm3: Resctrl based cqm Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-06-26 21:00 +0200
  [PATCH 16/21] x86/intel_rdt/cqm: Add mount,umount support Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-06-26 21:00 +0200
    Re: [PATCH 16/21] x86/intel_rdt/cqm: Add mount,umount support Thomas Gleixner <tglx@linutronix.de> - 2017-07-02 15:30 +0200
  [PATCH 20/21] x86/intel_rdt/mbm: Add mbm counter initialization Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-06-26 21:00 +0200
  [PATCH 13/21] x86/intel_rdt/cqm: Add cpus file support Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-06-26 21:00 +0200
    Re: [PATCH 13/21] x86/intel_rdt/cqm: Add cpus file support Thomas Gleixner <tglx@linutronix.de> - 2017-07-02 13:20 +0200
    Re: [PATCH 13/21] x86/intel_rdt/cqm: Add cpus file support Thomas Gleixner <tglx@linutronix.de> - 2017-07-02 14:40 +0200
  [PATCH 15/21] x86/intel_rdt/cqm: Add rmdir support Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-06-26 21:00 +0200
    Re: [PATCH 15/21] x86/intel_rdt/cqm: Add rmdir support Thomas Gleixner <tglx@linutronix.de> - 2017-07-02 15:20 +0200
  [PATCH 03/21] x86/intel_rdt/cqm: Documentation for resctrl based RDT Monitoring Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-06-26 21:00 +0200
  [PATCH 21/21] x86/intel_rdt/mbm: Handle counter overflow Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-06-26 21:00 +0200
    Re: [PATCH 21/21] x86/intel_rdt/mbm: Handle counter overflow Thomas Gleixner <tglx@linutronix.de> - 2017-07-02 16:00 +0200
  [PATCH 14/21] x86/intel_rdt/cqm: Add mon_data Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-06-26 21:00 +0200
    Re: [PATCH 14/21] x86/intel_rdt/cqm: Add mon_data Thomas Gleixner <tglx@linutronix.de> - 2017-07-02 14:50 +0200
  [PATCH 17/21] x86/intel_rdt/cqm: Add sched_in support Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-06-26 21:00 +0200
    Re: [PATCH 17/21] x86/intel_rdt/cqm: Add sched_in support Thomas Gleixner <tglx@linutronix.de> - 2017-07-02 15:40 +0200
  [PATCH 12/21] x86/intel_rdt/cqm: Add tasks file support Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-06-26 21:00 +0200
    Re: [PATCH 12/21] x86/intel_rdt/cqm: Add tasks file support Thomas Gleixner <tglx@linutronix.de> - 2017-07-02 13:10 +0200
  [PATCH 08/21] x86/intel_rdt/cqm: Add RMID(Resource monitoring ID) management Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-06-26 21:00 +0200
    Re: [PATCH 08/21] x86/intel_rdt/cqm: Add RMID(Resource monitoring  ID) management Thomas Gleixner <tglx@linutronix.de> - 2017-07-02 12:10 +0200
      Re: [PATCH 08/21] x86/intel_rdt/cqm: Add RMID(Resource monitoring  ID) management Thomas Gleixner <tglx@linutronix.de> - 2017-07-03 12:00 +0200

csiph-web