lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140702104958.GB6758@twins.programming.kicks-ass.net>
Date:	Wed, 2 Jul 2014 12:49:58 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	"Yan, Zheng" <zheng.z.yan@...el.com>
Cc:	linux-kernel@...r.kernel.org, mingo@...nel.org, acme@...radead.org,
	eranian@...gle.com, andi@...stfloor.org
Subject: Re: [PATCH V4 09/16] perf, x86: Save/resotre LBR stack during
 context switch

On Mon, Jun 30, 2014 at 04:50:46PM +0800, Yan, Zheng wrote:
>  void intel_pmu_lbr_sched_task(struct perf_event_context *ctx, bool sched_in)
>  {
>  	struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
> +	struct x86_perf_task_context *task_ctx;
>  
>  	if (!x86_pmu.lbr_nr)
>  		return;
>  
>  	/*
> +	 * If LBR callstack feature is enabled and the stack was saved when
> +	 * the task was scheduled out, restore the stack. Otherwise flush
> +	 * the LBR stack.
>  	 */
> +	task_ctx = ctx ? ctx->task_ctx_data : NULL;
>  	if (sched_in) {
> +		if (task_ctx &&
> +		    task_ctx->lbr_callstack_users > 0 &&
> +		    task_ctx->lbr_stack_state == LBR_VALID)
> +			__intel_pmu_lbr_restore(task_ctx);
> +		else
> +			intel_pmu_lbr_reset();
> +
>  		cpuc->lbr_context = ctx;
> +		return;
> +	}
> +
> +	/* schedule out */
> +	if (task_ctx) {
> +		if (task_ctx->lbr_callstack_users)
> +			__intel_pmu_lbr_save(task_ctx);
> +		else
> +			task_ctx->lbr_stack_state = LBR_NONE;
>  	}
>  }

I can't say that's pretty..

How about something like:

	task_ctx = ctx->task_ctx_data; /* XXX I don't think ctx can ever be NULL here */
	if (task_ctx) {
		if (sched_in)
			intel_pmu_lbr_restore(task_ctx);
		else
			intel_pmu_lbr_save(task_ctx);
		return;
	}

	if (sched_in)
		intel_pmu_lbr_reset();


And then push all the callstack_users and state nonsense into the
save/restore functions.

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