'\" t .\" Title: struct fence .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: January 2017 .\" Manual: Device drivers infrastructure .\" Source: Kernel Hackers Manual 4.8.15 .\" Language: English .\" .TH "STRUCT FENCE" "9" "January 2017" "Kernel Hackers Manual 4\&.8\&." "Device drivers infrastructure" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" struct_fence \- software synchronization primitive .SH "SYNOPSIS" .sp .nf struct fence { struct kref refcount; const struct fence_ops * ops; struct rcu_head rcu; struct list_head cb_list; spinlock_t * lock; u64 context; unsigned seqno; unsigned long flags; ktime_t timestamp; int status; }; .fi .SH "MEMBERS" .PP refcount .RS 4 refcount for this fence .RE .PP ops .RS 4 fence_ops associated with this fence .RE .PP rcu .RS 4 used for releasing fence with kfree_rcu .RE .PP cb_list .RS 4 list of all callbacks to call .RE .PP lock .RS 4 spin_lock_irqsave used for locking .RE .PP context .RS 4 execution context this fence belongs to, returned by \fBfence_context_alloc\fR .RE .PP seqno .RS 4 the sequence number of this fence inside the execution context, can be compared to decide which fence would be signaled later\&. .RE .PP flags .RS 4 A mask of FENCE_FLAG_* defined below .RE .PP timestamp .RS 4 Timestamp when the fence was signaled\&. .RE .PP status .RS 4 Optional, only valid if < 0, must be set before calling fence_signal, indicates that the fence has completed with an error\&. .RE .SH "DESCRIPTION" .PP the flags member must be manipulated and read using the appropriate atomic ops (bit_*), so taking the spinlock will not be needed most of the time\&. .PP FENCE_FLAG_SIGNALED_BIT \- fence is already signaled FENCE_FLAG_ENABLE_SIGNAL_BIT \- enable_signaling might have been called* FENCE_FLAG_USER_BITS \- start of the unused bits, can be used by the implementer of the fence for its own purposes\&. Can be used in different ways by different fence implementers, so do not rely on this\&. .PP *) Since atomic bitops are used, this is not guaranteed to be the case\&. Particularly, if the bit was set, but fence_signal was called right before this bit was set, it would have been able to set the FENCE_FLAG_SIGNALED_BIT, before enable_signaling was called\&. Adding a check for FENCE_FLAG_SIGNALED_BIT after setting FENCE_FLAG_ENABLE_SIGNAL_BIT closes this race, and makes sure that after fence_signal was called, any enable_signaling call will have either been completed, or never called at all\&. .SH "COPYRIGHT" .br