Skip to contentSkip to conversation

shmctl(SHM_LOCK/UNLOCK) deadlock

PATCH Andrea Arcangeli 1 participant 1 message Jun 4, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

this patch fixes an SMP deadlock that triggered in some production usage:

mm/shmem.c renamed from mm/shmem.c.~1~ +2 -2
@@ -808,9 +808,9 @@ void shmem_lock(struct file * file, int 
 	struct inode * inode = file->f_dentry->d_inode;
 	struct shmem_inode_info * info = SHMEM_I(inode);
 
-	down(&info->sem);
+	spin_lock(&info->lock);
 	info->locked = lock;
-	up(&info->sem);
+	spin_unlock(&info->lock);
 }
 
 int shmem_make_bigpage_mmap(struct file * file, struct vm_area_struct * vma)

you can merge it in 21-final IMHO (even dropping the lock enterely would been ok, the reader is out of order anyways and that's atomic stuff in C no matter the architecture)

Andrea