2 * Preemptible hypercalls
4 * Copyright (C) 2014 Citrix Systems R&D ltd.
6 * This source code is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
12 #include <linux/sched.h>
13 #include <xen/xen-ops.h>
15 #ifndef CONFIG_PREEMPT
18 * Some hypercalls issued by the toolstack can take many 10s of
19 * seconds. Allow tasks running hypercalls via the privcmd driver to
20 * be voluntarily preempted even if full kernel preemption is
23 * Such preemptible hypercalls are bracketed by
24 * xen_preemptible_hcall_begin() and xen_preemptible_hcall_end()
28 DEFINE_PER_CPU(bool, xen_in_preemptible_hcall
);
29 EXPORT_SYMBOL_GPL(xen_in_preemptible_hcall
);
31 asmlinkage __visible
void xen_maybe_preempt_hcall(void)
33 if (unlikely(__this_cpu_read(xen_in_preemptible_hcall
)
36 * Clear flag as we may be rescheduled on a different
39 __this_cpu_write(xen_in_preemptible_hcall
, false);
43 __this_cpu_write(xen_in_preemptible_hcall
, true);
46 #endif /* CONFIG_PREEMPT */