[Devel] [PATCH RHEL8 COMMIT] mm, memcg: Fix "add oom counter to memory.stat memcgroup file"

2020-12-08 Thread Konstantin Khorenko
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear 
at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.el8
-->
commit b8af6763e91a7451b09831aa70510c138a799491
Author: Andrey Ryabinin 
Date:   Tue Dec 8 17:21:00 2020 +0300

mm, memcg: Fix "add oom counter to memory.stat memcgroup file"

Fix rebase of commit 3f10e0c1a0df12a2a503d0d9a3ec7b4f3ac3a467
Author: Andrey Ryabinin 
Date: Mon Oct 5 13:18:40 2020 +0300

mm, memcg: add oom counter to memory.stat memcgroup file

https://jira.sw.ru/browse/PSBM-123537
Signed-off-by: Andrey Ryabinin 
---
 mm/memcontrol.c | 38 +-
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 01c012b11243..c0f825a4c43e 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4141,12 +4141,28 @@ static const unsigned int memcg1_events[] = {
PSWPOUT,
 };
 
+static void accumulate_ooms(struct mem_cgroup *memcg, unsigned long *total_oom,
+   unsigned long *total_oom_kill)
+{
+   struct mem_cgroup *mi;
+
+   total_oom_kill = total_oom = 0;
+
+   for_each_mem_cgroup_tree(mi, memcg) {
+   total_oom += atomic_long_read(&mi->memory_events[MEMCG_OOM]);
+   total_oom_kill += 
atomic_long_read(&mi->memory_events[MEMCG_OOM_KILL]);
+
+   cond_resched();
+   }
+}
+
 static int memcg_stat_show(struct seq_file *m, void *v)
 {
struct mem_cgroup *memcg = mem_cgroup_from_seq(m);
unsigned long memory, memsw;
struct mem_cgroup *mi;
unsigned int i;
+   unsigned long total_oom = 0, total_oom_kill = 0;
 
BUILD_BUG_ON(ARRAY_SIZE(memcg1_stat_names) != ARRAY_SIZE(memcg1_stats));
 
@@ -4162,21 +4178,19 @@ static int memcg_stat_show(struct seq_file *m, void *v)
seq_printf(m, "%s %lu\n", vm_event_name(memcg1_events[i]),
   memcg_events_local(memcg, memcg1_events[i]));
 
+
+   accumulate_ooms(memcg, &total_oom, &total_oom_kill);
+
/*
 * For root_mem_cgroup we want to account global ooms as well.
 * The diff between all MEMCG_OOM_KILL and MEMCG_OOM events
 * should give us the glogbal ooms count.
 */
-   if (memcg == root_mem_cgroup) {
-   unsigned long glob_ooms;
-
-   glob_ooms = memcg_events(memcg, memcg1_events[MEMCG_OOM_KILL]) -
-   memcg_events(memcg, memcg1_events[MEMCG_OOM]);
-   seq_printf(m, "oom %lu\n", glob_ooms +
-   memcg_events_local(memcg, memcg1_events[MEMCG_OOM]));
-   } else
+   if (memcg == root_mem_cgroup)
+   seq_printf(m, "oom %lu\n", total_oom_kill - total_oom);
+   else
seq_printf(m, "oom %lu\n",
-   memcg_events_local(memcg, memcg1_events[MEMCG_OOM]));
+   atomic_long_read(&memcg->memory_events[MEMCG_OOM]));
 
for (i = 0; i < NR_LRU_LISTS; i++)
seq_printf(m, "%s %lu\n", lru_list_name(i),
@@ -4209,11 +4223,9 @@ static int memcg_stat_show(struct seq_file *m, void *v)
   (u64)memcg_events(memcg, memcg1_events[i]));
 
if (memcg == root_mem_cgroup)
-   seq_printf(m, "total_oom %lu\n",
-   memcg_events(memcg, memcg1_events[MEMCG_OOM_KILL]));
+   seq_printf(m, "total_oom %lu\n", total_oom_kill);
else
-   seq_printf(m, "total_oom %lu\n",
-   memcg_events(memcg, memcg1_events[MEMCG_OOM]));
+   seq_printf(m, "total_oom %lu\n", total_oom);
 
for (i = 0; i < NR_LRU_LISTS; i++)
seq_printf(m, "total_%s %llu\n", lru_list_name(i),
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH vz8] mm, memcg: Fix "add oom counter to memory.stat memcgroup file"

