All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauricio Lin <mauriciolin@gmail.com>
To: Marcelo Tosatti <marcelo.tosatti@cyclades.com>
Cc: Edjard Souza Mota <edjard@gmail.com>,
	linux-kernel@vger.kernel.org, akpm@osdl.org
Subject: Re: User space out of memory approach
Date: Mon, 10 Jan 2005 19:30:53 -0400	[thread overview]
Message-ID: <3f250c71050110153031825ba3@mail.gmail.com> (raw)
In-Reply-To: <3f250c71050110152421e83e04@mail.gmail.com>

Hi all,

I noticed something wrong with the first patch. Here goes the fixed patch:

***********
PATCH
***********

diff -urN linux-2.6.10/fs/proc/array.c linux-2.6.10-oom/fs/proc/array.c
--- linux-2.6.10/fs/proc/array.c	2004-12-24 17:35:00.000000000 -0400
+++ linux-2.6.10-oom/fs/proc/array.c	2005-01-10 15:42:26.000000000 -0400
@@ -470,3 +470,13 @@
 	return sprintf(buffer,"%d %d %d %d %d %d %d\n",
 		       size, resident, shared, text, lib, data, 0);
 }
+
+int proc_pid_oom(struct task_struct *task, char * buffer)
+{
+	int res;
+	res = sprintf(buffer, "%d %lu %lu\n",
+		      task->pid,
+		      task->utime,
+		      task->stime);
+	return res;
+}
diff -urN linux-2.6.10/fs/proc/base.c linux-2.6.10-oom/fs/proc/base.c
--- linux-2.6.10/fs/proc/base.c	2004-12-24 17:35:00.000000000 -0400
+++ linux-2.6.10-oom/fs/proc/base.c	2005-01-10 15:42:26.000000000 -0400
@@ -60,6 +60,7 @@
 	PROC_TGID_MAPS,
 	PROC_TGID_MOUNTS,
 	PROC_TGID_WCHAN,
+	PROC_TGID_OOM,
 #ifdef CONFIG_SCHEDSTATS
 	PROC_TGID_SCHEDSTAT,
 #endif
@@ -86,6 +87,7 @@
 	PROC_TID_MAPS,
 	PROC_TID_MOUNTS,
 	PROC_TID_WCHAN,
+	PROC_TID_OOM,
 #ifdef CONFIG_SCHEDSTATS
 	PROC_TID_SCHEDSTAT,
 #endif
@@ -132,6 +134,7 @@
 #ifdef CONFIG_SCHEDSTATS
 	E(PROC_TGID_SCHEDSTAT, "schedstat", S_IFREG|S_IRUGO),
 #endif
+	E(PROC_TGID_OOM,       "oom", S_IFREG|S_IRUGO),
 	{0,0,NULL,0}
 };
 static struct pid_entry tid_base_stuff[] = {
@@ -157,6 +160,7 @@
 #ifdef CONFIG_SCHEDSTATS
 	E(PROC_TID_SCHEDSTAT, "schedstat",S_IFREG|S_IRUGO),
 #endif
+	E(PROC_TID_OOM,       "oom", S_IFREG|S_IRUGO),
 	{0,0,NULL,0}
 };
 
@@ -193,6 +197,7 @@
 int proc_tgid_stat(struct task_struct*,char*);
 int proc_pid_status(struct task_struct*,char*);
 int proc_pid_statm(struct task_struct*,char*);
+int proc_pid_oom(struct task_struct*,char*);
 
 static int proc_fd_link(struct inode *inode, struct dentry **dentry,
struct vfsmount **mnt)
 {
@@ -1377,6 +1382,11 @@
 			ei->op.proc_read = proc_pid_schedstat;
 			break;
 #endif
+		case PROC_TID_OOM:
+		case PROC_TGID_OOM:
+			inode->i_fop = &proc_info_file_operations;
+			ei->op.proc_read = proc_pid_oom;
+			break;
 		default:
 			printk("procfs: impossible type (%d)",p->type);
 			iput(inode);
diff -urN linux-2.6.10/include/linux/oom_kill.h
linux-2.6.10-oom/include/linux/oom_kill.h
--- linux-2.6.10/include/linux/oom_kill.h	1969-12-31 20:00:00.000000000 -0400
+++ linux-2.6.10-oom/include/linux/oom_kill.h	2005-01-10
15:42:26.000000000 -0400
@@ -0,0 +1,6 @@
+struct candidate_process {
+	pid_t pid;
+	struct list_head pid_list;
+};
+
+struct list_head *loop_counter;
diff -urN linux-2.6.10/mm/oom_kill.c linux-2.6.10-oom/mm/oom_kill.c
--- linux-2.6.10/mm/oom_kill.c	2004-12-24 17:34:57.000000000 -0400
+++ linux-2.6.10-oom/mm/oom_kill.c	2005-01-10 17:56:34.000000000 -0400
@@ -13,13 +13,26 @@
  *  machine) this file will double as a 'coding guide' and a signpost
  *  for newbie kernel hackers. It features several pointers to major
  *  kernel subsystems and hints as to where to find out what things do.
