From: Andrew Cooper <andrew.cooper3@citrix.com>
To: "Luis R. Rodriguez" <mcgrof@suse.com>,
David Vrabel <david.vrabel@citrix.com>
Cc: xen-devel@lists.xenproject.org,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Borislav Petkov <bp@suse.de>,
Steven Rostedt <rostedt@goodmis.org>,
Andy Lutomirski <luto@amacapital.net>
Subject: Re: [PATCHv5] x86/xen: allow privcmd hypercalls to be preempted
Date: Thu, 5 Feb 2015 18:23:28 +0000 [thread overview]
Message-ID: <54D3B520.7030209@citrix.com> (raw)
In-Reply-To: <20150205181445.GV19988@wotan.suse.de>
On 05/02/15 18:14, Luis R. Rodriguez wrote:
> On Thu, Feb 05, 2015 at 12:41:17PM +0000, David Vrabel wrote:
>> --- a/arch/x86/kernel/entry_32.S
>> +++ b/arch/x86/kernel/entry_32.S
>> @@ -982,6 +982,9 @@ ENTRY(xen_hypervisor_callback)
>> ENTRY(xen_do_upcall)
>> 1: mov %esp, %eax
>> call xen_evtchn_do_upcall
>> +#ifndef CONFIG_PREEMPT
>> + call xen_maybe_preempt_hcall
>> +#endif
>> jmp ret_from_intr
>> CFI_ENDPROC
>> ENDPROC(xen_hypervisor_callback)
> Oh good, did you get to test 32-bit? I was still trying to get
> a good recent Xen build to test the domU suggestion you had.
>
>> diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
>> index 9ebaf63..9069401 100644
>> --- a/arch/x86/kernel/entry_64.S
>> +++ b/arch/x86/kernel/entry_64.S
>> @@ -1198,6 +1198,9 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
>> popq %rsp
>> CFI_DEF_CFA_REGISTER rsp
>> decl PER_CPU_VAR(irq_count)
>> +#ifndef CONFIG_PREEMPT
>> + call xen_maybe_preempt_hcall
>> +#endif
>> jmp error_exit
>> CFI_ENDPROC
>> END(xen_do_hypervisor_callback)
>> diff --git a/drivers/xen/preempt.c b/drivers/xen/preempt.c
>> new file mode 100644
>> index 0000000..e2bcc01
>> --- /dev/null
>> +++ b/drivers/xen/preempt.c
> <-- ... -->
>
>> +DEFINE_PER_CPU(bool, xen_in_preemptible_hcall);
>> +EXPORT_SYMBOL_GPL(xen_in_preemptible_hcall);
>> +
>> +void xen_maybe_preempt_hcall(void)
>> +{
>> + if (__this_cpu_read(xen_in_preemptible_hcall)) {
>> + /*
>> + * Clear flag as we may be rescheduled on a different
>> + * cpu.
>> + */
>> + __this_cpu_write(xen_in_preemptible_hcall, false);
> This read might be on CPU 3.
>
>> + _cond_resched();
>> + __this_cpu_write(xen_in_preemptible_hcall, true);
> This CPU wright might happen on CPU 1 and as such it would
> write true to another CPU.
That is the entire point, because the hypercall is now being continued
on CPU1 rather than CPU3. The "preemptibleness" follows the task which
initiated the hypercall, not the cpu which it happened to start
executing on.
~Andrew
> I had tested this approach and
> it was my original approach and while it sort of works its
> obviously broken due to the above. After considering
> Andy's original request to use pt_regs instead it seemed a lot
> safer than trying to fix this approach, so that is what I
> went with.
>
> Luis
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2015-02-05 18:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-05 12:41 [PATCHv5] x86/xen: allow privcmd hypercalls to be preempted David Vrabel
2015-02-05 15:37 ` Boris Ostrovsky
2015-02-05 15:39 ` David Vrabel
2015-02-05 16:11 ` Boris Ostrovsky
2015-02-05 16:14 ` David Vrabel
2015-02-05 16:16 ` Boris Ostrovsky
2015-02-05 18:14 ` Luis R. Rodriguez
2015-02-05 18:23 ` Andrew Cooper [this message]
2015-02-05 18:36 ` Luis R. Rodriguez
2015-02-06 0:50 ` Andy Lutomirski
2015-02-06 10:01 ` David Vrabel
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=54D3B520.7030209@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@suse.de \
--cc=david.vrabel@citrix.com \
--cc=luto@amacapital.net \
--cc=mcgrof@suse.com \
--cc=rostedt@goodmis.org \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.