mem_notify v6: introduce /dev/mem_notify new device (the core of this patch series)
Subsystems (7)
PATCH 3/8 mem_notify v6: introduce /dev/mem_notify new device (the core of this patch series)
the core of this patch series.
add /dev/mem_notify device for notification low memory to user process.
<usage examle>
fd = open("/dev/mem_notify", O_RDONLY);
if (fd < 0) {
exit(1);
}
pollfds.fd = fd;
pollfds.events = POLLIN;
pollfds.revents = 0;
err = poll(&pollfds, 1, -1); // wake up at low memory
...</usage example>
ChangeLog
v5 -> v6:
o improve number of wakeup tasks fomula when task is a few.
Signed-off-by Marcelo Tosatti <[email protected]>
Signed-off-by KOSAKI Motohiro <[email protected]>
--- Documentation/devices.txt | 1 drivers/char/mem.c | 5 + include/linux/mem_notify.h | 42 +++++++++++++++ include/linux/mmzone.h | 1 mm/Makefile | 2 mm/mem_notify.c | 123 +++++++++++++++++++++++++++++++++++++++++++++ mm/page_alloc.c | 1 7 files changed, 174 insertions(+), 1 deletion(-)
drivers/char/mem.c +5 -0
@@ -26,6 +26,7 @@#include <linux/bootmem.h> #include <linux/splice.h> #include <linux/pfn.h> +#include <linux/mem_notify.h> #include <asm/uaccess.h> #include <asm/io.h>
@@ -869,6 +870,9 @@ static int memory_open(struct inode * in filp->f_op = &oldmem_fops;break ;#endif +case 13 : + filp->f_op = &mem_notify_fops; +break ;default :return -ENXIO ; }
@@ -901,6 +905,7 @@ static const struct { #ifdef CONFIG_CRASH_DUMP {12,"oldmem", S_IRUSR | S_IWUSR | S_IRGRP, &oldmem_fops}, #endif + {13, "mem_notify", S_IRUGO, &mem_notify_fops}, }; static struct class *mem_class;
include/linux/mem_notify.h new file +42 -0
42 lines not on this page · raw message
include/linux/mmzone.h +1 -0
@@ -283,6 +283,7 @@ struct zone {*/ int prev_priority; +int mem_notify_status;ZONE_PADDING (_pad2_)/* Rarely used or read-mostly fields */
mm/Makefile +1 -1
@@ -11,7 +11,7 @@ obj-y := bootmem.o filemap.o mempool.o page_alloc.o page-writeback.o pdflush.o \ readahead.o swap.o truncate.o vmscan.o \ prio_tree.o util.o mmzone.o vmstat.o backing-dev.o \ - page_isolation.o $(mmu-y) + page_isolation.o mem_notify.o $(mmu-y) obj-$(CONFIG_PROC_PAGE_MONITOR) += pagewalk.o obj-$(CONFIG_BOUNCE) += bounce.o
mm/mem_notify.c new file +123 -0
123 lines not on this page · raw message
mm/page_alloc.c +1 -0
@@ -3458,6 +3458,7 @@ static void __meminit free_area_init_cor zone->zone_pgdat = pgdat; zone->prev_priority =DEF_PRIORITY ; + zone->mem_notify_status =0 ;zone_pcp_init (zone);INIT_LIST_HEAD (&zone->active_list);
Documentation/devices.txt +1 -0
@@ -96,6 +96,7 @@ Your cooperation is appreciated. 11 = /dev/kmsg Writes to this come out as printk's 12 = /dev/oldmem Used by crashdump kernels to access the memory of the kernel that crashed. + 13 = /dev/mem_notify Low memory notification. 1 block RAM disk 0 = /dev/ram0 First RAM disk
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>