Patch "ipc/sem.c: update sem_otime for all operations" has been added to the 3.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ipc/sem.c: update sem_otime for all operations

to the 3.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ipc-sem.c-update-sem_otime-for-all-operations.patch
and it can be found in the queue-3.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From 0e8c665699e953fa58dc1b0b0d09e5dce7343cc7 Mon Sep 17 00:00:00 2001
From: Manfred Spraul <manfred@xxxxxxxxxxxxxxxx>
Date: Mon, 30 Sep 2013 13:45:25 -0700
Subject: ipc/sem.c: update sem_otime for all operations

From: Manfred Spraul <manfred@xxxxxxxxxxxxxxxx>

commit 0e8c665699e953fa58dc1b0b0d09e5dce7343cc7 upstream.

In commit 0a2b9d4c7967 ("ipc/sem.c: move wake_up_process out of the
spinlock section"), the update of semaphore's sem_otime(last semop time)
was moved to one central position (do_smart_update).

But since do_smart_update() is only called for operations that modify
the array, this means that wait-for-zero semops do not update sem_otime
anymore.

The fix is simple:
Non-alter operations must update sem_otime.

[akpm@xxxxxxxxxxxxxxxxxxxx: coding-style fixes]
Signed-off-by: Manfred Spraul <manfred@xxxxxxxxxxxxxxxx>
Reported-by: Jia He <jiakernel@xxxxxxxxx>
Tested-by: Jia He <jiakernel@xxxxxxxxx>
Cc: Davidlohr Bueso <davidlohr.bueso@xxxxxx>
Cc: Mike Galbraith <efault@xxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
 ipc/sem.c |   42 +++++++++++++++++++++++++++++-------------
 1 file changed, 29 insertions(+), 13 deletions(-)

--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -918,6 +918,24 @@ again:
 }
 
 /**
+ * set_semotime(sma, sops) - set sem_otime
+ * @sma: semaphore array
+ * @sops: operations that modified the array, may be NULL
+ *
+ * sem_otime is replicated to avoid cache line trashing.
+ * This function sets one instance to the current time.
+ */
+static void set_semotime(struct sem_array *sma, struct sembuf *sops)
+{
+	if (sops == NULL) {
+		sma->sem_base[0].sem_otime = get_seconds();
+	} else {
+		sma->sem_base[sops[0].sem_num].sem_otime =
+							get_seconds();
+	}
+}
+
+/**
  * do_smart_update(sma, sops, nsops, otime, pt) - optimized update_queue
  * @sma: semaphore array
  * @sops: operations that were performed
@@ -967,17 +985,10 @@ static void do_smart_update(struct sem_a
 			}
 		}
 	}
-	if (otime) {
-		if (sops == NULL) {
-			sma->sem_base[0].sem_otime = get_seconds();
-		} else {
-			sma->sem_base[sops[0].sem_num].sem_otime =
-								get_seconds();
-		}
-	}
+	if (otime)
+		set_semotime(sma, sops);
 }
 
-
 /* The following counts are associated to each semaphore:
  *   semncnt        number of tasks waiting on semval being nonzero
  *   semzcnt        number of tasks waiting on semval being zero
@@ -1839,12 +1850,17 @@ SYSCALL_DEFINE4(semtimedop, int, semid,
 
 	error = perform_atomic_semop(sma, sops, nsops, un,
 					task_tgid_vnr(current));
-	if (error <= 0) {
-		if (alter && error == 0)
+	if (error == 0) {
+		/* If the operation was successful, then do
+		 * the required updates.
+		 */
+		if (alter)
 			do_smart_update(sma, sops, nsops, 1, &tasks);
-
-		goto out_unlock_free;
+		else
+			set_semotime(sma, sops);
 	}
+	if (error <= 0)
+		goto out_unlock_free;
 
 	/* We need to sleep on this operation, so we put the current
 	 * task into the pending queue and go to sleep.


Patches currently in stable-queue which might be from manfred@xxxxxxxxxxxxxxxx are

queue-3.10/ipc-drop-ipc_lock_by_ptr.patch
queue-3.10/ipc-sem.c-synchronize-the-proc-interface.patch
queue-3.10/ipc-msg-drop-msg_unlock.patch
queue-3.10/ipc-fix-race-with-lsms.patch
queue-3.10/ipc-shm-shorten-critical-region-in-shmctl_down.patch
queue-3.10/ipc-rename-ids-rw_mutex.patch
queue-3.10/ipc-msg.c-fix-lost-wakeup-in-msgsnd.patch
queue-3.10/ipc-shm-introduce-lockless-functions-to-obtain-the-ipc-object.patch
queue-3.10/ipc-sem.c-optimize-sem_lock.patch
queue-3.10/ipc-shm-shorten-critical-region-for-shmat.patch
queue-3.10/ipc-sem.c-fix-race-in-sem_lock.patch
queue-3.10/ipc-sem-separate-wait-for-zero-and-alter-tasks-into-seperate-queues.patch
queue-3.10/ipc-shm-shorten-critical-region-for-shmctl.patch
queue-3.10/ipc-shm-introduce-shmctl_nolock.patch
queue-3.10/ipc-drop-ipcctl_pre_down.patch
queue-3.10/ipc-document-general-ipc-locking-scheme.patch
queue-3.10/ipc-util.c-ipc_rcu_alloc-cacheline-align-allocation.patch
queue-3.10/ipc-shm-drop-shm_lock_check.patch
queue-3.10/ipc-sem.c-cacheline-align-the-semaphore-structures.patch
queue-3.10/ipc-msg-prevent-race-with-rmid-in-msgsnd-msgrcv.patch
queue-3.10/ipc-shm-guard-against-non-existant-vma-in-shmdt-2.patch
queue-3.10/ipc-sem.c-always-use-only-one-queue-for-alter-operations.patch
queue-3.10/ipc-shm-cleanup-do_shmat-pasta.patch
queue-3.10/ipc-drop-ipc_lock_check.patch
queue-3.10/ipc-sem.c-update-sem_otime-for-all-operations.patch
queue-3.10/ipc-sem.c-rename-try_atomic_semop-to-perform_atomic_semop-docu-update.patch
queue-3.10/ipc-shm-make-shmctl_nolock-lockless.patch
queue-3.10/ipc-sem.c-replace-shared-sem_otime-with-per-semaphore-value.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]