Changes

m
Line 39: Line 39:  
or signal). Then we need to put an pointer to <code>struct rseq_cs</code> to the <code>(struct rseq).rseq_cs</code> field.
 
or signal). Then we need to put an pointer to <code>struct rseq_cs</code> to the <code>(struct rseq).rseq_cs</code> field.
   −
== What about <code>flags</code>? ==
+
== Hnalding of <code>flags</code>? ==
   −
You may have noticed that both <code>struct rseq</code> and <code>struct rseq_cs</code> have <code>flags</code> field. It may took values from <code>enum rseq_cs_flags</code>.
+
Flags can be specified at either <code>struct rseq</code> and <code>struct rseq_cs</code> using values from <code>enum rseq_cs_flags</code>. Regardless of where they are set, the kernel combines them when determining restart behavior:
   −
First of all, a user may specify flags in any place they will be combined on the kernel side:
   
<pre>
 
<pre>
 
static int rseq_need_restart(struct task_struct *t, u32 cs_flags)
 
static int rseq_need_restart(struct task_struct *t, u32 cs_flags)
Line 59: Line 58:  
</pre>
 
</pre>
   −
The most common <code>flags</code> value is zero. In this case, the rseq CS will be interrupted (and IP will be fixed up to the abort handler)
+
The most common <code>flags</code> value is zero. In this case, the restartable sequence critical section is interrupted whenever a preemption, CPU migration, or signal occurs, and the instruction pointer (IP) will be redirected to the abort handler. In some scenarios, however, applications may prefer to allow a critical section to complete even when certain events occur, and can do so by explicitly setting the appropriate flags.
if preemption, migration, or signal occurs. But there are situations when users may want not to abort section once one of these events happen.
     −
It's worth mentioning that <code>RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL</code> can be used only in combination with <code>RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT</code> and <code>RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE</code>:
+
Note that <code>RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL</code> must be used in conjunction with both <code>RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT</code> and <code>RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE</code>. The kernel enforces this constraint to prevent inconsistent restart semantics:
 
<pre>
 
<pre>
 
/*
 
/*
Line 75: Line 73:  
return -EINVAL;
 
return -EINVAL;
 
</pre>
 
</pre>
      
== How CRIU handles rseq ==
 
== How CRIU handles rseq ==
554

edits