2020-12-08 Thread Andrey Ryabinin
Fix rebase of commit 3f10e0c1a0df12a2a503d0d9a3ec7b4f3ac3a467
Author: Andrey Ryabinin 
Date: Mon Oct 5 13:18:40 2020 +0300

mm, memcg: add oom counter to memory.stat memcgroup file

https://jira.sw.ru/browse/PSBM-123537
Signed-off-by: Andrey Ryabinin 
---
 mm/memcontrol.c | 38 +-
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 01c012b11243..c0f825a4c43e 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4141,12 +4141,28 @@ static const unsigned int memcg1_events[] = {
PSWPOUT,
 };
 
+static void accumulate_ooms(struct mem_cgroup *memcg, unsigned long *total_oom,
+   unsigned long *total_oom_kill)
+{
+   struct mem_cgroup *mi;
+
+   total_oom_kill = total_oom = 0;
+
+   for_each_mem_cgroup_tree(mi, memcg) {
+   total_oom += atomic_long_read(&mi->memory_events[MEMCG_OOM]);
+   total_oom_kill += 
atomic_long_read(&mi->memory_events[MEMCG_OOM_KILL]);
+
+   cond_resched();
+   }
+}
+
 static int memcg_stat_show(struct seq_file *m, void *v)
 {
struct mem_cgroup *memcg = mem_cgroup_from_seq(m);
unsigned long memory, memsw;
struct mem_cgroup *mi;
unsigned int i;
+   unsigned long total_oom = 0, total_oom_kill = 0;
 
BUILD_BUG_ON(ARRAY_SIZE(memcg1_stat_names) != ARRAY_SIZE(memcg1_stats));
 
@@ -4162,21 +4178,19 @@ static int memcg_stat_show(struct seq_file *m, void *v)
seq_printf(m, "%s %lu\n", vm_event_name(memcg1_events[i]),
   memcg_events_local(memcg, memcg1_events[i]));
 
+
+   accumulate_ooms(memcg, &total_oom, &total_oom_kill);
+
/*
 * For root_mem_cgroup we want to account global ooms as well.
 * The diff between all MEMCG_OOM_KILL and MEMCG_OOM events
 * should give us the glogbal ooms count.
 */
-   if (memcg == root_mem_cgroup) {
-   unsigned long glob_ooms;
-
-   glob_ooms = memcg_events(memcg, memcg1_events[MEMCG_OOM_KILL]) -
-   memcg_events(memcg, memcg1_events[MEMCG_OOM]);
-   seq_printf(m, "oom %lu\n", glob_ooms +
-   memcg_events_local(memcg, memcg1_events[MEMCG_OOM]));
-   } else
+   if (memcg == root_mem_cgroup)
+   seq_printf(m, "oom %lu\n", total_oom_kill - total_oom);
+   else
seq_printf(m, "oom %lu\n",
-   memcg_events_local(memcg, memcg1_events[MEMCG_OOM]));
+   atomic_long_read(&memcg->memory_events[MEMCG_OOM]));
 
for (i = 0; i < NR_LRU_LISTS; i++)
seq_printf(m, "%s %lu\n", lru_list_name(i),
@@ -4209,11 +4223,9 @@ static int memcg_stat_show(struct seq_file *m, void *v)
   (u64)memcg_events(memcg, memcg1_events[i]));
 
if (memcg == root_mem_cgroup)
-   seq_printf(m, "total_oom %lu\n",
-   memcg_events(memcg, memcg1_events[MEMCG_OOM_KILL]));
+   seq_printf(m, "total_oom %lu\n", total_oom_kill);
else
-   seq_printf(m, "total_oom %lu\n",
-   memcg_events(memcg, memcg1_events[MEMCG_OOM]));
+   seq_printf(m, "total_oom %lu\n", total_oom);
 
for (i = 0; i < NR_LRU_LISTS; i++)
seq_printf(m, "total_%s %llu\n", lru_list_name(i),
-- 
2.26.2

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH rh7] ms/KVM: x86: reinstate vendor-agnostic check on SPEC_CTRL cpuid bits #PSBM-120787 #PSBM-123538 #PSBM-121767

2020-12-08 Thread Konstantin Khorenko
From: Paolo Bonzini 

