From: Jeff Garzik <jgarzik@mandrakesoft.com>
To: linux-mm@kvack.org
Cc: Linux Kernel Mailing List <linux-kernel@vger.rutgers.edu>
Subject: PATCH 2.4.0.1.ac10: a KISS memory pressure callback
Date: Wed, 07 Jun 2000 03:34:59 -0400 [thread overview]
Message-ID: <393DFB23.64FD2E3D@mandrakesoft.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 213 bytes --]
Cheesy maybe, effective probably.
--
Jeff Garzik | Liberty is always dangerous, but
Building 1024 | it is the safest thing we have.
MandrakeSoft, Inc. | -- Harry Emerson Fosdick
[-- Attachment #2: freemem.patch --]
[-- Type: text/plain, Size: 3435 bytes --]
Index: mm/vmscan.c
===================================================================
RCS file: /g/cvslan/linux_2_3/mm/vmscan.c,v
retrieving revision 1.1.1.40
diff -u -r1.1.1.40 vmscan.c
--- mm/vmscan.c 2000/06/05 03:14:23 1.1.1.40
+++ mm/vmscan.c 2000/06/07 07:32:47
@@ -428,6 +428,31 @@
}
/*
+ * The freemem notifier list holds a list of functions
+ * that are to be called when trying to free pages.
+ *
+ * Call them... We don't use notifier_call_chain
+ * because the return code from a freemem notifier
+ * is treated as a shrink_*_memory-style return value.
+ */
+extern struct notifier_block *freemem_notifier_list;
+static int shrink_misc_memory (int priority, unsigned int gfp_mask)
+{
+ int count = 0;
+ struct notifier_block *nb = freemem_notifier_list;
+
+ while (nb) {
+ count += nb->notifier_call(nb,
+ (unsigned long) priority,
+ (void *)(unsigned long) gfp_mask);
+ nb = nb->next;
+ }
+
+ return count;
+}
+
+
+/*
* We need to make the locks finer granularity, but right
* now we need this so that we can do page allocations
* without holding the kernel lock etc.
@@ -476,6 +501,13 @@
if (!--count)
goto done;
}
+ }
+
+ /* call everybody who registered a mem pressure notifier */
+ count -= shrink_misc_memory(priority, gfp_mask);
+ if (count <= 0) {
+ ret = 1;
+ goto done;
}
/*
Index: kernel/ksyms.c
===================================================================
RCS file: /g/cvslan/linux_2_3/kernel/ksyms.c,v
retrieving revision 1.1.1.62
diff -u -r1.1.1.62 ksyms.c
--- kernel/ksyms.c 2000/05/29 23:48:48 1.1.1.62
+++ kernel/ksyms.c 2000/06/07 07:32:53
@@ -448,6 +448,8 @@
EXPORT_SYMBOL(machine_power_off);
EXPORT_SYMBOL(register_reboot_notifier);
EXPORT_SYMBOL(unregister_reboot_notifier);
+EXPORT_SYMBOL(register_freemem_notifier);
+EXPORT_SYMBOL(unregister_freemem_notifier);
EXPORT_SYMBOL(_ctype);
EXPORT_SYMBOL(secure_tcp_sequence_number);
EXPORT_SYMBOL(get_random_bytes);
Index: kernel/sys.c
===================================================================
RCS file: /g/cvslan/linux_2_3/kernel/sys.c,v
retrieving revision 1.1.1.19
diff -u -r1.1.1.19 sys.c
--- kernel/sys.c 2000/05/31 13:07:05 1.1.1.19
+++ kernel/sys.c 2000/06/07 07:32:53
@@ -47,15 +47,51 @@
*/
static struct notifier_block *reboot_notifier_list = NULL;
+struct notifier_block *freemem_notifier_list = NULL;
+static spinlock_t notifier_lock = SPIN_LOCK_UNLOCKED;
int register_reboot_notifier(struct notifier_block * nb)
{
- return notifier_chain_register(&reboot_notifier_list, nb);
+ int i;
+
+ spin_lock(¬ifier_lock);
+ i = notifier_chain_register(&reboot_notifier_list, nb);
+ spin_unlock(¬ifier_lock);
+
+ return i;
}
int unregister_reboot_notifier(struct notifier_block * nb)
+{
+ int i;
+
+ spin_lock(¬ifier_lock);
+ i = notifier_chain_unregister(&reboot_notifier_list, nb);
+ spin_unlock(¬ifier_lock);
+
+ return i;
+}
+
+int register_freemem_notifier(struct notifier_block * nb)
{
- return notifier_chain_unregister(&reboot_notifier_list, nb);
+ int i;
+
+ spin_lock(¬ifier_lock);
+ i = notifier_chain_register(&freemem_notifier_list, nb);
+ spin_unlock(¬ifier_lock);
+
+ return i;
+}
+
+int unregister_freemem_notifier(struct notifier_block * nb)
+{
+ int i;
+
+ spin_lock(¬ifier_lock);
+ i = notifier_chain_unregister(&freemem_notifier_list, nb);
+ spin_unlock(¬ifier_lock);
+
+ return i;
}
asmlinkage long sys_ni_syscall(void)
next reply other threads:[~2000-06-07 7:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-06-07 7:34 Jeff Garzik [this message]
[not found] ` <oupln0hkgag.fsf@pigdrop.muc.suse.de>
2000-06-07 10:25 ` PATCH 2.4.0.1.ac10: a KISS memory pressure callback (rev 2) Jeff Garzik
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=393DFB23.64FD2E3D@mandrakesoft.com \
--to=jgarzik@mandrakesoft.com \
--cc=linux-kernel@vger.rutgers.edu \
--cc=linux-mm@kvack.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox