treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / xen / preempt.c
blob70650b248de5d43dae2b4ae01d1fbebfaa6d4c10
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Preemptible hypercalls
5 * Copyright (C) 2014 Citrix Systems R&D ltd.
6 */
8 #include <linux/sched.h>
9 #include <xen/xen-ops.h>
11 #ifndef CONFIG_PREEMPTION
14 * Some hypercalls issued by the toolstack can take many 10s of
15 * seconds. Allow tasks running hypercalls via the privcmd driver to
16 * be voluntarily preempted even if full kernel preemption is
17 * disabled.
19 * Such preemptible hypercalls are bracketed by
20 * xen_preemptible_hcall_begin() and xen_preemptible_hcall_end()
21 * calls.
24 DEFINE_PER_CPU(bool, xen_in_preemptible_hcall);
25 EXPORT_SYMBOL_GPL(xen_in_preemptible_hcall);
27 asmlinkage __visible void xen_maybe_preempt_hcall(void)
29 if (unlikely(__this_cpu_read(xen_in_preemptible_hcall)
30 && need_resched())) {
32 * Clear flag as we may be rescheduled on a different
33 * cpu.
35 __this_cpu_write(xen_in_preemptible_hcall, false);
36 _cond_resched();
37 __this_cpu_write(xen_in_preemptible_hcall, true);
40 #endif /* CONFIG_PREEMPTION */