From 7bd92180e74fab8260b697c4de1f4bfe36a17a4a Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 2 Jun 2009 06:55:32 +0000 Subject: - Use an acquire barrier to increment f_count in fget_unlocked and remove the volatile cast. Describe the reason in detail in a comment. Discussed with: bde, jhb --- sys/kern/kern_descrip.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sys/kern/kern_descrip.c') diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index c93d05a..1221825 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -2075,9 +2075,13 @@ fget_unlocked(struct filedesc *fdp, int fd) count = fp->f_count; if (count == 0) continue; - if (atomic_cmpset_int(&fp->f_count, count, count + 1) != 1) + /* + * Use an acquire barrier to prevent caching of fd_ofiles + * so it is refreshed for verification. + */ + if (atomic_cmpset_acq_int(&fp->f_count, count, count + 1) != 1) continue; - if (fp == ((struct file *volatile*)fdp->fd_ofiles)[fd]) + if (fp == fdp->fd_ofiles[fd]) break; fdrop(fp, curthread); } -- cgit v1.1