From d34fdaccd8fa40b84419d1315c68490b105c0e0a Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Wed, 5 May 2004 20:40:22 +0000
Subject: [PATCH] Add ptrace kernel patch required for TotalView and update
 documentation to match.

---
 Makefile.am                    |  1 +
 doc/html/quickstart_admin.html |  8 +++++---
 etc/ptrace.patch               | 22 ++++++++++++++++++++++
 src/slurmd/smgr.c              |  5 ++---
 4 files changed, 30 insertions(+), 6 deletions(-)
 create mode 100644 etc/ptrace.patch

diff --git a/Makefile.am b/Makefile.am
index 034797d74d1..6a9c0f625ae 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,6 +8,7 @@ EXTRA_DIST =			\
 	Make-rpm.mk		\
 	etc/slurm.conf.example	\
 	etc/init.d.slurm	\
+	etc/ptrace.patch	\
 	autogen.sh		\
 	slurm.spec		\
 	README			\
diff --git a/doc/html/quickstart_admin.html b/doc/html/quickstart_admin.html
index 51a2fb6433e..89f3347d4fb 100644
--- a/doc/html/quickstart_admin.html
+++ b/doc/html/quickstart_admin.html
@@ -9,7 +9,7 @@
 <meta http-equiv="keywords" content="Simple Linux Utility for Resource Management, SLURM, resource management, 
 Linux clusters, high-performance computing, Livermore Computing">
 <meta name="LLNLRandR" content="UCRL-WEB-201790">
-<meta name="LLNLRandRdate" content="2 May 2004">
+<meta name="LLNLRandRdate" content="5 May 2004">
 <meta name="distribution" content="global">
 <meta name="description" content="Simple Linux Utility for Resource Management">
 <meta name="copyright"
@@ -123,7 +123,9 @@ Install architecture-independent files in PREFIX; default value is /usr/local.</
 </i> 
 Specify location of SLURM configuration file.</p>
 <p style="margin-left:.2in"><span class="commandline">--with-totalview</span><br>
-Compile with support for the TotalView debugger (see <a href="http://www.etnus.com/">http://www.etnus.com</a>).</p>
+Compile with support for the TotalView debugger 
+(see <a href="http://www.etnus.com/">http://www.etnus.com</a>).
+The kernel patch in <b>etc/ptrace.patch</b> may also be required.</p>
 <p class="footer"><a href="#top">top</a></p>
 <h3>Configuration</h3>
 <p>The SLURM configuration file includes a wide variety of parameters. 
@@ -352,7 +354,7 @@ adev0: scontrol shutdown
 <td colspan="3"><hr> <p>For information about this page, contact <a href="mailto:slurm-dev@lists.llnl.gov">slurm-dev@lists.llnl.gov</a>.</p>
 <p><a href="http://www.llnl.gov/"><img align=middle src="lll.gif" width="32" height="32" border="0"></a></p>
 <p class="footer">UCRL-WEB-201790<br>
-Last modified 2 May 2004</p></td>
+Last modified 5 May 2004</p></td>
 </tr>
 </table>
 </td>
diff --git a/etc/ptrace.patch b/etc/ptrace.patch
new file mode 100644
index 00000000000..c72e329eb27
--- /dev/null
+++ b/etc/ptrace.patch
@@ -0,0 +1,22 @@
+Without this change TotalView will not operate properly with 
+SLURM launched jobs. We want the tasks to be in a STOPPED 
+state and detached from the slurmd daemon. The default 
+code leaves an extra SIGSTOP pending. Any time the task is 
+allowed to process pending signals, it will be stopped again
+and confuse TotalView.
+===============================================================
+--- ptrace.c    18 Sep 2003 23:50:00 -0000      1.3.2.1.4.1
++++ ptrace.c    22 Mar 2004 19:58:29 -0000
+@@ -113,7 +113,10 @@ int ptrace_attach(struct task_struct *ta
+        __ptrace_link(task, current);
+        write_unlock_irq(&tasklist_lock);
+
+-       force_sig_specific(SIGSTOP, task);
++       if (task->state != TASK_STOPPED)
++               force_sig_specific(SIGSTOP, task);
++       else
++               task->exit_code = SIGSTOP;
+        return 0;
+
+ bad:
+===============================================================
diff --git a/src/slurmd/smgr.c b/src/slurmd/smgr.c
index dab143abaae..ec4d148e3cb 100644
--- a/src/slurmd/smgr.c
+++ b/src/slurmd/smgr.c
@@ -554,9 +554,8 @@ _pdebug_trace_process(slurmd_job_t *job, pid_t pid)
 	/*  If task to be debugged, wait for it to stop via
 	 *  child's ptrace(PTRACE_TRACEME), then SIGSTOP, and 
 	 *  ptrace(PTRACE_DETACH). This requires a kernel patch,
-	 *  which you probably already have in place for TotalView:
-	 *  http://hypermail.idiosynkrasia.net
-	 *        /linux-kernel/archived/2001/week51/1193.html 
+	 *  which you may already have in place for TotalView.
+	 *  If not, apply the kernel patch in etc/ptrace.patch
 	 */
 
 	if (job->task_flags & TASK_TOTALVIEW_DEBUG) {
-- 
GitLab