[Devel] [PATCH rh7] mm/tcache: make tcache work again
Tcache use PF_MEMALLOC to distinguish memcg recalim from global reclaim, but sinche upstream commit 89a2848381b5 ("mm: memcontrol: do not recurse in direct reclaim") this is no longer works as PF_MEMALLOC also set during memcg reclaim. Add new PF_MEMCG_RECLAIM flag set only during memcg reclaim and use it in tcache to distinguish global recalaim from per-memcg recalim. Signed-off-by: Andrey Ryabinin --- include/linux/sched.h | 1 + mm/tcache.c | 2 +- mm/vmscan.c | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 8ce9573..69f8368 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2044,6 +2044,7 @@ extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut, #define PF_KTHREAD 0x0020 /* I am a kernel thread */ #define PF_RANDOMIZE 0x0040 /* randomize virtual address space */ #define PF_SWAPWRITE 0x0080 /* Allowed to write to swap */ +#define PF_MEMCG_RECLAIM 0x0100 /* We are in memcg reclaim */ #define PF_NO_SETAFFINITY 0x0400 /* Userland is not allowed to meddle with cpus_allowed */ #define PF_MCE_EARLY0x0800 /* Early kill for mce process policy */ #define PF_MEMPOLICY 0x1000 /* Non-default NUMA mempolicy */ diff --git a/mm/tcache.c b/mm/tcache.c index e15d212..94f0383 100644 --- a/mm/tcache.c +++ b/mm/tcache.c @@ -1145,7 +1145,7 @@ static void tcache_cleancache_put_page(int pool_id, struct page *cache_page = NULL; /* It makes no sense to populate tcache when we are short on memory */ - if (!READ_ONCE(tcache_active) || current->flags & PF_MEMALLOC) + if (!READ_ONCE(tcache_active) || !(current->flags & PF_MEMCG_RECLAIM)) return; node = tcache_get_node_and_pool(pool_id, &key, true); diff --git a/mm/vmscan.c b/mm/vmscan.c index a3a380b..6bf978f 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2955,9 +2955,9 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg, sc.may_writepage, sc.gfp_mask); - current->flags |= PF_MEMALLOC; + current->flags |= PF_MEMALLOC | PF_MEMCG_RECLAIM; nr_reclaimed = do_try_to_free_pages(zonelist, &sc); - current->flags &= ~PF_MEMALLOC; + current->flags &= ~(PF_MEMALLOC | PF_MEMCG_RECLAIM); trace_mm_vmscan_memcg_reclaim_end(nr_reclaimed); -- 2.10.2 ___ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel
[Devel] [PATCH RHEL7 COMMIT] mm/tcache: make tcache work again
The commit is pushed to "branch-rh7-3.10.0-514.16.1.vz7.30.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git after rh7-3.10.0-514.16.1.vz7.30.2 --> commit 9b034990d22f69354f686c9dde81c04023d6530d Author: Andrey Ryabinin Date: Tue Apr 18 16:51:13 2017 +0400 mm/tcache: make tcache work again Tcache use PF_MEMALLOC to distinguish memcg recalim from global reclaim, but sinche upstream commit 89a2848381b5 ("mm: memcontrol: do not recurse in direct reclaim") this is no longer works as PF_MEMALLOC also set during memcg reclaim. Add new PF_MEMCG_RECLAIM flag set only during memcg reclaim and use it in tcache to distinguish global recalaim from per-memcg recalim. https://jira.sw.ru/browse/PSBM-64725 Signed-off-by: Andrey Ryabinin --- include/linux/sched.h | 1 + mm/tcache.c | 2 +- mm/vmscan.c | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 8ce9573..69f8368 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2044,6 +2044,7 @@ extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut, #define PF_KTHREAD 0x0020 /* I am a kernel thread */ #define PF_RANDOMIZE 0x0040 /* randomize virtual address space */ #define PF_SWAPWRITE 0x0080 /* Allowed to write to swap */ +#define PF_MEMCG_RECLAIM 0x0100 /* We are in memcg reclaim */ #define PF_NO_SETAFFINITY 0x0400 /* Userland is not allowed to meddle with cpus_allowed */ #define PF_MCE_EARLY0x0800 /* Early kill for mce process policy */ #define PF_MEMPOLICY 0x1000 /* Non-default NUMA mempolicy */ diff --git a/mm/tcache.c b/mm/tcache.c index e15d212..94f0383 100644 --- a/mm/tcache.c +++ b/mm/tcache.c @@ -1145,7 +1145,7 @@ static void tcache_cleancache_put_page(int pool_id, struct page *cache_page = NULL; /* It makes no sense to populate tcache when we are short on memory */ - if (!READ_ONCE(tcache_active) || current->flags & PF_MEMALLOC) + if (!READ_ONCE(tcache_active) || !(current->flags & PF_MEMCG_RECLAIM)) return; node = tcache_get_node_and_pool(pool_id, &key, true); diff --git a/mm/vmscan.c b/mm/vmscan.c index a3a380b..6bf978f 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2955,9 +2955,9 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg, sc.may_writepage, sc.gfp_mask); - current->flags |= PF_MEMALLOC; + current->flags |= PF_MEMALLOC | PF_MEMCG_RECLAIM; nr_reclaimed = do_try_to_free_pages(zonelist, &sc); - current->flags &= ~PF_MEMALLOC; + current->flags &= ~(PF_MEMALLOC | PF_MEMCG_RECLAIM); trace_mm_vmscan_memcg_reclaim_end(nr_reclaimed); ___ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel
[Devel] [PATCH RHEL7 COMMIT] Revert "kvm/x86: do not clear hyperv synic pages when setting MSRs"
The commit is pushed to "branch-rh7-3.10.0-514.16.1.vz7.30.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git after rh7-3.10.0-514.16.1.vz7.30.2 --> commit 12ef8f93ff4c22492a7e3844d2a97bb7b8c98526 Author: Evgeny Yakovlev Date: Tue Apr 18 16:56:34 2017 +0400 Revert "kvm/x86: do not clear hyperv synic pages when setting MSRs" This reverts commit 9b97e5b0878dcf05bdb00c6054fb99125be46501, next patch "kvm/x86: clear hyperv synic pages only when guest modifies MSRs" contains a better fix for https://jira.sw.ru/browse/PSBM-63164 https://jira.sw.ru/browse/PSBM-64657 Signed-off-by: Evgeny Yakovlev Reviewed-by: Roman Kagan --- arch/x86/kvm/hyperv.c | 12 1 file changed, 12 insertions(+) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 563c54fb..eae314b 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -219,11 +219,23 @@ static int synic_set_msr(struct kvm_vcpu_hv_synic *synic, synic->version = data; break; case HV_X64_MSR_SIEFP: + if (data & HV_SYNIC_SIEFP_ENABLE) + if (kvm_clear_guest(vcpu->kvm, + data & PAGE_MASK, PAGE_SIZE)) { + ret = 1; + break; + } synic->evt_page = data; if (!host) synic_exit(synic, msr); break; case HV_X64_MSR_SIMP: + if (data & HV_SYNIC_SIMP_ENABLE) + if (kvm_clear_guest(vcpu->kvm, + data & PAGE_MASK, PAGE_SIZE)) { + ret = 1; + break; + } synic->msg_page = data; if (!host) synic_exit(synic, msr); ___ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel
[Devel] [PATCH RHEL7 COMMIT] kvm/x86: clear hyperv synic pages only when guest modifies MSRs
The commit is pushed to "branch-rh7-3.10.0-514.16.1.vz7.30.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git after rh7-3.10.0-514.16.1.vz7.30.2 --> commit 9f24caf30ffe8c9d4e751aa38898fb33d2dbab62 Author: Evgeny Yakovlev Date: Tue Apr 18 16:56:35 2017 +0400 kvm/x86: clear hyperv synic pages only when guest modifies MSRs Existing code resets guest synic message and event flag pages to zero when host (but not guest) updates their guest PAs by writing to corresponding MSRs. This turned out to be a problem for migration code when guest had a SYNIC irq to inject before suspending. After resuming qemu resets MSRs to saved values and KVM zeroes out migrated guest memory as a side effect. Following that guest sees an IRQ but doesn't see any event flags in event flags page, skips this IRQ and hangs indefinitely. This change fixes failing migration scenario by checking that pages are cleared by guest MSR write only. https://jira.sw.ru/browse/PSBM-63164 https://jira.sw.ru/browse/PSBM-64657 Signed-off-by: Evgeny Yakovlev Reviewed-by: Roman Kagan --- arch/x86/kvm/hyperv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index eae314b..c8efdce 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -219,7 +219,7 @@ static int synic_set_msr(struct kvm_vcpu_hv_synic *synic, synic->version = data; break; case HV_X64_MSR_SIEFP: - if (data & HV_SYNIC_SIEFP_ENABLE) + if (data & HV_SYNIC_SIEFP_ENABLE && !host) if (kvm_clear_guest(vcpu->kvm, data & PAGE_MASK, PAGE_SIZE)) { ret = 1; @@ -230,7 +230,7 @@ static int synic_set_msr(struct kvm_vcpu_hv_synic *synic, synic_exit(synic, msr); break; case HV_X64_MSR_SIMP: - if (data & HV_SYNIC_SIMP_ENABLE) + if (data & HV_SYNIC_SIMP_ENABLE && !host) if (kvm_clear_guest(vcpu->kvm, data & PAGE_MASK, PAGE_SIZE)) { ret = 1; ___ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel
[Devel] [PATCH rh7] mm/tswap: make tswap work again
The same issue as with tcache in "mm/tcache: make tcache work again" Tswap uses PF_MEMALLOC to distinguish memcg recalim from global reclaim, but sinche upstream commit 89a2848381b5 ("mm: memcontrol: do not recurse in direct reclaim") this is no longer works as PF_MEMALLOC also set during memcg reclaim. Use new PF_MEMCG_RECLAIM instead of PF_MEMALLOC to identify per-memcg recalim to avoid populating tswap during global reclaim Signed-off-by: Andrey Ryabinin --- mm/tswap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/tswap.c b/mm/tswap.c index 4c6c5bc..15f5adc 100644 --- a/mm/tswap.c +++ b/mm/tswap.c @@ -288,7 +288,7 @@ static int tswap_frontswap_store(unsigned type, pgoff_t offset, if (cache_page) goto copy; - if (current->flags & PF_MEMALLOC) + if (!(current->flags & PF_MEMCG_RECLAIM)) return -1; cache_page = alloc_page(TSWAP_GFP_MASK | __GFP_HIGHMEM); -- 2.10.2 ___ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel
[Devel] [PATCH RHEL7 COMMIT] mm/tswap: make tswap work again
The commit is pushed to "branch-rh7-3.10.0-514.16.1.vz7.30.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git after rh7-3.10.0-514.16.1.vz7.30.3 --> commit ad6fbf96fe30f323e03b0f872e4eeffacbfbb264 Author: Andrey Ryabinin Date: Tue Apr 18 18:42:01 2017 +0400 mm/tswap: make tswap work again The same issue as with tcache in "mm/tcache: make tcache work again" Tswap uses PF_MEMALLOC to distinguish memcg recalim from global reclaim, but sinche upstream commit 89a2848381b5 ("mm: memcontrol: do not recurse in direct reclaim") this is no longer works as PF_MEMALLOC also set during memcg reclaim. Use new PF_MEMCG_RECLAIM instead of PF_MEMALLOC to identify per-memcg recalim to avoid populating tswap during global reclaim https://jira.sw.ru/browse/PSBM-64725 Signed-off-by: Andrey Ryabinin --- mm/tswap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/tswap.c b/mm/tswap.c index 4c6c5bc..15f5adc 100644 --- a/mm/tswap.c +++ b/mm/tswap.c @@ -288,7 +288,7 @@ static int tswap_frontswap_store(unsigned type, pgoff_t offset, if (cache_page) goto copy; - if (current->flags & PF_MEMALLOC) + if (!(current->flags & PF_MEMCG_RECLAIM)) return -1; cache_page = alloc_page(TSWAP_GFP_MASK | __GFP_HIGHMEM); ___ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel