[patch 14/21] Change printk to use OMBUG macro

Florian Delizy <[email protected]> Wed, 01 Nov 2006 05:11:44 +0100
Newsgroups gmane.linux.cluster.openmosix.devel
Message-ID <[email protected]>
changed printk( KERN_ERR * into OMBUG macro call ...
added a stack dump on the OMBUG as well ...

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
openMosix-devel mailing list
openMosix-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/openmosix-devel
use-ombug-macro.patch (text/x-patch, 7 KB)
Subject: [patch @num@/@total@] Change printk to use OMBUG macro

changed printk( KERN_ERR * into OMBUG macro call ... 
added a stack dump on the OMBUG as well ... 

Index: linux/hpc/migrecv.c
===================================================================
--- linux.orig/hpc/migrecv.c	2006-10-26 16:11:43.000000000 +0200
+++ linux/hpc/migrecv.c	2006-10-27 22:09:51.000000000 +0200
@@ -501,7 +501,7 @@
 		OMDEBUG_MIG( 3, "%s:%d pid %d waiting kcomd to do his work ! %d HZ\n", __FUNCTION__, __LINE__, p->pid, waiting_time);
 		/* Preventing infinite loops */
 		if ( 60 < waiting_time ) {
-			printk( KERN_ERR "openMosix: kcomd task creation timeout exceeded, dying ... \n" );
+			OMBUG("kcomd task creation timeout exceeded, dying ... \n" );
 			ret = -1;
 			goto protocol_exit;
 		}
@@ -564,7 +564,7 @@
 					break;
 
 				default:
-					printk(KERN_ERR "openMosix: (receive) [pid: %u] Unknown packet type 0x%x received.\n", p->pid, pkt->type);
+					OMBUG("(receive) [pid: %u] Unknown packet type 0x%x received.\n", p->pid, pkt->type);
 
 					ret = -1; /* Should exit on unknown packet !! */
 					break;
@@ -636,7 +636,7 @@
 	arch_kickstart(p);
 	/*NOTREACHED*/
 
-	printk(KERN_ERR "process %u, waking up. YOU SHOULD NOT SEE THIS!!!!!\n", p->pid);
+	OMBUG("process %u, waking up. YOU SHOULD NOT SEE THIS!!!!!\n", p->pid);
 	while (1) {
 		set_current_state(TASK_INTERRUPTIBLE);
 		schedule();
@@ -644,7 +644,7 @@
 
 
 fail:
-	printk(KERN_ERR "mig_handle_migration failed with %d\n", error);
+	OMBUG(KERN_ERR "mig_handle_migration failed with %d\n", error);
 	OMBUG("failed\n");
 	do_exit(SIGKILL);
 	/*NOTREACHED*/
Index: linux/include/hpc/prototype.h
===================================================================
--- linux.orig/include/hpc/prototype.h	2006-10-26 16:15:00.000000000 +0200
+++ linux/include/hpc/prototype.h	2006-10-27 21:55:12.000000000 +0200
@@ -20,13 +20,18 @@
 #ifndef _HPC_PROTOTYPE_H
 #define _HPC_PROTOTYPE_H
 
+#include <linux/kernel.h>
+
 #ifdef CONFIG_OPENMOSIX_MIGRATION_VERBOSE
 #define OM_VERBOSE_MIG(fmt...)	printk(KERN_NOTICE fmt)
 #else
 #define OM_VERBOSE_MIG(fmt...)	do { } while (0)
 #endif
 
-#define OMBUG(f, a...)	printk(KERN_ERR "[OMBUG] %s: " f, __FUNCTION__, ## a)
+#define OMBUG(f, a...)	do { \
+			    printk(KERN_ERR "[OMBUG] %s: " f, __FUNCTION__, ## a); \
+			    dump_stack(); \
+			} while (0)
 
 #include <linux/in.h>
 #include <hpc/kcom.h>
@@ -91,6 +96,7 @@
 
 struct kcom_pkt *kcom_pkt_create(int, int, int, char *);
 
+int kcom_add_packet( struct kcom_task *tsk, struct kcom_pkt *pkt );
 int kcom_send(int, int, char *, unsigned long, struct sockaddr_in *);
 int kcom_send_with_ack(int, int, char *, unsigned long, struct sockaddr_in *);
 int kcom_send_with_response(int, int, char *, unsigned long, char *, struct sockaddr_in *);
Index: linux/hpc/kcomd.c
===================================================================
--- linux.orig/hpc/kcomd.c	2006-10-26 16:27:05.000000000 +0200
+++ linux/hpc/kcomd.c	2006-10-27 22:10:11.000000000 +0200
@@ -124,7 +124,7 @@
 
 	sock = sock_alloc();
 	if (!sock) {
-		printk(KERN_ERR "openMosix: Unable to allocate socket.\n");
+		OMBUG("openMosix: Unable to allocate socket.\n");
 		return -1;
 	}
 
@@ -133,7 +133,7 @@
 
 	ret = lsock->ops->accept(lsock, sock, 0);
 	if (ret) {
-		printk(KERN_ERR "openMosix: Error accepting connection\n");
+		OMBUG("openMosix: Error accepting connection\n");
 		goto err_accept;
 	}
 
@@ -143,13 +143,13 @@
 
 	fd = sock_map_fd(sock);
 	if (fd < 0) {
-		printk(KERN_ERR "openMosix: Error mapping socket to file descriptor\n");
+		OMBUG("openMosix: Error mapping socket to file descriptor\n");
 		goto err_accept;
 	}
 
 	node = kcom_node_add(sock);
 	if (node==NULL) {
-		printk(KERN_ERR "openMosix: Error adding new node\n");
+		OMBUG("openMosix: Error adding new node\n");
 		goto errfd;
 	}
 	// Store the IP addr.
@@ -197,13 +197,13 @@
 	while (iov.iov_len > 0) {
 		i = sock_sendmsg(sock, &msg, iov.iov_len);
 		if ((i == -ENOSPC) || (i == -EAGAIN)) {
-			printk(KERN_ERR "Retrying hdr...error %d\n", i);
+			OMBUG("Retrying hdr...error %d\n", i);
 			schedule_timeout(HZ/1000);
 			continue;
 		}
 		if (i == -EFAULT) {
-			printk(KERN_ERR "Error %d sending data. Unable to access data.\n", i);
-			printk(KERN_ERR "Data may need to be copied into a temporary buffer to be sent.\n");
+			OMBUG("Error %d sending data. Unable to access data.\n", i);
+			OMBUG("Data may need to be copied into a temporary buffer to be sent.\n");
 		}
 
 		if (i < 0) {
@@ -236,7 +236,7 @@
 			continue;
 		}
 		if (i < 0) {
-			printk(KERN_ERR"openMosix: ERROR %d sending data\n", i);
+			OMBUG("openMosix: ERROR %d sending data\n", i);
 			set_fs(oldfs);
 			return -1;
 		}
@@ -293,7 +293,7 @@
 			list_add_tail(&recv_kcom_pkt->list, &tsk->in_packs);
 			write_unlock( &tsk->in_packs_lock );
 		} else {
-			printk(KERN_ERR "unable to find remote pid %u\n", recv_kcom_pkt->rpid);
+			OMBUG("unable to find remote pid %u\n", recv_kcom_pkt->rpid);
 			return -1;
 
 		}
@@ -303,7 +303,7 @@
 		if (sltsk) {
 			wake_up_process(sltsk);
 		} else {
-			printk(KERN_ERR "Unable to find remote pid %u to wake up\n", recv_kcom_pkt->rpid);
+			OMBUG("Unable to find remote pid %u to wake up\n", recv_kcom_pkt->rpid);
 			return -1;
 		}
 
@@ -314,7 +314,7 @@
 			list_add_tail(&recv_kcom_pkt->list, &tsk->in_packs);
 			write_unlock( &tsk->in_packs_lock );
 		} else {
-			printk(KERN_ERR "unable to find home pid %u\n", recv_kcom_pkt->hpid);
+			OMBUG("unable to find home pid %u\n", recv_kcom_pkt->hpid);
 			return -1;
 		}
 		read_lock(&tasklist_lock);
@@ -323,7 +323,7 @@
 		if (sltsk) {
 			wake_up_process(sltsk);
 		} else {
-			printk(KERN_ERR "Unable to find home pid %u to wake up\n", recv_kcom_pkt->hpid);
+			OMBUG("Unable to find home pid %u to wake up\n", recv_kcom_pkt->hpid);
 			return -1;
 		}
 	}
@@ -363,7 +363,7 @@
 		}
 
 		if (i < recv_kcom_pkt->len) {
-			printk(KERN_ERR "ERROR: incomplete data pkt\n");
+			OMBUG("ERROR: incomplete data pkt\n");
 			goto error_recv;
 		}
 	}
