diff for duplicates of <20130812022535.GA18832@bbox> diff --git a/a/1.txt b/N1/1.txt index 71165f2..09425c6 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -48,3 +48,143 @@ Only hurdle for that is that we should introduce a new page flag and I believe if we all agree this approch, we can find a solution at last. What do you think? + +>From 9a4f652006b7d0c750933d738e1bd6f53754bcf6 Mon Sep 17 00:00:00 2001 +From: Minchan Kim <minchan@kernel.org> +Date: Sun, 11 Aug 2013 00:31:57 +0900 +Subject: [RFC] pin page control subsystem + + +Signed-off-by: Minchan Kim <minchan@kernel.org> +--- + mm/Makefile | 2 +- + mm/pin-page.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 102 insertions(+), 1 deletion(-) + create mode 100644 mm/pin-page.c + +diff --git a/mm/Makefile b/mm/Makefile +index f008033..245c2f7 100644 +--- a/mm/Makefile ++++ b/mm/Makefile +@@ -5,7 +5,7 @@ + mmu-y := nommu.o + mmu-$(CONFIG_MMU) := fremap.o highmem.o madvise.o memory.o mincore.o \ + mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \ +- vmalloc.o pagewalk.o pgtable-generic.o ++ vmalloc.o pagewalk.o pgtable-generic.o pin-page.o + + ifdef CONFIG_CROSS_MEMORY_ATTACH + mmu-$(CONFIG_MMU) += process_vm_access.o +diff --git a/mm/pin-page.c b/mm/pin-page.c +new file mode 100644 +index 0000000..74b07f8 +--- /dev/null ++++ b/mm/pin-page.c +@@ -0,0 +1,101 @@ ++#include <linux/mm.h> ++#include <linux/slab.h> ++#include <linux/list.h> ++#include <linux/hashtable.h> ++ ++#define PPAGE_HASH_BITS 10 ++ ++static DEFINE_SPINLOCK(hash_lock); ++/* ++ * Should consider what's data struct we should use. ++ * It would be better use radix tree if we try to pin contigous ++ * pages a lot but if we pin spread pages, it wouldn't be a good idea. ++ */ ++static DEFINE_HASHTABLE(pin_page_hash, PPAGE_HASH_BITS); ++ ++/* ++ * Each subsystems should provide own page migration handler ++ */ ++struct pin_page_owner { ++ int (*migrate)(struct page *page, void *private); ++}; ++ ++struct pin_page_info { ++ struct pin_page_owner *owner; ++ struct hlist_node hlist; ++ ++ unsigned long pfn; ++ void *private; ++}; ++ ++/* TODO : Introduce new page flags */ ++void SetPinnedPage(struct page *page) ++{ ++ ++} ++ ++int PinnedPage(struct page *page) ++{ ++ return 0; ++} ++ ++/* ++ * GUP caller or subsystems which pin the page should call this function ++ * to register @page in pin-page control subsystem so that VM can ask us ++ * when it want to migrate @page. ++ * ++ * Each pinned page would have some private key to identify itself ++ * like custom-allocator-returned handle. ++ */ ++int set_pinned_page(struct pin_page_owner *owner, ++ struct page *page, void *private) ++{ ++ struct pin_page_info *pinfo = kmalloc(sizeof(pinfo), GFP_KERNEL); ++ ++ INIT_HLIST_NODE(&pinfo->hlist); ++ pinfo->owner = owner; ++ ++ pinfo->pfn = page_to_pfn(page); ++ pinfo->private = private; ++ ++ spin_lock(&hash_lock); ++ hash_add(pin_page_hash, &pinfo->hlist, pinfo->pfn); ++ spin_unlock(&hash_lock); ++ ++ SetPinnedPage(page); ++ return 0; ++}; ++ ++struct pin_page_info *get_pin_page_info(struct page *page) ++{ ++ struct pin_page_info *tmp; ++ unsigned long pfn = page_to_pfn(page); ++ ++ spin_lock(&hash_lock); ++ hash_for_each_possible(pin_page_hash, tmp, hlist, pfn) { ++ if (tmp->pfn == pfn) { ++ spin_unlock(&hash_lock); ++ return tmp; ++ } ++ } ++ spin_unlock(&hash_lock); ++ return NULL; ++} ++ ++/* Used in compaction.c */ ++int migrate_pinned_page(struct page *page) ++{ ++ int ret = 1; ++ struct pin_page_info *pinfo = NULL; ++ ++ if (PinnedPage(page)) { ++ while ((pinfo = get_pin_page_info(page))) { ++ /* If one of owners failed, bail out */ ++ if (pinfo->owner->migrate(page, pinfo->private)) ++ break; ++ } ++ ++ ret = 0; ++ } ++ return ret; ++} +-- +1.7.9.5 + +-- +Kind regards, +Minchan Kim diff --git a/a/content_digest b/N1/content_digest index 43be502..653dda4 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -65,6 +65,146 @@ "Only hurdle for that is that we should introduce a new page flag and\n" "I believe if we all agree this approch, we can find a solution at last.\n" "\n" - What do you think? + "What do you think?\n" + "\n" + ">From 9a4f652006b7d0c750933d738e1bd6f53754bcf6 Mon Sep 17 00:00:00 2001\n" + "From: Minchan Kim <minchan@kernel.org>\n" + "Date: Sun, 11 Aug 2013 00:31:57 +0900\n" + "Subject: [RFC] pin page control subsystem\n" + "\n" + "\n" + "Signed-off-by: Minchan Kim <minchan@kernel.org>\n" + "---\n" + " mm/Makefile | 2 +-\n" + " mm/pin-page.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" + " 2 files changed, 102 insertions(+), 1 deletion(-)\n" + " create mode 100644 mm/pin-page.c\n" + "\n" + "diff --git a/mm/Makefile b/mm/Makefile\n" + "index f008033..245c2f7 100644\n" + "--- a/mm/Makefile\n" + "+++ b/mm/Makefile\n" + "@@ -5,7 +5,7 @@\n" + " mmu-y\t\t\t:= nommu.o\n" + " mmu-$(CONFIG_MMU)\t:= fremap.o highmem.o madvise.o memory.o mincore.o \\\n" + " \t\t\t mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \\\n" + "-\t\t\t vmalloc.o pagewalk.o pgtable-generic.o\n" + "+\t\t\t vmalloc.o pagewalk.o pgtable-generic.o pin-page.o\n" + " \n" + " ifdef CONFIG_CROSS_MEMORY_ATTACH\n" + " mmu-$(CONFIG_MMU)\t+= process_vm_access.o\n" + "diff --git a/mm/pin-page.c b/mm/pin-page.c\n" + "new file mode 100644\n" + "index 0000000..74b07f8\n" + "--- /dev/null\n" + "+++ b/mm/pin-page.c\n" + "@@ -0,0 +1,101 @@\n" + "+#include <linux/mm.h>\n" + "+#include <linux/slab.h>\n" + "+#include <linux/list.h>\n" + "+#include <linux/hashtable.h>\n" + "+\n" + "+#define PPAGE_HASH_BITS 10\n" + "+\n" + "+static DEFINE_SPINLOCK(hash_lock);\n" + "+/*\n" + "+ * Should consider what's data struct we should use.\n" + "+ * It would be better use radix tree if we try to pin contigous\n" + "+ * pages a lot but if we pin spread pages, it wouldn't be a good idea.\n" + "+ */\n" + "+static DEFINE_HASHTABLE(pin_page_hash, PPAGE_HASH_BITS);\n" + "+\n" + "+/*\n" + "+ * Each subsystems should provide own page migration handler\n" + "+ */\n" + "+struct pin_page_owner {\n" + "+\tint (*migrate)(struct page *page, void *private);\n" + "+};\n" + "+\n" + "+struct pin_page_info {\n" + "+\tstruct pin_page_owner *owner;\n" + "+\tstruct hlist_node hlist;\n" + "+\n" + "+\tunsigned long pfn;\n" + "+\tvoid *private;\n" + "+};\n" + "+\n" + "+/* TODO : Introduce new page flags */\n" + "+void SetPinnedPage(struct page *page)\n" + "+{\n" + "+\n" + "+}\n" + "+\n" + "+int PinnedPage(struct page *page)\n" + "+{\n" + "+\treturn 0;\n" + "+}\n" + "+\n" + "+/*\n" + "+ * GUP caller or subsystems which pin the page should call this function\n" + "+ * to register @page in pin-page control subsystem so that VM can ask us\n" + "+ * when it want to migrate @page.\n" + "+ * \n" + "+ * Each pinned page would have some private key to identify itself\n" + "+ * like custom-allocator-returned handle.\n" + "+ */\n" + "+int set_pinned_page(struct pin_page_owner *owner,\n" + "+\t\t\tstruct page *page, void *private)\n" + "+{\n" + "+\tstruct pin_page_info *pinfo = kmalloc(sizeof(pinfo), GFP_KERNEL);\n" + "+\n" + "+\tINIT_HLIST_NODE(&pinfo->hlist);\n" + "+\tpinfo->owner = owner;\n" + "+\n" + "+\tpinfo->pfn = page_to_pfn(page);\n" + "+\tpinfo->private = private;\n" + "+\t\n" + "+\tspin_lock(&hash_lock);\n" + "+\thash_add(pin_page_hash, &pinfo->hlist, pinfo->pfn);\n" + "+\tspin_unlock(&hash_lock);\n" + "+\n" + "+\tSetPinnedPage(page);\n" + "+\treturn 0;\n" + "+};\n" + "+\n" + "+struct pin_page_info *get_pin_page_info(struct page *page)\n" + "+{\n" + "+\tstruct pin_page_info *tmp;\n" + "+\tunsigned long pfn = page_to_pfn(page);\n" + "+\n" + "+\tspin_lock(&hash_lock);\n" + "+\thash_for_each_possible(pin_page_hash, tmp, hlist, pfn) {\n" + "+\t\tif (tmp->pfn == pfn) {\n" + "+\t\t\tspin_unlock(&hash_lock);\n" + "+\t\t\treturn tmp;\n" + "+\t\t}\n" + "+\t}\n" + "+\tspin_unlock(&hash_lock);\n" + "+\treturn NULL;\n" + "+}\n" + "+\n" + "+/* Used in compaction.c */\n" + "+int migrate_pinned_page(struct page *page)\n" + "+{\n" + "+\tint ret = 1;\n" + "+\tstruct pin_page_info *pinfo = NULL;\n" + "+\n" + "+\tif (PinnedPage(page)) {\n" + "+\t\twhile ((pinfo = get_pin_page_info(page))) {\n" + "+\t\t\t/* If one of owners failed, bail out */\n" + "+\t\t\tif (pinfo->owner->migrate(page, pinfo->private))\n" + "+\t\t\t\tbreak;\n" + "+\t\t}\n" + "+\n" + "+\t\tret = 0;\n" + "+\t}\n" + "+\treturn ret;\n" + "+}\n" + "-- \n" + "1.7.9.5\n" + "\n" + "-- \n" + "Kind regards,\n" + Minchan Kim -63ee1729c4190de4a505f2289c06cc87c456d4dd530fa8d4f1e2eaf8e05bbbce +45e9990675bc3d6a0cc0b5bf73b0bdc452c89af11fe10f1ee8b25aeee5dbfc8b
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.