diff for duplicates of <20170317031048.GC18964@aaronlu.sh.intel.com> diff --git a/a/1.txt b/N1/1.txt index 0cdacdb..bb4cd46 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -11,3 +11,77 @@ it wouldn't parallize well for: 2 work load that has a lot of small VMAs. The code is nice and easy though(developed at v4.9 time frame): + +>From f6d5cfde888b9e0356719fabe8754fdfe6fe236b Mon Sep 17 00:00:00 2001 +From: Aaron Lu <aaron.lu@intel.com> +Date: Wed, 11 Jan 2017 15:56:06 +0800 +Subject: [PATCH] mm: async free vma + +--- + include/linux/mm_types.h | 6 ++++++ + mm/memory.c | 23 ++++++++++++++++++++++- + 2 files changed, 28 insertions(+), 1 deletion(-) + +diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h +index 4a8acedf4b7d..d10d2ce8f8f4 100644 +--- a/include/linux/mm_types.h ++++ b/include/linux/mm_types.h +@@ -358,6 +358,12 @@ struct vm_area_struct { + struct mempolicy *vm_policy; /* NUMA policy for the VMA */ + #endif + struct vm_userfaultfd_ctx vm_userfaultfd_ctx; ++ ++ struct vma_free_ctx { ++ unsigned long start_addr; ++ unsigned long end_addr; ++ struct work_struct work; ++ } free_ctx; + }; + + struct core_thread { +diff --git a/mm/memory.c b/mm/memory.c +index e18c57bdc75c..0fe4e45a044b 100644 +--- a/mm/memory.c ++++ b/mm/memory.c +@@ -1345,6 +1345,17 @@ static void unmap_single_vma(struct mmu_gather *tlb, + } + } + ++static void unmap_single_vma_work(struct work_struct *work) ++{ ++ struct vma_free_ctx *ctx = container_of(work, struct vma_free_ctx, work); ++ struct vm_area_struct *vma = container_of(ctx, struct vm_area_struct, free_ctx); ++ struct mmu_gather tlb; ++ ++ tlb_gather_mmu(&tlb, vma->vm_mm, ctx->start_addr, ctx->end_addr); ++ unmap_single_vma(&tlb, vma, ctx->start_addr, ctx->end_addr, NULL); ++ tlb_finish_mmu(&tlb, ctx->start_addr, ctx->end_addr); ++} ++ + /** + * unmap_vmas - unmap a range of memory covered by a list of vma's + * @tlb: address of the caller's struct mmu_gather +@@ -1368,10 +1379,20 @@ void unmap_vmas(struct mmu_gather *tlb, + unsigned long end_addr) + { + struct mm_struct *mm = vma->vm_mm; ++ struct vma_free_ctx *ctx; ++ struct vm_area_struct *tmp = vma; + + mmu_notifier_invalidate_range_start(mm, start_addr, end_addr); ++ for ( ; vma && vma->vm_start < end_addr; vma = vma->vm_next) { ++ ctx = &vma->free_ctx; ++ ctx->start_addr = start_addr; ++ ctx->end_addr = end_addr; ++ INIT_WORK(&ctx->work, unmap_single_vma_work); ++ queue_work(system_unbound_wq, &ctx->work); ++ } ++ vma = tmp; + for ( ; vma && vma->vm_start < end_addr; vma = vma->vm_next) +- unmap_single_vma(tlb, vma, start_addr, end_addr, NULL); ++ flush_work(&vma->free_ctx.work); + mmu_notifier_invalidate_range_end(mm, start_addr, end_addr); + } + +-- +2.9.3 diff --git a/a/content_digest b/N1/content_digest index 0bdfd6b..d621aa3 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -24,6 +24,80 @@ "1 work load that uses only 1 or very few huge VMA;\n" "2 work load that has a lot of small VMAs.\n" "\n" - The code is nice and easy though(developed at v4.9 time frame): + "The code is nice and easy though(developed at v4.9 time frame):\n" + "\n" + ">From f6d5cfde888b9e0356719fabe8754fdfe6fe236b Mon Sep 17 00:00:00 2001\n" + "From: Aaron Lu <aaron.lu@intel.com>\n" + "Date: Wed, 11 Jan 2017 15:56:06 +0800\n" + "Subject: [PATCH] mm: async free vma\n" + "\n" + "---\n" + " include/linux/mm_types.h | 6 ++++++\n" + " mm/memory.c | 23 ++++++++++++++++++++++-\n" + " 2 files changed, 28 insertions(+), 1 deletion(-)\n" + "\n" + "diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h\n" + "index 4a8acedf4b7d..d10d2ce8f8f4 100644\n" + "--- a/include/linux/mm_types.h\n" + "+++ b/include/linux/mm_types.h\n" + "@@ -358,6 +358,12 @@ struct vm_area_struct {\n" + " \tstruct mempolicy *vm_policy;\t/* NUMA policy for the VMA */\n" + " #endif\n" + " \tstruct vm_userfaultfd_ctx vm_userfaultfd_ctx;\n" + "+\n" + "+\tstruct vma_free_ctx {\n" + "+\t\tunsigned long start_addr;\n" + "+\t\tunsigned long end_addr;\n" + "+\t\tstruct work_struct work;\n" + "+\t} free_ctx;\n" + " };\n" + " \n" + " struct core_thread {\n" + "diff --git a/mm/memory.c b/mm/memory.c\n" + "index e18c57bdc75c..0fe4e45a044b 100644\n" + "--- a/mm/memory.c\n" + "+++ b/mm/memory.c\n" + "@@ -1345,6 +1345,17 @@ static void unmap_single_vma(struct mmu_gather *tlb,\n" + " \t}\n" + " }\n" + " \n" + "+static void unmap_single_vma_work(struct work_struct *work)\n" + "+{\n" + "+\tstruct vma_free_ctx *ctx = container_of(work, struct vma_free_ctx, work);\n" + "+\tstruct vm_area_struct *vma = container_of(ctx, struct vm_area_struct, free_ctx);\n" + "+\tstruct mmu_gather tlb;\n" + "+\n" + "+\ttlb_gather_mmu(&tlb, vma->vm_mm, ctx->start_addr, ctx->end_addr);\n" + "+\tunmap_single_vma(&tlb, vma, ctx->start_addr, ctx->end_addr, NULL);\n" + "+\ttlb_finish_mmu(&tlb, ctx->start_addr, ctx->end_addr);\n" + "+}\n" + "+\n" + " /**\n" + " * unmap_vmas - unmap a range of memory covered by a list of vma's\n" + " * @tlb: address of the caller's struct mmu_gather\n" + "@@ -1368,10 +1379,20 @@ void unmap_vmas(struct mmu_gather *tlb,\n" + " \t\tunsigned long end_addr)\n" + " {\n" + " \tstruct mm_struct *mm = vma->vm_mm;\n" + "+\tstruct vma_free_ctx *ctx;\n" + "+\tstruct vm_area_struct *tmp = vma;\n" + " \n" + " \tmmu_notifier_invalidate_range_start(mm, start_addr, end_addr);\n" + "+\tfor ( ; vma && vma->vm_start < end_addr; vma = vma->vm_next) {\n" + "+\t\tctx = &vma->free_ctx;\n" + "+\t\tctx->start_addr = start_addr;\n" + "+\t\tctx->end_addr = end_addr;\n" + "+\t\tINIT_WORK(&ctx->work, unmap_single_vma_work);\n" + "+\t\tqueue_work(system_unbound_wq, &ctx->work);\n" + "+\t}\n" + "+\tvma = tmp;\n" + " \tfor ( ; vma && vma->vm_start < end_addr; vma = vma->vm_next)\n" + "-\t\tunmap_single_vma(tlb, vma, start_addr, end_addr, NULL);\n" + "+\t\tflush_work(&vma->free_ctx.work);\n" + " \tmmu_notifier_invalidate_range_end(mm, start_addr, end_addr);\n" + " }\n" + " \n" + "-- \n" + 2.9.3 -2efbcb0f4773aaae30e4c3f5ee42706cb7451dd266b9917547102a09f3f1d2af +a47fb3a9615a57447a664f95a2f5df59863fe2aaa4728eaee1c3dd2b1b91784a
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.