/*
 * Preemptible hypercalls
 *
 * Copyright (C) 2014 Citrix Systems R&D ltd.
 *
 * This source code is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 */

#include <linux/sched.h>
#include <xen/xen-ops.h>

#ifndef CONFIG_PREEMPT

/*
 * Some hypercalls issued by the toolstack can take many 10s of
 * seconds. Allow tasks running hypercalls via the privcmd driver to
 * be voluntarily preempted even if full kernel preemption is
 * disabled.
 *
 * Such preemptible hypercalls are bracketed by
 * xen_preemptible_hcall_begin() and xen_preemptible_hcall_end()
 * calls.
 */

DEFINE_PER_CPU(bool, xen_in_preemptible_hcall);
EXPORT_SYMBOL_GPL(xen_in_preemptible_hcall);

asmlinkage __visible void xen_maybe_preempt_hcall(void)
{
	if (unlikely(__this_cpu_read(xen_in_preemptible_hcall)
		     && need_resched())) {
		/*
		 * Clear flag as we may be rescheduled on a different
		 * cpu.
		 */
		__this_cpu_write(xen_in_preemptible_hcall, false);
		_cond_resched();
		__this_cpu_write(xen_in_preemptible_hcall, true);
	}
}
#endif /* CONFIG_PREEMPT */
cket-loop-back'>packet-loop-back</option>
<option value='packet-rx-pump-back'>packet-rx-pump-back</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>net-next plumbings</td><td class='sub right'>Tobias Klauser</td></tr></table>
<table class='tabs'><tr><td>
<a href='/cgit.cgi/linux/net-next.git/'>summary</a><a href='/cgit.cgi/linux/net-next.git/refs/?id=6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25'>refs</a><a class='active' href='/cgit.cgi/linux/net-next.git/log/include/scsi/iscsi_if.h?showmsg=1'>log</a><a href='/cgit.cgi/linux/net-next.git/tree/include/scsi/iscsi_if.h?id=6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25'>tree</a><a href='/cgit.cgi/linux/net-next.git/commit/include/scsi/iscsi_if.h?id=6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25'>commit</a><a href='/cgit.cgi/linux/net-next.git/diff/include/scsi/iscsi_if.h?id=6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/include/scsi/iscsi_if.h'>
<input type='hidden' name='id' value='6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25'/><input type='hidden' name='showmsg' value='1'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/log/?id=6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25&amp;showmsg=1'>root</a>/<a href='/cgit.cgi/linux/net-next.git/log/include?id=6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25&amp;showmsg=1'>include</a>/<a href='/cgit.cgi/linux/net-next.git/log/include/scsi?id=6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25&amp;showmsg=1'>scsi</a>/<a href='/cgit.cgi/linux/net-next.git/log/include/scsi/iscsi_if.h?id=6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25&amp;showmsg=1'>iscsi_if.h</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/cgit.cgi/linux/net-next.git/log/include/scsi/iscsi_if.h?id=6d9f66ac7fec2a6ccd649e5909806dfe36f1fc25'>Collapse</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>