Until commit e7c587da1252 ("x86/speculation: Use synthetic bits for 
IBRS/IBPB/STIBP",
2018-05-17), KVM was testing both Intel and AMD CPUID bits before allowing the
guest to write MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD.  Testing only Intel 
bits
on VMX processors, or only AMD bits on SVM processors, fails if the guests are
created with the "opposite" vendor as the host.

While at it, also tweak the host CPU check to use the vendor-agnostic feature 
bit
X86_FEATURE_IBPB, since we only care about the availability of the MSR on the 
host
here and not about specific CPUID bits.

mFixes: e7c587da1252 ("x86/speculation: Use synthetic bits for IBRS/IBPB/STIBP")
Cc: sta...@vger.kernel.org
Reported-by: Denis V. Lunev 
Signed-off-by: Paolo Bonzini 

https://jira.sw.ru/browse/PSBM-123538


The patch is a replacement for below vz patch,
which has been reverted due to
https://jira.sw.ru/browse/PSBM-121767

 commit 39d637ddbcf876f897e01c737bbb351461921df0
 Author: Denis V. Lunev 
 Date:   Wed Oct 28 19:25:57 2020 +0300

kvm: fix AMD IBRS/IBPB/STIBP/SSBD reporting #PSBM-120787

We should report these bits in 8008 EBX on AMD only, i.e. when AMD
specific feature bits are enabled.

https://jira.sw.ru/browse/PSBM-120787

Signed-off-by: Denis V. Lunev 
CC: Vasily Averin 
CC: Konstantin Khorenko 


Port to vz7 note:

in vz7 both functions svm_set_msr() and vmx_set_msr() did not have
checks for
  !boot_cpu_has(X86_FEATURE_AMD_IBPB)
and
  !boot_cpu_has(X86_FEATURE_SPEC_CTRL)

Signed-off-by: Konstantin Khorenko 
---
 arch/x86/kvm/svm.c |  3 +++
 arch/x86/kvm/vmx.c | 10 --
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 5715da241383..3a04bd0bdf09 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -3881,11 +3881,14 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct 
msr_data *msr)
break;
case MSR_IA32_PRED_CMD:
if (!msr->host_initiated &&
+   !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) &&
!guest_cpuid_has(vcpu, X86_FEATURE_AMD_IBPB))
return 1;
 
if (data & ~PRED_CMD_IBPB)
return 1;
+   if (!boot_cpu_has(X86_FEATURE_IBPB))
+   return 1;
 
if (!data)
break;
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index f43b2db71ea9..a120208d3496 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3350,7 +3350,10 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct 
msr_data *msr_info)
break;
case MSR_IA32_SPEC_CTRL:
if (!msr_info->host_initiated &&
-   !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL))
+   !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) &&
+   !guest_cpuid_has(vcpu, X86_FEATURE_AMD_STIBP) &&
+   !guest_cpuid_has(vcpu, X86_FEATURE_AMD_IBRS) &&
+   !guest_cpuid_has(vcpu, X86_FEATURE_AMD_SSBD))
return 1;
 
/* The STIBP bit doesn't fault even if it's not advertised */
@@ -3387,11 +3390,14 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct 
msr_data *msr_info)
goto find_shared_msr;
case MSR_IA32_PRED_CMD:
if (!msr_info->host_initiated &&
-   !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL))
+   !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) &&
+   !guest_cpuid_has(vcpu, X86_FEATURE_AMD_IBPB))
return 1;
 
if (data & ~PRED_CMD_IBPB)
return 1;
+   if (!boot_cpu_has(X86_FEATURE_IBPB))
+   return 1;
 
if (!data)
break;
-- 
2.24.3

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH RHEL8 COMMIT] ms/KVM: x86: reinstate vendor-agnostic check on SPEC_CTRL cpuid bits #PSBM-120787 #PSBM-123538

2020-12-08 Thread Konstantin Khorenko
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear 
at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.el8
-->
commit 39074da0597b4d25ec98c688668bc3b063b7647c
Author: Paolo Bonzini 
Date:   Thu Dec 3 10:15:16 2020 -0500

ms/KVM: x86: reinstate vendor-agnostic check on SPEC_CTRL cpuid bits 
#PSBM-120787 #PSBM-123538

Until commit e7c587da1252 ("x86/speculation: Use synthetic bits for 
IBRS/IBPB/STIBP",
2018-05-17), KVM was testing both Intel and AMD CPUID bits before allowing 
the
guest to write MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD.  Testing only 
Intel bits
on VMX processors, or only AMD bits on SVM processors, fails if the guests 
are
created with the "opposite" vendor as the host.

