David Howells
cb65537ee1
Add wait_on_atomic_t() and wake_up_atomic_t()
...
Add wait_on_atomic_t() and wake_up_atomic_t() to indicate became-zero events on
atomic_t types. This uses the bit-wake waitqueue table. The key is set to a
value outside of the number of bits in a long so that wait_on_bit() won't be
woken up accidentally.
What I'm using this for is: in a following patch I add a counter to struct
fscache_cookie to count the number of outstanding operations that need access
to netfs data. The way this works is:
(1) When a cookie is allocated, the counter is initialised to 1.
(2) When an operation wants to access netfs data, it calls atomic_inc_unless()
to increment the counter before it does so. If it was 0, then the counter
isn't incremented, the operation isn't permitted to access the netfs data
(which might by this point no longer exist) and the operation aborts in
some appropriate manner.
(3) When an operation finishes with the netfs data, it decrements the counter
and if it reaches 0, calls wake_up_atomic_t() on it - the assumption being
that it was the last blocker.
(4) When a cookie is released, the counter is decremented and the releaser
uses wait_on_atomic_t() to wait for the counter to become 0 - which should
indicate no one is using the netfs data any longer. The netfs data can
then be destroyed.
There are some alternatives that I have thought of and that have been suggested
by Tejun Heo:
(A) Using wait_on_bit() to wait on a bit in the counter. This doesn't work
because if that bit happens to be 0 then the wait won't happen - even if
the counter is non-zero.
(B) Using wait_on_bit() to wait on a flag elsewhere which is cleared when the
counter reaches 0. Such a flag would be redundant and would add
complexity.
(C) Adding a waitqueue to fscache_cookie - this would expand that struct by
several words for an event that happens just once in each cookie's
lifetime. Further, cookies are generally per-file so there are likely to
be a lot of them.
(D) Similar to (C), but add a pointer to a waitqueue in the cookie instead of
a waitqueue. This would add single word per cookie and so would be less
of an expansion - but still an expansion.
(E) Adding a static waitqueue to the fscache module. Generally this would be
fine, but under certain circumstances many cookies will all get added at
the same time (eg. NFS umount, cache withdrawal) thereby presenting
scaling issues. Note that the wait may be significant as disk I/O may be
in progress.
So, I think reusing the wait_on_bit() waitqueue set is reasonable. I don't
make much use of the waitqueue I need on a per-cookie basis, but sometimes I
have a huge flood of the cookies to deal with.
I also don't want to add a whole new set of global waitqueue tables
specifically for the dec-to-0 event if I can reuse the bit tables.
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-By: Milosz Tanski <milosz@adfin.com>
Acked-by: Jeff Layton <jlayton@redhat.com>
2013-05-15 13:50:38 +01:00
..
cpu
Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
2013-04-30 08:15:40 -07:00
debug
kgdb/sysrq: fix inconstistent help message of sysrq key
2013-04-30 17:04:10 -07:00
events
Merge branch 'timers-nohz-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
2013-05-05 13:23:27 -07:00
gcov
kernel/gcov: remove depends on CONFIG_EXPERIMENTAL
2013-01-11 11:39:33 -08:00
irq
irqdomain: Allow quiet failure mode
2013-05-06 11:37:43 +10:00
power
Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux
2013-05-02 19:40:34 -07:00
sched
Merge branch 'timers-nohz-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
2013-05-05 13:23:27 -07:00
time
Merge branch 'timers-nohz-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
2013-05-05 13:23:27 -07:00
trace
The majority of these changes are from Masami Hiramatsu bringing
2013-05-11 17:04:59 -07:00
.gitignore
kernel/hz.bc: ignore.
2013-04-22 07:09:06 -07:00
acct.c
fs: Fix hang with BSD accounting on frozen filesystem
2013-05-04 14:57:58 -04:00
async.c
async: rename and redefine async_func_ptr
2013-03-12 13:59:14 -07:00
audit.c
Merge git://git.infradead.org/users/eparis/audit
2013-05-11 14:29:11 -07:00
audit.h
Merge git://git.infradead.org/users/eparis/audit
2013-05-11 14:29:11 -07:00
audit_tree.c
kernel/audit_tree.c: tree will leak memory when failure occurs in audit_trim_trees()
2013-04-29 15:54:26 -07:00
audit_watch.c
audit: catch possible NULL audit buffers
2013-01-11 14:54:55 -08:00
auditfilter.c
Merge git://git.infradead.org/users/eparis/audit
2013-05-11 14:29:11 -07:00
auditsc.c
audit: Make testing for a valid loginuid explicit.
2013-05-07 22:27:15 -04:00
backtracetest.c
bounds.c
capability.c
Add file_ns_capable() helper function for open-time capability checking
2013-04-14 10:06:31 -07:00
cgroup.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2013-05-01 17:51:54 -07:00
cgroup_freezer.c
cgroup: rename ->create/post_create/pre_destroy/destroy() to ->css_alloc/online/offline/free()
2012-11-19 08:13:38 -08:00
compat.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal
2013-05-01 07:21:43 -07:00
configs.c
proc: Supply PDE attribute setting accessor functions
2013-05-01 17:29:18 -04:00
context_tracking.c
Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
2013-02-19 18:19:48 -08:00
cpu.c
Merge branch 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
2013-02-19 19:04:55 -08:00
cpu_pm.c
kernel/cpu_pm.c: fix various typos
2012-05-31 17:49:27 -07:00
cpuset.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2013-05-01 17:51:54 -07:00
crash_dump.c
cred.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
2012-12-18 10:55:28 -08:00
delayacct.c
cputime: Use accessors to read task cputime stats
2013-01-27 19:23:31 +01:00
dma.c
elfcore.c
exec_domain.c
exit.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2013-05-01 17:51:54 -07:00
extable.c
extable: Flip the sorting message
2013-04-15 13:25:16 +02:00
fork.c
Merge branch 'for-3.10/drivers' of git://git.kernel.dk/linux-block
2013-05-08 11:51:05 -07:00
freezer.c
freezer: change ptrace_stop/do_signal_stop to use freezable_schedule()
2012-10-26 14:27:49 -07:00
futex.c
futex: fix kernel-doc notation and spello
2013-03-12 20:42:10 -07:00
futex_compat.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal
2013-02-23 18:50:11 -08:00
groups.c
hrtimer.c
Merge branch 'timers-nohz-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
2013-05-05 13:23:27 -07:00
hung_task.c
irq_work.c
Merge branch 'nohz/printk-v8' into irq/core
2013-02-05 00:48:46 +01:00
itimer.c
jump_label.c
jump_label: Export jump_label_rate_limit()
2012-08-06 19:00:35 +03:00
kallsyms.c
kernel: kallsyms: memory override issue, need check destination buffer length
2013-04-15 15:17:26 +09:30
kcmp.c
kcmp: include linux/ptrace.h
2012-12-20 17:40:19 -08:00
Kconfig.freezer
Kconfig.hz
Kconfig.locks
locking: Adjust spin lock inlining Kconfig options
2012-09-13 17:56:13 +02:00
Kconfig.preempt
kexec.c
kexec: Use min() and min_t() to simplify logic
2013-04-30 17:04:07 -07:00
kmod.c
kmod: remove call_usermodehelper_fns()
2013-04-30 17:04:06 -07:00
kprobes.c
kprobes: Fix a double lock bug of kprobe_mutex
2013-04-18 08:58:38 -07:00
ksysfs.c
Merge branch 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
2012-12-11 18:10:49 -08:00
kthread.c
kthread: implement probe_kthread_data()
2013-04-30 17:04:02 -07:00
latencytop.c
lglock.c
brlocks/lglocks: turn into functions
2012-05-29 23:28:41 -04:00
lockdep.c
Merge branch 'for-3.10/drivers' of git://git.kernel.dk/linux-block
2013-05-08 11:51:05 -07:00
lockdep_internals.h
lockdep_proc.c
lockdep: Use KSYM_NAME_LEN'ed buffer for __get_key_name()
2012-10-24 12:39:09 +02:00
lockdep_states.h
Makefile
We get rid of the general module prefix confusion with a binary config option,
2013-05-05 10:58:06 -07:00
modsign_certificate.S
CONFIG_SYMBOL_PREFIX: cleanup.
2013-03-15 15:09:43 +10:30
modsign_pubkey.c
keys: use keyring_alloc() to create module signing keyring
2012-12-20 17:40:21 -08:00
module-internal.h
MODSIGN: Move the magic string to the end of a module and eliminate the search
2012-10-19 17:30:40 -07:00
module.c
module: don't unlink the module until we've removed all exposure.
2013-04-17 13:23:02 +09:30
module_signing.c
MODSIGN: Don't use enum-type bitfields in module signature info block
2012-12-05 11:27:24 +10:30
mutex-debug.c
mutex-debug.h
mutex.c
mutex: Back out architecture specific check for negative mutex count
2013-04-19 09:33:36 +02:00
mutex.h
notifier.c
nsproxy.c
proc: Split the namespace stuff out into linux/proc_ns.h
2013-05-01 17:29:39 -04:00
padata.c
padata: use __this_cpu_read per-cpu helper
2012-12-06 17:16:23 +08:00
panic.c
dump_stack: implement arch-specific hardware description in task dumps
2013-04-30 17:04:02 -07:00
params.c
params: Fix potential memory leak in add_sysfs_param()
2013-03-18 11:40:21 +00:00
pid.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2013-05-01 17:51:54 -07:00
pid_namespace.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2013-05-01 17:51:54 -07:00
posix-cpu-timers.c
posix_timers: Fix pre-condition to stop the tick on full dynticks
2013-04-22 19:59:25 +02:00
posix-timers.c
posix-timers: Remove unused variable
2013-04-18 12:51:19 +02:00
printk.c
aio: don't include aio.h in sched.h
2013-05-07 20:16:25 -07:00
profile.c
proc: Supply PDE attribute setting accessor functions
2013-05-01 17:29:18 -04:00
ptrace.c
aio: don't include aio.h in sched.h
2013-05-07 20:16:25 -07:00
range.c
kernel/range.c: subtract_range: fix the broken phrase issued by printk
2013-04-30 17:04:01 -07:00
rcu.h
rcu: Provide RCU CPU stall warnings for tiny RCU
2013-01-28 22:06:21 -08:00
rcupdate.c
Merge branches 'doctorture.2013.01.29a', 'fixes.2013.01.26a', 'tagcb.2013.01.24a' and 'tiny.2013.01.29b' into HEAD
2013-01-28 22:25:21 -08:00
rcutiny.c
Merge branches 'doctorture.2013.01.29a', 'fixes.2013.01.26a', 'tagcb.2013.01.24a' and 'tiny.2013.01.29b' into HEAD
2013-01-28 22:25:21 -08:00
rcutiny_plugin.h
rcu: Provide RCU CPU stall warnings for tiny RCU
2013-01-28 22:06:21 -08:00
rcutorture.c
rcu: Allow rcutorture to be built at low optimization levels
2013-02-04 12:18:20 -08:00
rcutree.c
Merge commit ' 8700c95adb' into timers/nohz
2013-05-02 17:54:19 +02:00
rcutree.h
Merge commit ' 8700c95adb' into timers/nohz
2013-05-02 17:54:19 +02:00
rcutree_plugin.h
Merge branch 'timers-nohz-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
2013-05-05 13:23:27 -07:00
rcutree_trace.c
rcutrace: single_open() leaks
2013-05-05 00:16:35 -04:00
relay.c
Merge branch 'for-3.10/core' of git://git.kernel.dk/linux-block
2013-05-08 10:13:35 -07:00
res_counter.c
res_counter: return amount of charges after res_counter_uncharge()
2012-12-18 15:02:12 -08:00
resource.c
mem hotunplug: fix kfree() of bootmem memory
2013-04-29 15:54:40 -07:00
rtmutex-debug.c
sched/rt: Move rt specific bits into new header file
2013-02-07 20:51:08 +01:00
rtmutex-debug.h
rtmutex-tester.c
locking/rtmutex/tester: Set correct permissions on sysfs files
2013-04-10 14:48:37 +02:00
rtmutex.c
sched/rt: Move rt specific bits into new header file
2013-02-07 20:51:08 +01:00
rtmutex.h
rtmutex_common.h
rwsem.c
Revert "rw_semaphore: remove up/down_read_non_owner"
2013-03-23 15:53:52 -07:00
seccomp.c
seccomp: allow BPF_XOR based ALU instructions.
2013-03-26 11:07:19 +11:00
semaphore.c
semaphore: use `bool' type for semaphore_waiter's up
2013-04-30 17:04:08 -07:00
signal.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
2013-05-01 14:08:52 -07:00
smp.c
kernel/smp.c: cleanups
2013-04-30 17:04:03 -07:00
smpboot.c
kthread: Prevent unpark race which puts threads on the wrong cpu
2013-04-12 14:18:43 +02:00
smpboot.h
smpboot: Provide infrastructure for percpu hotplug threads
2012-08-13 17:01:07 +02:00
softirq.c
Merge branch 'timers-nohz-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
2013-05-05 13:23:27 -07:00
spinlock.c
srcu.c
srcu: use ACCESS_ONCE() to access sp->completed in srcu_read_lock()
2013-02-07 15:19:36 -08:00
stacktrace.c
stop_machine.c
stop_machine: Mark per cpu stopper enabled early
2013-02-26 22:25:17 +01:00
sys.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal
2013-05-01 07:21:43 -07:00
sys_ni.c
unify compat fanotify_mark(2), switch to COMPAT_SYSCALL_DEFINE
2013-05-09 13:46:38 -04:00
sysctl.c
mm: replace hardcoded 3% with admin_reserve_pages knob
2013-04-29 15:54:36 -07:00
sysctl_binary.c
switch compat_sys_sysctl to COMPAT_SYSCALL_DEFINE
2013-05-09 14:53:20 -04:00
task_work.c
task_work: task_work_add() should not succeed after exit_task_work()
2012-09-13 16:47:34 +02:00
taskstats.c
taskstats: cgroupstats_user_cmd() may leak on error
2012-10-06 03:05:31 +09:00
test_kprobes.c
kernel/: rename random32() to prandom_u32()
2013-04-29 18:28:42 -07:00
time.c
timekeeping: Use inject_offset in warp_clock
2013-03-15 16:50:20 -07:00
timeconst.bc
kernel: Replace timeconst.pl with a bc script
2013-02-16 23:17:25 +01:00
timer.c
Merge branch 'timers-nohz-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
2013-05-05 13:23:27 -07:00
tracepoint.c
Tracing updates for Linux 3.10
2013-04-29 13:55:38 -07:00
tsacct.c
cputime: Use accessors to read task cputime stats
2013-01-27 19:23:31 +01:00
uid16.c
make SYSCALL_DEFINE<n>-generated wrappers do asmlinkage_protect
2013-03-03 22:58:33 -05:00
up.c
user-return-notifier.c
hlist: drop the node parameter from iterators
2013-02-27 19:10:24 -08:00
user.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2013-05-01 17:51:54 -07:00
user_namespace.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2013-05-01 17:51:54 -07:00
utsname.c
proc: Split the namespace stuff out into linux/proc_ns.h
2013-05-01 17:29:39 -04:00
utsname_sysctl.c
kernel/utsname_sysctl.c: put get/get_uts() into CONFIG_PROC_SYSCTL code block
2013-02-27 19:10:22 -08:00
wait.c
Add wait_on_atomic_t() and wake_up_atomic_t()
2013-05-15 13:50:38 +01:00
watchdog.c
watchdog: Add comments to explain the watchdog_disabled variable
2013-03-14 08:24:05 +01:00
workqueue.c
workqueue: workqueue_congested() shouldn't translate WORK_CPU_UNBOUND into node number
2013-05-10 11:10:17 -07:00
workqueue_internal.h
workqueue: include workqueue info when printing debug dump of a worker task
2013-04-30 17:04:02 -07:00