Skip to contentSkip to conversation

Support for modules that use swap

PATCH New Eric W. Biederman 1 participant 1 message May 23, 1999

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Support for modules that use swap

The following patch allows shmfs (and possibly ipc/shm.c) to be built as modules by providing an interface to swap off, that you can add and remove functions from.

Eric

include/linux/shm.h +0 -1
diff -uNrX linux-ignore-files linux-2.3.3.eb3/include/linux/shm.h linux-2.3.3.eb4/include/linux/shm.h
@@ -72,7 +72,6 @@
 asmlinkage int sys_shmat (int shmid, char *shmaddr, int shmflg, unsigned long *addr);
 asmlinkage int sys_shmdt (char *shmaddr);
 asmlinkage int sys_shmctl (int shmid, int cmd, struct shmid_ds *buf);
-extern void shm_unuse(unsigned long entry, unsigned long page);
 
 #endif /* __KERNEL__ */
 
include/linux/swap.h +14 -0
diff -uNrX linux-ignore-files linux-2.3.3.eb3/include/linux/swap.h linux-2.3.3.eb4/include/linux/swap.h
@@ -125,6 +125,20 @@
 asmlinkage int sys_swapoff(const char *);
 asmlinkage int sys_swapon(const char *, int);
 
+
+/* So that external drivers can use swap, swapoff */
+struct swap_unuse {
+	void (*unuse)(unsigned long entry, unsigned long page, void *arg);
+	int (*read_page_tables)(void *arg);
+	void (*swap_page_tables)(void *arg);
+	void *arg;
+	struct swap_unuse *prev;
+	struct swap_unuse *next;
+};
+
+extern void register_swap_unuse_function (struct swap_unuse *swap_unuse);
+extern void unregister_swap_unuse_function (struct swap_unuse *swap_unuse);
+
 /*
  * vm_ops not present page codes for shared memory.
  *
ipc/shm.c +10 -1
diff -uNrX linux-ignore-files linux-2.3.3.eb3/ipc/shm.c linux-2.3.3.eb4/ipc/shm.c
@@ -41,6 +41,14 @@
 static ulong swap_successes = 0;
 static ulong used_segs = 0;
 
+static void shm_unuse(unsigned long entry, unsigned long page, void *arg);
+static struct swap_unuse shm_swap_unuse = 
+{
+	shm_unuse,
+	NULL,
+	NULL, NULL, NULL
+};
+
 void __init shm_init (void)
 {
 	int id;
@@ -49,6 +57,7 @@
 		shm_segs[id] = (struct shmid_kernel *) IPC_UNUSED;
 	shm_tot = shm_rss = shm_seq = max_shmid = used_segs = 0;
 	init_waitqueue_head(&shm_lock);
+ 	register_swap_unuse_function(&shm_swap_unuse);
 	return;
 }
 
@@ -748,7 +757,7 @@
 /*
  * unuse_shm() search for an eventually swapped out shm page.
  */
-void shm_unuse(unsigned long entry, unsigned long page)
+static void shm_unuse(unsigned long entry, unsigned long page, void *arg)
 {
 	int i, n;
 
mm/Makefile +2 -0
diff -uNrX linux-ignore-files linux-2.3.3.eb3/mm/Makefile linux-2.3.3.eb4/mm/Makefile
@@ -12,4 +12,6 @@
 	    vmalloc.o slab.o \
 	    swap.o vmscan.o page_io.o page_alloc.o swap_state.o swapfile.o
 
+OX_OBJS := swap_syms.o
+
 include $(TOPDIR)/Rules.make
mm/swap_syms.c +16 -0
diff -uNrX linux-ignore-files linux-2.3.3.eb3/mm/swap_syms.c linux-2.3.3.eb4/mm/swap_syms.c
@@ -0,0 +1,16 @@
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/mm.h>
+#include <linux/swap.h>
+
+/* Explicit swapping */
+EXPORT_SYMBOL(rw_swap_page);
+EXPORT_SYMBOL(rw_swap_page_nocache);
+EXPORT_SYMBOL(rw_swap_page_nolock);
+EXPORT_SYMBOL(swap_free);
+EXPORT_SYMBOL(get_swap_page);
+EXPORT_SYMBOL(si_swapinfo);
+EXPORT_SYMBOL(register_swap_unuse_function);
+EXPORT_SYMBOL(unregister_swap_unuse_function);
+EXPORT_SYMBOL(swapper_inode);
mm/swapfile.c +131 -8

167 lines not on this page · raw message

--
To unsubscribe, send a message with 'unsubscribe linux-mm my@address' in the body to [email protected]. For more info on Linux MM,
see: http://humbolt.geo.uu.nl/Linux-MM/