While at it, also tweak the host CPU check to use the vendor-agnostic 
feature bit
X86_FEATURE_IBPB, since we only care about the availability of the MSR on 
the host
here and not about specific CPUID bits.

mFixes: e7c587da1252 ("x86/speculation: Use synthetic bits for 
IBRS/IBPB/STIBP")
Cc: sta...@vger.kernel.org
Reported-by: Denis V. Lunev 
Signed-off-by: Paolo Bonzini 

https://jira.sw.ru/browse/PSBM-123538


The patch is a replacement for vz patch:

 commit 39d637ddbcf876f897e01c737bbb351461921df0
 Author: Denis V. Lunev 
 Date:   Wed Oct 28 19:25:57 2020 +0300

kvm: fix AMD IBRS/IBPB/STIBP/SSBD reporting #PSBM-120787

We should report these bits in 8008 EBX on AMD only, i.e. when AMD
specific feature bits are enabled.

https://jira.sw.ru/browse/PSBM-120787

Signed-off-by: Denis V. Lunev 
CC: Vasily Averin 
CC: Konstantin Khorenko 

---
 arch/x86/kvm/svm/svm.c |  3 ++-
 arch/x86/kvm/vmx/vmx.c | 10 +++---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 3ea87e4bff90..7c76485f0b6b 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -2547,12 +2547,13 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct 
msr_data *msr)
break;
case MSR_IA32_PRED_CMD:
if (!msr->host_initiated &&
+   !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) &&
!guest_cpuid_has(vcpu, X86_FEATURE_AMD_IBPB))
return 1;
 
if (data & ~PRED_CMD_IBPB)
return 1;
-   if (!boot_cpu_has(X86_FEATURE_AMD_IBPB))
+   if (!boot_cpu_has(X86_FEATURE_IBPB))
return 1;
if (!data)
break;
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 547ef2dd03a7..4411eaf652a6 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -2058,7 +2058,10 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct 
msr_data *msr_info)
break;
case MSR_IA32_SPEC_CTRL:
if (!msr_info->host_initiated &&
-   !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL))
+   !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) &&
+   !guest_cpuid_has(vcpu, X86_FEATURE_AMD_STIBP) &&
+   !guest_cpuid_has(vcpu, X86_FEATURE_AMD_IBRS) &&
+   !guest_cpuid_has(vcpu, X86_FEATURE_AMD_SSBD))
return 1;
 
if (kvm_spec_ctrl_test_value(data))
@@ -2093,12 +2096,13 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct 
msr_data *msr_info)
goto find_shared_msr;
case MSR_IA32_PRED_CMD:
if (!msr_info->host_initiated &&
-   !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL))
+   !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) &&
+   !guest_cpuid_has(vcpu, X86_FEATURE_AMD_IBPB))
return 1;
 
if (data & ~PRED_CMD_IBPB)
return 1;
-   if (!boot_cpu_has(X86_FEATURE_SPEC_CTRL))
+   if (!boot_cpu_has(X86_FEATURE_IBPB))
return 1;
if (!data)
break;
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH RHEL8 COMMIT] Revert "kvm: fix AMD IBRS/IBPB/STIBP/SSBD reporting #PSBM-120787"

2020-12-08 Thread Konstantin Khorenko
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear 
at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.el8
-->
commit eb7aa6cb2a5e6e651f835254e5fb8d1f7524c94c
Author: Konstantin Khorenko 
Date:   Tue Dec 8 13:14:15 2020 +0300

Revert "kvm: fix AMD IBRS/IBPB/STIBP/SSBD reporting #PSBM-120787"

This reverts commit 39d637ddbcf876f897e01c737bbb351461921df0.

We will take the mainstream version of the patch instead:
  From: Paolo Bonzini 
  Subject: [PATCH] KVM: x86: reinstate vendor-agnostic check on SPEC_CTRL 
cpuid bits
  Date: Thu,  3 Dec 2020 10:15:16 -0500
  Message-Id: <20201203151516.14441-1-pbonz...@redhat.com>

Signed-off-by: Konstantin Khorenko 
---
 arch/x86/kvm/cpuid.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index a995faa586a7..d2ce3812633b 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -396,11 +396,11 @@ void kvm_set_cpu_caps(void)
 * arch/x86/kernel/cpu/bugs.c is kind enough to
 * record that in cpufeatures so use them.
 */
