public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	rostedt <rostedt@goodmis.org>, Ben Segall <bsegall@google.com>,
	Mel Gorman <mgorman@suse.de>, bristot <bristot@redhat.com>,
	Borislav Petkov <bp@alien8.de>, x86 <x86@kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>, Jens Axboe <axboe@kernel.dk>,
	Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@redhat.com>,
	dm-devel@redhat.com, "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Felipe Balbi <balbi@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Tejun Heo <tj@kernel.org>, Zefan Li <liz>
Subject: Re: [PATCH 3/6] sched,perf,kvm: Fix preemption condition
Date: Wed, 2 Jun 2021 09:59:07 -0400 (EDT)	[thread overview]
Message-ID: <1873020549.5854.1622642347895.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <20210602133040.398289363@infradead.org>

----- On Jun 2, 2021, at 9:12 AM, Peter Zijlstra peterz@infradead.org wrote:

> When ran from the sched-out path (preempt_notifier or perf_event),
> p->state is irrelevant to determine preemption. You can get preempted
> with !task_is_running() just fine.
> 
> The right indicator for preemption is if the task is still on the
> runqueue in the sched-out path.
> 
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> kernel/events/core.c |    7 +++----
> virt/kvm/kvm_main.c  |    2 +-
> 2 files changed, 4 insertions(+), 5 deletions(-)
> 
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -8568,13 +8568,12 @@ static void perf_event_switch(struct tas
> 		},
> 	};
> 
> -	if (!sched_in && task->state == TASK_RUNNING)
> +	if (!sched_in && current->on_rq) {

This changes from checking task->state to current->on_rq, but this change
from "task" to "current" is not described in the commit message, which is odd.

Are we really sure that task == current here ?

Thanks,

Mathieu

> 		switch_event.event_id.header.misc |=
> 				PERF_RECORD_MISC_SWITCH_OUT_PREEMPT;
> +	}
> 
> -	perf_iterate_sb(perf_event_switch_output,
> -		       &switch_event,
> -		       NULL);
> +	perf_iterate_sb(perf_event_switch_output, &switch_event, NULL);
> }
> 
> /*
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -4869,7 +4869,7 @@ static void kvm_sched_out(struct preempt
> {
> 	struct kvm_vcpu *vcpu = preempt_notifier_to_vcpu(pn);
> 
> -	if (current->state == TASK_RUNNING) {
> +	if (current->on_rq) {
> 		WRITE_ONCE(vcpu->preempted, true);
> 		WRITE_ONCE(vcpu->ready, true);
>  	}

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

  reply	other threads:[~2021-06-02 13:59 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02 13:12 [PATCH 0/6] sched: Cleanup task_struct::state Peter Zijlstra
2021-06-02 13:12 ` [PATCH 1/6] sched: Unbreak wakeups Peter Zijlstra
2021-06-02 13:58   ` Greg Kroah-Hartman
     [not found]   ` <20210602133040.271625424-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2021-06-02 14:47     ` Will Deacon
2021-06-02 19:43   ` Davidlohr Bueso
2021-06-02 13:12 ` [PATCH 2/6] sched: Introduce task_is_running() Peter Zijlstra
2021-06-02 14:59   ` Will Deacon
2021-06-02 16:46     ` Peter Zijlstra
2021-06-02 23:15   ` Davidlohr Bueso
2021-06-02 13:12 ` [PATCH 3/6] sched,perf,kvm: Fix preemption condition Peter Zijlstra
2021-06-02 13:59   ` Mathieu Desnoyers [this message]
2021-06-02 14:10     ` Peter Zijlstra
     [not found]       ` <YLeRVQbXt2hCiO8f-Nxj+rRp3nVydTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2021-06-02 14:30         ` Mark Rutland
     [not found]   ` <20210602133040.398289363-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2021-06-02 14:15     ` Mathieu Desnoyers
2021-06-02 14:23       ` Peter Zijlstra
2021-06-02 13:12 ` [PATCH 4/6] sched: Add get_current_state() Peter Zijlstra
     [not found]   ` <20210602133040.461908001-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2021-06-02 14:01     ` Mathieu Desnoyers
2021-06-02 14:12       ` Peter Zijlstra
2021-06-02 15:02   ` Will Deacon
2021-06-02 13:12 ` [PATCH 5/6] sched,timer: Use __set_current_state() Peter Zijlstra
     [not found]   ` <20210602133040.524487671-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2021-06-02 15:06     ` Will Deacon
2021-06-02 19:54   ` Davidlohr Bueso
2021-06-03  6:39     ` Peter Zijlstra
2021-06-18 20:42   ` Thomas Gleixner
2021-06-02 13:12 ` [PATCH 6/6] sched: Change task_struct::state Peter Zijlstra
     [not found]   ` <20210602133040.587042016-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2021-06-02 14:06     ` Mathieu Desnoyers
2021-06-02 14:20       ` Peter Zijlstra
2021-06-02 15:10     ` Will Deacon
2021-06-07 10:45   ` Daniel Thompson
     [not found]     ` <20210607104500.sopvslejuoxwzhrs-DWWWtol72k3/PtFMR13I2A@public.gmane.org>
2021-06-07 11:10       ` Peter Zijlstra

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=1873020549.5854.1622642347895.JavaMail.zimbra@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=agk@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=balbi@kernel.org \
    --cc=bp@alien8.de \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=davem@davemloft.net \
    --cc=dietmar.eggemann@arm.com \
    --cc=dm-devel@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=juri.lelli@redhat.com \
    --cc=kuba@kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=snitzer@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=x86@kernel.org \
    /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