+ *
+ *
+ *  2005
+ *  Bruna Moreira <bruna.moreira@indt.org.br>
+ *  Edjard Mota <edjard.mota@indt.org.br>
+ *  Ilias Biris <ext-ilias.biris@indt.org.br>
+ *  Mauricio Lin <mauricio.lin@indt.org.br>
+ * 
+ *  Embedded Linux Lab - 10LE Institulo Nokia de Tecnologia - INdT 
+ *
+ *  Turn off the kernel space out of memory killer algorithm and provide
+ *  support for user space out of memory killer.
  */
-
+#include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/swap.h>
 #include <linux/timex.h>
 #include <linux/jiffies.h>
+#include <linux/oom_kill.h>
 
 /* #define DEBUG */
 
@@ -42,6 +55,57 @@
  *    of least surprise ... (be careful when you change it)
  */
 
+struct candidate_process *candidate;
+
+EXPORT_SYMBOL(candidate);
+
+LIST_HEAD(pidqueue_head);
+
+EXPORT_SYMBOL(pidqueue_head);
+/*
+void show_candidate_comm(void)
+{
+	struct task_struct *g, *p;
+	int i = 0;
+
+	list_for_each(loop_counter, &pidqueue_head) {
+		candidate = list_entry(loop_counter, struct candidate_process, pid_list);
+		do_each_thread(g, p)
+			if (p->pid == candidate->pid) {
+				printk(KERN_DEBUG "A good walker leaves no tracks.%s\n", p->comm);
+				goto outer_loop;
+			}
+		while_each_thread(g, p);
+	  outer_loop:
+		continue;
+	}
+}
+
+EXPORT_SYMBOL(show_candidate_comm);
+*/
+static struct task_struct * select_process(void)
+{
+	struct task_struct *g, *p;
+	struct task_struct *chosen = NULL;
+	      
+	if (!list_empty(&pidqueue_head)) {
+		struct list_head *tmp;
+		list_for_each_safe(loop_counter, tmp, &pidqueue_head) {
+			candidate = list_entry(loop_counter, struct candidate_process, pid_list);
+			do_each_thread(g, p)
+				if (p->pid == candidate->pid) {
+					chosen = p;
+					list_del(&candidate->pid_list);
+					kfree(candidate);
+					goto exit;
+				}
+			while_each_thread(g, p);
+		}
+	}
+  exit:
+	return chosen;
+}
+
 static unsigned long badness(struct task_struct *p, unsigned long uptime)
 {
 	unsigned long points, cpu_time, run_time, s;
@@ -111,6 +175,7 @@
  *
  * (not docbooked, we don't want this one cluttering up the manual)
  */
+/*
 static struct task_struct * select_bad_process(void)
 {
 	unsigned long maxpoints = 0;
@@ -132,7 +197,7 @@
 	while_each_thread(g, p);
 	return chosen;
 }
-
+*/
 /**
  * We must be careful though to never send SIGKILL a process with
  * CAP_SYS_RAW_IO set, send SIGTERM instead (but it's unlikely that
@@ -191,7 +256,8 @@
 	
 	read_lock(&tasklist_lock);
 retry:
-	p = select_bad_process();
+	printk(KERN_DEBUG "A good walker leaves no tracks.\n");
+	p = select_process();
 
 	/* Found nothing?!?! Either we hang forever, or we panic. */
 	if (!p) {




BR,

Mauricio Lin.

  reply	other threads:[~2005-01-10 23:38 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-10 21:43 User space out of memory approach Mauricio Lin
2005-01-10 19:20 ` Marcelo Tosatti
2005-01-10 19:39   ` Marcelo Tosatti
2005-01-10 23:01     ` Mauricio Lin
2005-01-10 22:40   ` Edjard Souza Mota
2005-01-10 20:05     ` Marcelo Tosatti
2005-01-10 23:17       ` Edjard Souza Mota
2005-01-10 23:18         ` Edjard Souza Mota
2005-01-10 23:24       ` Mauricio Lin
2005-01-10 23:30         ` Mauricio Lin [this message]
2005-01-11  7:47         ` Marcelo Tosatti
2005-01-11  0:35       ` Thomas Gleixner
2005-01-11  2:03         ` Edjard Souza Mota
2005-01-11  8:44           ` Thomas Gleixner
2005-01-11  8:58             ` Andrea Arcangeli
2005-01-11  7:48               ` Marcelo Tosatti
2005-01-11  9:08               ` Andrew Morton
2005-01-11  9:19                 ` Andrea Arcangeli
2005-01-11  9:27                   ` Andrew Morton
2005-01-11  9:20             ` Edjard Souza Mota
2005-01-11  9:30               ` Thomas Gleixner
2005-01-11  9:56                 ` Andrea Arcangeli
2005-01-11 10:05                   ` Edjard Souza Mota
2005-01-11 10:39                     ` Thomas Gleixner
2005-01-11 10:44                     ` Andrea Arcangeli
2005-01-11 14:56                       ` Edjard Souza Mota
2005-01-11 15:27                       ` Ilias Biris
2005-01-11 10:00                 ` Edjard Souza Mota
2005-01-11 10:36                   ` Thomas Gleixner
2005-01-11 16:32             ` Alan Cox
2005-01-11 19:16               ` Ilias Biris
2005-01-11 20:46                 ` Ilias Biris
2005-01-11 20:57                   ` Thomas Gleixner
2005-01-12  9:31                     ` Edjard Souza Mota
2005-01-12 11:19                       ` Thomas Gleixner
2005-01-12 12:12                         ` Edjard Souza Mota
2005-01-13 15:36                   ` Alan Cox
2005-01-16 10:06                     ` Edjard Souza Mota
2005-01-16 21:10                       ` Alan Cox
2005-01-17 10:16                         ` Thomas Gleixner
2005-01-11 21:35                 ` Denis Vlasenko
2005-01-11 20:40               ` Thomas Gleixner
2005-01-11  7:42         ` Marcelo Tosatti
2005-01-11 10:51           ` Thomas Gleixner
2005-01-11 11:03             ` Andrea Arcangeli
2005-01-11  8:38         ` Andrea Arcangeli
2005-01-21 21:27           ` Mauricio Lin
2005-01-21 21:45             ` Mauricio Lin
2005-01-22  3:32               ` Andrea Arcangeli
2005-01-25 21:13                 ` Mauricio Lin
2005-01-25 21:39                   ` Thomas Gleixner
2005-01-26  0:11                     ` Mauricio Lin
2005-01-26  0:49                       ` Andrea Arcangeli
2005-01-26 14:03                         ` Mauricio Lin
2005-01-27 18:54                         ` Mauricio Lin
2005-01-27 22:11                           ` Andrea Arcangeli
2005-01-27 22:29                             ` Andrew Morton
2005-01-27 22:58                               ` Andrea Arcangeli
2005-01-27 23:35                                 ` Andrew Morton
2005-01-28  0:15                                   ` Andrea Arcangeli
2005-01-28 13:58                             ` Mauricio Lin
2005-01-28 15:21                               ` Mauricio Lin
2005-01-28 15:29                                 ` Andrea Arcangeli
2005-01-26  7:26                       ` Thomas Gleixner
2005-01-22  3:04             ` Andrea Arcangeli
     [not found] <fa.lcmt90h.1j1scpn@ifi.uio.no>
     [not found] ` <fa.ht4gei4.1g5odia@ifi.uio.no>
2005-01-16 16:28   ` Bodo Eggert
2005-01-18 13:15     ` Edjard Souza Mota
2005-01-19  6:18       ` Bodo Eggert
2005-01-20  3:20         ` Edjard Souza Mota
2005-01-20  5:00           ` Bodo Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3f250c71050110153031825ba3@mail.gmail.com \
    --to=mauriciolin@gmail.com \
    --cc=akpm@osdl.org \
    --cc=edjard@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.tosatti@cyclades.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.