-   if (boot_cpu_has( X86_FEATURE_AMD_IBPB))
+   if (boot_cpu_has(X86_FEATURE_IBPB))
kvm_cpu_cap_set(X86_FEATURE_AMD_IBPB);
-   if (boot_cpu_has(X86_FEATURE_AMD_IBRS))
+   if (boot_cpu_has(X86_FEATURE_IBRS))
kvm_cpu_cap_set(X86_FEATURE_AMD_IBRS);
-   if (boot_cpu_has(X86_FEATURE_AMD_STIBP))
+   if (boot_cpu_has(X86_FEATURE_STIBP))
kvm_cpu_cap_set(X86_FEATURE_AMD_STIBP);
if (boot_cpu_has(X86_FEATURE_SPEC_CTRL_SSBD))
kvm_cpu_cap_set(X86_FEATURE_AMD_SSBD);
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


Re: [Devel] [PATCH RHEL8 COMMIT] dm-ploop: Generalize defer_bio() and defer_bio_list()

2020-12-08 Thread Kirill Tkhai
On 07.12.2020 20:31, Konstantin Khorenko wrote:
> The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will 
> appear at https://src.openvz.org/scm/ovz/vzkernel.git
> after rh8-4.18.0-240.1.1.el8
> -->
> commit 2251161515d7aa39fc22d0ed2be193c0475a05b6
> Author: Kirill Tkhai 
> Date:   Fri Dec 4 19:13:11 2020 +0300
> 
> dm-ploop: Generalize defer_bio() and defer_bio_list()
> 
> ..since they do almost the same.
> 
> Fixes: 7264d1dd954a ("dm: Interpreter of ploop1 format (ploop driver)")

I don't understand this. "Fixes:" is tag for BUGs.
 
