'\" t .\" Title: del_timer_sync .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: January 2017 .\" Manual: Driver Basics .\" Source: Kernel Hackers Manual 4.8.15 .\" Language: English .\" .TH "DEL_TIMER_SYNC" "9" "January 2017" "Kernel Hackers Manual 4\&.8\&." "Driver Basics" .\" ----------------------------------------------------------------- .\" * 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" del_timer_sync \- deactivate a timer and wait for the handler to finish\&. .SH "SYNOPSIS" .HP \w'int\ del_timer_sync('u .BI "int del_timer_sync(struct\ timer_list\ *\ " "timer" ");" .SH "ARGUMENTS" .PP \fItimer\fR .RS 4 the timer to be deactivated .RE .SH "DESCRIPTION" .PP This function only differs from \fBdel_timer\fR on SMP: besides deactivating the timer it also makes sure the handler has finished executing on other CPUs\&. .PP Synchronization rules: Callers must prevent restarting of the timer, otherwise this function is meaningless\&. It must not be called from interrupt contexts unless the timer is an irqsafe one\&. The caller must not hold locks which would prevent completion of the timer\*(Aqs handler\&. The timer\*(Aqs handler must not call \fBadd_timer_on\fR\&. Upon exit the timer is not queued and the handler is not running on any CPU\&. .SH "NOTE" .PP For !irqsafe timers, you must not hold locks that are held in interrupt context while calling this function\&. Even if the lock has nothing to do with the timer in question\&. Here\*(Aqs why: .PP CPU0 CPU1 \-\-\-\- \-\-\-\- \fBcall_timer_fn\fR; base\->running_timer = mytimer; spin_lock_irq(somelock); spin_lock(somelock); del_timer_sync(mytimer); while (base\->running_timer == mytimer); .PP Now \fBdel_timer_sync\fR will never return and never release somelock\&. The interrupt on the other CPU is waiting to grab somelock but it has interrupted the softirq that CPU0 is waiting to finish\&. .PP The function returns whether it has deactivated a pending timer or not\&. .SH "COPYRIGHT" .br