@@ -385,7 +385,7 @@
 				OMDEBUG_KCOMD(2, "KCOMD: %s:%d it's a MIG_COME_HOME packet ... \n", __FUNCTION__, __LINE__ );
 				sltsk = find_task_by_pid(recv_kcom_pkt->rpid);
 				if ( !sltsk ) {
-				    printk( KERN_ERR "openMosix: %s Unable to find the task %d ", __FUNCTION__, recv_kcom_pkt->rpid );
+				    OMBUG("openMosix: %s Unable to find the task %d\n", __FUNCTION__, recv_kcom_pkt->rpid );
 				    goto error_recv;
 				}
 				task_register_migration(sltsk);
@@ -486,7 +486,6 @@
 
 	read_lock( &kcom_nodes_lock );
 	list_for_each_entry(node, &kcom_nodes, list) {
-		/* printk("node->fd=%d\n", node->fd);*/
 
 		if (node->fd == -1 || node->fd > maxfds) {
 			read_unlock( &kcom_nodes_lock );
@@ -589,7 +588,6 @@
 	daemonize("kcomd", 0);
 	sigfillset(&current->blocked);
 
-	/* kcom_pid=current->pid;*/
 	kcomd_task=current;
 
 retry_listen:
@@ -667,7 +665,7 @@
 			if (test_bit(node->fd, sockets_fds.res_in)) {
 				err=pkt_read(node);
 				if (err!=0) {
-					OMBUG(KERN_ERR "ERROR receiving data => ignoring packet.\n");
+					OMBUG("ERROR receiving data => ignoring packet.\n");
 					continue;
 				}
 			}