> Signed-off-by: Kirill Tkhai 
> ---
>  drivers/md/dm-ploop-cmd.c |  2 +-
>  drivers/md/dm-ploop-map.c | 29 +++--
>  drivers/md/dm-ploop.h |  3 +--
>  3 files changed, 13 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
> index 5f2c93579e53..31fa424a88f5 100644
> --- a/drivers/md/dm-ploop-cmd.c
> +++ b/drivers/md/dm-ploop-cmd.c
> @@ -1722,7 +1722,7 @@ static int ploop_push_backup_write(struct ploop *ploop, 
> char *uuid,
>   spin_unlock_irq(&ploop->pb_lock);
>  
>   if (!bio_list_empty(&bio_list)) {
> - defer_bio_list(ploop, &bio_list);
> + defer_bios(ploop, NULL, &bio_list);
>   if (has_more)
>   mod_timer(&pb->deadline_timer, pb->timeout_in_jiffies + 
> 1);
>   }
> diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
> index fadee7b2f0a6..4b12b5fc082a 100644
> --- a/drivers/md/dm-ploop-map.c
> +++ b/drivers/md/dm-ploop-map.c
> @@ -118,23 +118,16 @@ static int ploop_bio_cluster(struct ploop *ploop, 
> struct bio *bio,
>   return 0;
>  }
>  
> -void defer_bio(struct ploop *ploop, struct bio *bio)
> +void defer_bios(struct ploop *ploop, struct bio *bio, struct bio_list *bl)
>  {
>   unsigned long flags;
>  
>   spin_lock_irqsave(&ploop->deferred_lock, flags);
> - bio_list_add(&ploop->deferred_bios, bio);
> - spin_unlock_irqrestore(&ploop->deferred_lock, flags);
> -
> - queue_work(ploop->wq, &ploop->worker);
> -}
> -
> -void defer_bio_list(struct ploop *ploop, struct bio_list *bio_list)
> -{
> - unsigned long flags;
> + if (bio)
> + bio_list_add(&ploop->deferred_bios, bio);
> + if (bl)
> + bio_list_merge(&ploop->deferred_bios, bl);
>  
> - spin_lock_irqsave(&ploop->deferred_lock, flags);
> - bio_list_merge(&ploop->deferred_bios, bio_list);
>   spin_unlock_irqrestore(&ploop->deferred_lock, flags);
>   queue_work(ploop->wq, &ploop->worker);
>  }
> @@ -193,7 +186,7 @@ static int ploop_map_discard(struct ploop *ploop, struct 
> bio *bio)
>   }
>  
>   if (supported) {
> - defer_bio(ploop, bio);
> + defer_bios(ploop, bio, NULL);
>   } else {
>   bio->bi_status = BLK_STS_NOTSUPP;
>   bio_endio(bio);
> @@ -1077,7 +1070,7 @@ static void queue_or_fail(struct ploop *ploop, int err, 
> void *data)
>   bio->bi_status = errno_to_blk_status(err);
>   bio_endio(bio);
>   } else {
> - defer_bio(ploop, bio);
> + defer_bios(ploop, bio, NULL);
>   }
>  }
>  
> @@ -1257,7 +1250,7 @@ static bool locate_new_cluster_and_attach_bio(struct 
> ploop *ploop,
>  
>   if (piwb->page_nr != page_nr || piwb->type != PIWB_TYPE_ALLOC) {
>   /* Another BAT page wb is in process */
> - defer_bio(ploop, bio);
> + defer_bios(ploop, bio, NULL);
>   goto out;
>   }
>  
> @@ -1273,7 +1266,7 @@ static bool locate_new_cluster_and_attach_bio(struct 
> ploop *ploop,
>* batch? Delay submitting. Good thing, that cluster allocation
>* has already made, and it goes in the batch.
>*/
> - defer_bio(ploop, bio);
> + defer_bios(ploop, bio, NULL);
>   }
>  out:
>   return attached;
> @@ -1530,7 +1523,7 @@ void cleanup_backup(struct ploop *ploop)
>   spin_unlock_irq(&ploop->pb_lock);
>  
>   if (!bio_list_empty(&bio_list))
> - defer_bio_list(ploop, &bio_list);
> + defer_bios(ploop, NULL, &bio_list);
>  
>   del_timer_sync(&pb->deadline_timer);
>  }
> @@ -1649,7 +1642,7 @@ int ploop_map(struct dm_target *ti, struct bio *bio)
>  
>   if (!in_top_delta) {
>   if (op_is_write(bio->bi_opf) || dst_cluster != 
> BAT_ENTRY_NONE) {
> - defer_bio(ploop, bio);
> + defer_bios(ploop, bio, NULL);
>   } else {
>   zero_fill_bio(bio);
>   bio_endio(bio);
> diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
> index 5e0c88249dcd..dc5362f01e21 100644
> --- a/drivers/md/dm-ploop.h
> +++ b/drivers/md/dm-ploop.h
> @@ -493,8 +493,7 @@ extern bool try_update_bat_entry(struct ploop *ploop, 
> unsigned int cluster,
> 

Re: [Devel] [PATCH RHEL8 COMMIT] dm-ploop: Add PERCPU_REF_ALLOW_REINIT for refcounter

2020-12-08 Thread Kirill Tkhai
On 07.12.2020 20:31, Konstantin Khorenko wrote:
> The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will 
> appear at https://src.openvz.org/scm/ovz/vzkernel.git
> after rh8-4.18.0-240.1.1.el8
> -->
> commit b304f2465c4e01078d261734ed7c0f106d6928ae
> Author: Kirill Tkhai 
> Date:   Fri Dec 4 19:32:41 2020 +0300
> 
> dm-ploop: Add PERCPU_REF_ALLOW_REINIT for refcounter
> 
> This is for RHEL8.4 rebase. Without the flag,
> refcounter memory is freed early.
> 
> https://jira.sw.ru/browse/PSBM-123433
> 
> Fixes: 7264d1dd954a ("dm: Interpreter of ploop1 format (ploop driver)")

This fixes not this patch. This fixes rebase to RH 
branch-rh8-4.18.0-240.1.1.vz8.5.x

> 
> Signed-off-by: Kirill Tkhai 
> ---
>  drivers/md/dm-ploop-target.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
> index 986617dc1eb8..591f583bc324 100644
> --- a/drivers/md/dm-ploop-target.c
> +++ b/drivers/md/dm-ploop-target.c
> @@ -145,7 +145,7 @@ static int ploop_ctr(struct dm_target *ti, unsigned int 
> argc, char **argv)
>   for (i = 0; i < 2; i++) {
>   release = i ? inflight_bios_ref_exit1 : inflight_bios_ref_exit0;
>   if (percpu_ref_init(&ploop->inflight_bios_ref[i], release,
> - 0, GFP_KERNEL)) {
> + PERCPU_REF_ALLOW_REINIT, GFP_KERNEL)) {
>   ret = -ENOMEM;
>   ti->error = "could not alloc percpu_ref";
>   goto err;
> 

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel