All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] KVM: s390: memcg awareness
@ 2020-11-17 15:10 Christian Borntraeger
  2020-11-17 15:10 ` [PATCH 1/2] KVM: s390: Add memcg accounting to KVM allocations Christian Borntraeger
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Christian Borntraeger @ 2020-11-17 15:10 UTC (permalink / raw)
  To: Janosch Frank
  Cc: KVM, Cornelia Huck, Christian Borntraeger, David Hildenbrand, linux-s390

This got somehow lost.  (so this is kind of a v2)
KVM does have memcg awareness. Lets implement this also for s390kvm
and gmap.

Christian Borntraeger (2):
  KVM: s390: Add memcg accounting to KVM allocations
  s390/gmap: make gmap memcg aware

 arch/s390/kvm/guestdbg.c  |  8 ++++----
 arch/s390/kvm/intercept.c |  2 +-
 arch/s390/kvm/interrupt.c | 10 +++++-----
 arch/s390/kvm/kvm-s390.c  | 20 ++++++++++----------
 arch/s390/kvm/priv.c      |  4 ++--
 arch/s390/kvm/pv.c        |  6 +++---
 arch/s390/kvm/vsie.c      |  4 ++--
 arch/s390/mm/gmap.c       | 30 +++++++++++++++---------------
 8 files changed, 42 insertions(+), 42 deletions(-)

-- 
2.28.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/2] KVM: s390: Add memcg accounting to KVM allocations
  2020-11-17 15:10 [PATCH 0/2] KVM: s390: memcg awareness Christian Borntraeger
@ 2020-11-17 15:10 ` Christian Borntraeger
  2020-11-17 15:22   ` Janosch Frank
  2020-11-23 16:08   ` Cornelia Huck
  2020-11-17 15:10 ` [PATCH 2/2] s390/gmap: make gmap memcg aware Christian Borntraeger
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 10+ messages in thread
From: Christian Borntraeger @ 2020-11-17 15:10 UTC (permalink / raw)
  To: Janosch Frank
  Cc: KVM, Cornelia Huck, Christian Borntraeger, David Hildenbrand,
	linux-s390, Heiko Carstens

Almost all kvm allocations in the s390x KVM code can be attributed to
process that triggers the allocation (in other words, no global
allocation for other guests). This will help the memcg controller to do
the right decisions.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
---
 arch/s390/kvm/guestdbg.c  |  8 ++++----
 arch/s390/kvm/intercept.c |  2 +-
 arch/s390/kvm/interrupt.c | 10 +++++-----
 arch/s390/kvm/kvm-s390.c  | 20 ++++++++++----------
 arch/s390/kvm/priv.c      |  4 ++--
 arch/s390/kvm/pv.c        |  6 +++---
 arch/s390/kvm/vsie.c      |  4 ++--
 7 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/arch/s390/kvm/guestdbg.c b/arch/s390/kvm/guestdbg.c
index 394a5f53805b..3765c4223bf9 100644
--- a/arch/s390/kvm/guestdbg.c
+++ b/arch/s390/kvm/guestdbg.c
@@ -184,7 +184,7 @@ static int __import_wp_info(struct kvm_vcpu *vcpu,
 	if (wp_info->len < 0 || wp_info->len > MAX_WP_SIZE)
 		return -EINVAL;
 
-	wp_info->old_data = kmalloc(bp_data->len, GFP_KERNEL);
+	wp_info->old_data = kmalloc(bp_data->len, GFP_KERNEL_ACCOUNT);
 	if (!wp_info->old_data)
 		return -ENOMEM;
 	/* try to backup the original value */
@@ -234,7 +234,7 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu,
 	if (nr_wp > 0) {
 		wp_info = kmalloc_array(nr_wp,
 					sizeof(*wp_info),
-					GFP_KERNEL);
+					GFP_KERNEL_ACCOUNT);
 		if (!wp_info) {
 			ret = -ENOMEM;
 			goto error;
@@ -243,7 +243,7 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu,
 	if (nr_bp > 0) {
 		bp_info = kmalloc_array(nr_bp,
 					sizeof(*bp_info),
-					GFP_KERNEL);
+					GFP_KERNEL_ACCOUNT);
 		if (!bp_info) {
 			ret = -ENOMEM;
 			goto error;
@@ -349,7 +349,7 @@ static struct kvm_hw_wp_info_arch *any_wp_changed(struct kvm_vcpu *vcpu)
 		if (!wp_info || !wp_info->old_data || wp_info->len <= 0)
 			continue;
 
-		temp = kmalloc(wp_info->len, GFP_KERNEL);
+		temp = kmalloc(wp_info->len, GFP_KERNEL_ACCOUNT);
 		if (!temp)
 			continue;
 
diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c
index e7a7c499a73f..72b25b7cc6ae 100644
--- a/arch/s390/kvm/intercept.c
+++ b/arch/s390/kvm/intercept.c
@@ -398,7 +398,7 @@ int handle_sthyi(struct kvm_vcpu *vcpu)
 	if (!kvm_s390_pv_cpu_is_protected(vcpu) && (addr & ~PAGE_MASK))
 		return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
 
-	sctns = (void *)get_zeroed_page(GFP_KERNEL);
+	sctns = (void *)get_zeroed_page(GFP_KERNEL_ACCOUNT);
 	if (!sctns)
 		return -ENOMEM;
 
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index 2f177298c663..e3183bd05910 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -1792,7 +1792,7 @@ struct kvm_s390_interrupt_info *kvm_s390_get_io_int(struct kvm *kvm,
 		goto out;
 	}
 gisa_out:
-	tmp_inti = kzalloc(sizeof(*inti), GFP_KERNEL);
+	tmp_inti = kzalloc(sizeof(*inti), GFP_KERNEL_ACCOUNT);
 	if (tmp_inti) {
 		tmp_inti->type = KVM_S390_INT_IO(1, 0, 0, 0);
 		tmp_inti->io.io_int_word = isc_to_int_word(isc);
@@ -2015,7 +2015,7 @@ int kvm_s390_inject_vm(struct kvm *kvm,
 	struct kvm_s390_interrupt_info *inti;
 	int rc;
 
-	inti = kzalloc(sizeof(*inti), GFP_KERNEL);
+	inti = kzalloc(sizeof(*inti), GFP_KERNEL_ACCOUNT);
 	if (!inti)
 		return -ENOMEM;
 
@@ -2414,7 +2414,7 @@ static int enqueue_floating_irq(struct kvm_device *dev,
 		return -EINVAL;
 
 	while (len >= sizeof(struct kvm_s390_irq)) {
-		inti = kzalloc(sizeof(*inti), GFP_KERNEL);
+		inti = kzalloc(sizeof(*inti), GFP_KERNEL_ACCOUNT);
 		if (!inti)
 			return -ENOMEM;
 
@@ -2462,7 +2462,7 @@ static int register_io_adapter(struct kvm_device *dev,
 	if (dev->kvm->arch.adapters[adapter_info.id] != NULL)
 		return -EINVAL;
 
-	adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
+	adapter = kzalloc(sizeof(*adapter), GFP_KERNEL_ACCOUNT);
 	if (!adapter)
 		return -ENOMEM;
 
@@ -3290,7 +3290,7 @@ int kvm_s390_gib_init(u8 nisc)
 		goto out;
 	}
 
-	gib = (struct kvm_s390_gib *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
+	gib = (struct kvm_s390_gib *)get_zeroed_page(GFP_KERNEL_ACCOUNT | GFP_DMA);
 	if (!gib) {
 		rc = -ENOMEM;
 		goto out;
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 425d3d75320b..282a13ece554 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -1254,7 +1254,7 @@ static int kvm_s390_set_processor(struct kvm *kvm, struct kvm_device_attr *attr)
 		ret = -EBUSY;
 		goto out;
 	}
-	proc = kzalloc(sizeof(*proc), GFP_KERNEL);
+	proc = kzalloc(sizeof(*proc), GFP_KERNEL_ACCOUNT);
 	if (!proc) {
 		ret = -ENOMEM;
 		goto out;
@@ -1416,7 +1416,7 @@ static int kvm_s390_get_processor(struct kvm *kvm, struct kvm_device_attr *attr)
 	struct kvm_s390_vm_cpu_processor *proc;
 	int ret = 0;
 
-	proc = kzalloc(sizeof(*proc), GFP_KERNEL);
+	proc = kzalloc(sizeof(*proc), GFP_KERNEL_ACCOUNT);
 	if (!proc) {
 		ret = -ENOMEM;
 		goto out;
@@ -1444,7 +1444,7 @@ static int kvm_s390_get_machine(struct kvm *kvm, struct kvm_device_attr *attr)
 	struct kvm_s390_vm_cpu_machine *mach;
 	int ret = 0;
 
-	mach = kzalloc(sizeof(*mach), GFP_KERNEL);
+	mach = kzalloc(sizeof(*mach), GFP_KERNEL_ACCOUNT);
 	if (!mach) {
 		ret = -ENOMEM;
 		goto out;
@@ -1812,7 +1812,7 @@ static long kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
 	if (args->count < 1 || args->count > KVM_S390_SKEYS_MAX)
 		return -EINVAL;
 
-	keys = kvmalloc_array(args->count, sizeof(uint8_t), GFP_KERNEL);
+	keys = kvmalloc_array(args->count, sizeof(uint8_t), GFP_KERNEL_ACCOUNT);
 	if (!keys)
 		return -ENOMEM;
 
@@ -1857,7 +1857,7 @@ static long kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
 	if (args->count < 1 || args->count > KVM_S390_SKEYS_MAX)
 		return -EINVAL;
 
-	keys = kvmalloc_array(args->count, sizeof(uint8_t), GFP_KERNEL);
+	keys = kvmalloc_array(args->count, sizeof(uint8_t), GFP_KERNEL_ACCOUNT);
 	if (!keys)
 		return -ENOMEM;
 
@@ -2625,7 +2625,7 @@ static void sca_dispose(struct kvm *kvm)
 
 int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 {
-	gfp_t alloc_flags = GFP_KERNEL;
+	gfp_t alloc_flags = GFP_KERNEL_ACCOUNT;
 	int i, rc;
 	char debug_name[16];
 	static unsigned long sca_offset;
@@ -2670,7 +2670,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 
 	BUILD_BUG_ON(sizeof(struct sie_page2) != 4096);
 	kvm->arch.sie_page2 =
-	     (struct sie_page2 *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
+	     (struct sie_page2 *) get_zeroed_page(GFP_KERNEL_ACCOUNT | GFP_DMA);
 	if (!kvm->arch.sie_page2)
 		goto out_err;
 
@@ -2900,7 +2900,7 @@ static int sca_switch_to_extended(struct kvm *kvm)
 	if (kvm->arch.use_esca)
 		return 0;
 
-	new_sca = alloc_pages_exact(sizeof(*new_sca), GFP_KERNEL|__GFP_ZERO);
+	new_sca = alloc_pages_exact(sizeof(*new_sca), GFP_KERNEL_ACCOUNT | __GFP_ZERO);
 	if (!new_sca)
 		return -ENOMEM;
 
@@ -3133,7 +3133,7 @@ void kvm_s390_vcpu_unsetup_cmma(struct kvm_vcpu *vcpu)
 
 int kvm_s390_vcpu_setup_cmma(struct kvm_vcpu *vcpu)
 {
-	vcpu->arch.sie_block->cbrlo = get_zeroed_page(GFP_KERNEL);
+	vcpu->arch.sie_block->cbrlo = get_zeroed_page(GFP_KERNEL_ACCOUNT);
 	if (!vcpu->arch.sie_block->cbrlo)
 		return -ENOMEM;
 	return 0;
@@ -3243,7 +3243,7 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
 	int rc;
 
 	BUILD_BUG_ON(sizeof(struct sie_page) != 4096);
-	sie_page = (struct sie_page *) get_zeroed_page(GFP_KERNEL);
+	sie_page = (struct sie_page *) get_zeroed_page(GFP_KERNEL_ACCOUNT);
 	if (!sie_page)
 		return -ENOMEM;
 
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index cd74989ce0b0..9928f785c677 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -879,7 +879,7 @@ static int handle_stsi(struct kvm_vcpu *vcpu)
 	switch (fc) {
 	case 1: /* same handling for 1 and 2 */
 	case 2:
-		mem = get_zeroed_page(GFP_KERNEL);
+		mem = get_zeroed_page(GFP_KERNEL_ACCOUNT);
 		if (!mem)
 			goto out_no_data;
 		if (stsi((void *) mem, fc, sel1, sel2))
@@ -888,7 +888,7 @@ static int handle_stsi(struct kvm_vcpu *vcpu)
 	case 3:
 		if (sel1 != 2 || sel2 != 2)
 			goto out_no_data;
-		mem = get_zeroed_page(GFP_KERNEL);
+		mem = get_zeroed_page(GFP_KERNEL_ACCOUNT);
 		if (!mem)
 			goto out_no_data;
 		handle_stsi_3_2_2(vcpu, (void *) mem);
diff --git a/arch/s390/kvm/pv.c b/arch/s390/kvm/pv.c
index f5847f9dec7c..813b6e93dc83 100644
--- a/arch/s390/kvm/pv.c
+++ b/arch/s390/kvm/pv.c
@@ -60,7 +60,7 @@ int kvm_s390_pv_create_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc)
 	if (kvm_s390_pv_cpu_get_handle(vcpu))
 		return -EINVAL;
 
-	vcpu->arch.pv.stor_base = __get_free_pages(GFP_KERNEL,
+	vcpu->arch.pv.stor_base = __get_free_pages(GFP_KERNEL_ACCOUNT,
 						   get_order(uv_info.guest_cpu_stor_len));
 	if (!vcpu->arch.pv.stor_base)
 		return -ENOMEM;
@@ -72,7 +72,7 @@ int kvm_s390_pv_create_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc)
 	uvcb.stor_origin = (u64)vcpu->arch.pv.stor_base;
 
 	/* Alloc Secure Instruction Data Area Designation */
-	vcpu->arch.sie_block->sidad = __get_free_page(GFP_KERNEL | __GFP_ZERO);
+	vcpu->arch.sie_block->sidad = __get_free_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO);
 	if (!vcpu->arch.sie_block->sidad) {
 		free_pages(vcpu->arch.pv.stor_base,
 			   get_order(uv_info.guest_cpu_stor_len));
@@ -120,7 +120,7 @@ static int kvm_s390_pv_alloc_vm(struct kvm *kvm)
 	struct kvm_memory_slot *memslot;
 
 	kvm->arch.pv.stor_var = NULL;
-	kvm->arch.pv.stor_base = __get_free_pages(GFP_KERNEL, get_order(base));
+	kvm->arch.pv.stor_base = __get_free_pages(GFP_KERNEL_ACCOUNT, get_order(base));
 	if (!kvm->arch.pv.stor_base)
 		return -ENOMEM;
 
diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
index 4f3cbf6003a9..c5d0a58b2c29 100644
--- a/arch/s390/kvm/vsie.c
+++ b/arch/s390/kvm/vsie.c
@@ -1234,7 +1234,7 @@ static struct vsie_page *get_vsie_page(struct kvm *kvm, unsigned long addr)
 
 	mutex_lock(&kvm->arch.vsie.mutex);
 	if (kvm->arch.vsie.page_count < nr_vcpus) {
-		page = alloc_page(GFP_KERNEL | __GFP_ZERO | GFP_DMA);
+		page = alloc_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO | GFP_DMA);
 		if (!page) {
 			mutex_unlock(&kvm->arch.vsie.mutex);
 			return ERR_PTR(-ENOMEM);
@@ -1336,7 +1336,7 @@ int kvm_s390_handle_vsie(struct kvm_vcpu *vcpu)
 void kvm_s390_vsie_init(struct kvm *kvm)
 {
 	mutex_init(&kvm->arch.vsie.mutex);
-	INIT_RADIX_TREE(&kvm->arch.vsie.addr_to_page, GFP_KERNEL);
+	INIT_RADIX_TREE(&kvm->arch.vsie.addr_to_page, GFP_KERNEL_ACCOUNT);
 }
 
 /* Destroy the vsie data structures. To be called when a vm is destroyed. */
-- 
2.28.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] s390/gmap: make gmap memcg aware
  2020-11-17 15:10 [PATCH 0/2] KVM: s390: memcg awareness Christian Borntraeger
  2020-11-17 15:10 ` [PATCH 1/2] KVM: s390: Add memcg accounting to KVM allocations Christian Borntraeger
@ 2020-11-17 15:10 ` Christian Borntraeger
  2020-11-17 15:22   ` Janosch Frank
  2020-11-23 16:10   ` Cornelia Huck
  2020-11-17 15:23 ` [PATCH 0/2] KVM: s390: memcg awareness David Hildenbrand
  2020-11-23 17:15 ` Christian Borntraeger
  3 siblings, 2 replies; 10+ messages in thread
From: Christian Borntraeger @ 2020-11-17 15:10 UTC (permalink / raw)
  To: Janosch Frank
  Cc: KVM, Cornelia Huck, Christian Borntraeger, David Hildenbrand,
	linux-s390, Heiko Carstens

gmap allocations can be attributed to a process.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
---
 arch/s390/mm/gmap.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c
index 64795d034926..9bb2c7512cd5 100644
--- a/arch/s390/mm/gmap.c
+++ b/arch/s390/mm/gmap.c
@@ -2,7 +2,7 @@
 /*
  *  KVM guest address space mapping code
  *
- *    Copyright IBM Corp. 2007, 2016, 2018
+ *    Copyright IBM Corp. 2007, 2020
  *    Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
  *		 David Hildenbrand <david@redhat.com>
  *		 Janosch Frank <frankja@linux.vnet.ibm.com>
@@ -56,19 +56,19 @@ static struct gmap *gmap_alloc(unsigned long limit)
 		atype = _ASCE_TYPE_REGION1;
 		etype = _REGION1_ENTRY_EMPTY;
 	}
-	gmap = kzalloc(sizeof(struct gmap), GFP_KERNEL);
+	gmap = kzalloc(sizeof(struct gmap), GFP_KERNEL_ACCOUNT);
 	if (!gmap)
 		goto out;
 	INIT_LIST_HEAD(&gmap->crst_list);
 	INIT_LIST_HEAD(&gmap->children);
 	INIT_LIST_HEAD(&gmap->pt_list);
-	INIT_RADIX_TREE(&gmap->guest_to_host, GFP_KERNEL);
-	INIT_RADIX_TREE(&gmap->host_to_guest, GFP_ATOMIC);
-	INIT_RADIX_TREE(&gmap->host_to_rmap, GFP_ATOMIC);
+	INIT_RADIX_TREE(&gmap->guest_to_host, GFP_KERNEL_ACCOUNT);
+	INIT_RADIX_TREE(&gmap->host_to_guest, GFP_ATOMIC | __GFP_ACCOUNT);
+	INIT_RADIX_TREE(&gmap->host_to_rmap, GFP_ATOMIC | __GFP_ACCOUNT);
 	spin_lock_init(&gmap->guest_table_lock);
 	spin_lock_init(&gmap->shadow_lock);
 	refcount_set(&gmap->ref_count, 1);
-	page = alloc_pages(GFP_KERNEL, CRST_ALLOC_ORDER);
+	page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
 	if (!page)
 		goto out_free;
 	page->index = 0;
@@ -309,7 +309,7 @@ static int gmap_alloc_table(struct gmap *gmap, unsigned long *table,
 	unsigned long *new;
 
 	/* since we dont free the gmap table until gmap_free we can unlock */
-	page = alloc_pages(GFP_KERNEL, CRST_ALLOC_ORDER);
+	page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
 	if (!page)
 		return -ENOMEM;
 	new = (unsigned long *) page_to_phys(page);
@@ -594,7 +594,7 @@ int __gmap_link(struct gmap *gmap, unsigned long gaddr, unsigned long vmaddr)
 	if (pmd_large(*pmd) && !gmap->mm->context.allow_gmap_hpage_1m)
 		return -EFAULT;
 	/* Link gmap segment table entry location to page table. */
-	rc = radix_tree_preload(GFP_KERNEL);
+	rc = radix_tree_preload(GFP_KERNEL_ACCOUNT);
 	if (rc)
 		return rc;
 	ptl = pmd_lock(mm, pmd);
@@ -1218,11 +1218,11 @@ static int gmap_protect_rmap(struct gmap *sg, unsigned long raddr,
 		vmaddr = __gmap_translate(parent, paddr);
 		if (IS_ERR_VALUE(vmaddr))
 			return vmaddr;
-		rmap = kzalloc(sizeof(*rmap), GFP_KERNEL);
+		rmap = kzalloc(sizeof(*rmap), GFP_KERNEL_ACCOUNT);
 		if (!rmap)
 			return -ENOMEM;
 		rmap->raddr = raddr;
-		rc = radix_tree_preload(GFP_KERNEL);
+		rc = radix_tree_preload(GFP_KERNEL_ACCOUNT);
 		if (rc) {
 			kfree(rmap);
 			return rc;
@@ -1741,7 +1741,7 @@ int gmap_shadow_r2t(struct gmap *sg, unsigned long saddr, unsigned long r2t,
 
 	BUG_ON(!gmap_is_shadow(sg));
 	/* Allocate a shadow region second table */
-	page = alloc_pages(GFP_KERNEL, CRST_ALLOC_ORDER);
+	page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
 	if (!page)
 		return -ENOMEM;
 	page->index = r2t & _REGION_ENTRY_ORIGIN;
@@ -1825,7 +1825,7 @@ int gmap_shadow_r3t(struct gmap *sg, unsigned long saddr, unsigned long r3t,
 
 	BUG_ON(!gmap_is_shadow(sg));
 	/* Allocate a shadow region second table */
-	page = alloc_pages(GFP_KERNEL, CRST_ALLOC_ORDER);
+	page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
 	if (!page)
 		return -ENOMEM;
 	page->index = r3t & _REGION_ENTRY_ORIGIN;
@@ -1909,7 +1909,7 @@ int gmap_shadow_sgt(struct gmap *sg, unsigned long saddr, unsigned long sgt,
 
 	BUG_ON(!gmap_is_shadow(sg) || (sgt & _REGION3_ENTRY_LARGE));
 	/* Allocate a shadow segment table */
-	page = alloc_pages(GFP_KERNEL, CRST_ALLOC_ORDER);
+	page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
 	if (!page)
 		return -ENOMEM;
 	page->index = sgt & _REGION_ENTRY_ORIGIN;
@@ -2116,7 +2116,7 @@ int gmap_shadow_page(struct gmap *sg, unsigned long saddr, pte_t pte)
 	parent = sg->parent;
 	prot = (pte_val(pte) & _PAGE_PROTECT) ? PROT_READ : PROT_WRITE;
 
-	rmap = kzalloc(sizeof(*rmap), GFP_KERNEL);
+	rmap = kzalloc(sizeof(*rmap), GFP_KERNEL_ACCOUNT);
 	if (!rmap)
 		return -ENOMEM;
 	rmap->raddr = (saddr & PAGE_MASK) | _SHADOW_RMAP_PGTABLE;
@@ -2128,7 +2128,7 @@ int gmap_shadow_page(struct gmap *sg, unsigned long saddr, pte_t pte)
 			rc = vmaddr;
 			break;
 		}
-		rc = radix_tree_preload(GFP_KERNEL);
+		rc = radix_tree_preload(GFP_KERNEL_ACCOUNT);
 		if (rc)
 			break;
 		rc = -EAGAIN;
-- 
2.28.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] s390/gmap: make gmap memcg aware
  2020-11-17 15:10 ` [PATCH 2/2] s390/gmap: make gmap memcg aware Christian Borntraeger
@ 2020-11-17 15:22   ` Janosch Frank
  2020-11-17 15:31     ` Christian Borntraeger
  2020-11-23 16:10   ` Cornelia Huck
  1 sibling, 1 reply; 10+ messages in thread
From: Janosch Frank @ 2020-11-17 15:22 UTC (permalink / raw)
  To: Christian Borntraeger, Janosch Frank
  Cc: KVM, Cornelia Huck, David Hildenbrand, linux-s390, Heiko Carstens


[-- Attachment #1.1.1: Type: text/plain, Size: 5280 bytes --]

On 11/17/20 4:10 PM, Christian Borntraeger wrote:
> gmap allocations can be attributed to a process.
> 
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Acked-by: Heiko Carstens <hca@linux.ibm.com>
> ---
>  arch/s390/mm/gmap.c | 30 +++++++++++++++---------------
>  1 file changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c
> index 64795d034926..9bb2c7512cd5 100644
> --- a/arch/s390/mm/gmap.c
> +++ b/arch/s390/mm/gmap.c
> @@ -2,7 +2,7 @@
>  /*
>   *  KVM guest address space mapping code
>   *
> - *    Copyright IBM Corp. 2007, 2016, 2018
> + *    Copyright IBM Corp. 2007, 2020

Do you mean 2007 - 2020 or did you drop the 2016 and 2018?
How does this even work?

Acked-by: Janosch Frank <frankja@linux.ibm.com>


>   *    Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
>   *		 David Hildenbrand <david@redhat.com>
>   *		 Janosch Frank <frankja@linux.vnet.ibm.com>
> @@ -56,19 +56,19 @@ static struct gmap *gmap_alloc(unsigned long limit)
>  		atype = _ASCE_TYPE_REGION1;
>  		etype = _REGION1_ENTRY_EMPTY;
>  	}
> -	gmap = kzalloc(sizeof(struct gmap), GFP_KERNEL);
> +	gmap = kzalloc(sizeof(struct gmap), GFP_KERNEL_ACCOUNT);
>  	if (!gmap)
>  		goto out;
>  	INIT_LIST_HEAD(&gmap->crst_list);
>  	INIT_LIST_HEAD(&gmap->children);
>  	INIT_LIST_HEAD(&gmap->pt_list);
> -	INIT_RADIX_TREE(&gmap->guest_to_host, GFP_KERNEL);
> -	INIT_RADIX_TREE(&gmap->host_to_guest, GFP_ATOMIC);
> -	INIT_RADIX_TREE(&gmap->host_to_rmap, GFP_ATOMIC);
> +	INIT_RADIX_TREE(&gmap->guest_to_host, GFP_KERNEL_ACCOUNT);
> +	INIT_RADIX_TREE(&gmap->host_to_guest, GFP_ATOMIC | __GFP_ACCOUNT);
> +	INIT_RADIX_TREE(&gmap->host_to_rmap, GFP_ATOMIC | __GFP_ACCOUNT);
>  	spin_lock_init(&gmap->guest_table_lock);
>  	spin_lock_init(&gmap->shadow_lock);
>  	refcount_set(&gmap->ref_count, 1);
> -	page = alloc_pages(GFP_KERNEL, CRST_ALLOC_ORDER);
> +	page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
>  	if (!page)
>  		goto out_free;
>  	page->index = 0;
> @@ -309,7 +309,7 @@ static int gmap_alloc_table(struct gmap *gmap, unsigned long *table,
>  	unsigned long *new;
> 
>  	/* since we dont free the gmap table until gmap_free we can unlock */
> -	page = alloc_pages(GFP_KERNEL, CRST_ALLOC_ORDER);
> +	page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
>  	if (!page)
>  		return -ENOMEM;
>  	new = (unsigned long *) page_to_phys(page);
> @@ -594,7 +594,7 @@ int __gmap_link(struct gmap *gmap, unsigned long gaddr, unsigned long vmaddr)
>  	if (pmd_large(*pmd) && !gmap->mm->context.allow_gmap_hpage_1m)
>  		return -EFAULT;
>  	/* Link gmap segment table entry location to page table. */
> -	rc = radix_tree_preload(GFP_KERNEL);
> +	rc = radix_tree_preload(GFP_KERNEL_ACCOUNT);
>  	if (rc)
>  		return rc;
>  	ptl = pmd_lock(mm, pmd);
> @@ -1218,11 +1218,11 @@ static int gmap_protect_rmap(struct gmap *sg, unsigned long raddr,
>  		vmaddr = __gmap_translate(parent, paddr);
>  		if (IS_ERR_VALUE(vmaddr))
>  			return vmaddr;
> -		rmap = kzalloc(sizeof(*rmap), GFP_KERNEL);
> +		rmap = kzalloc(sizeof(*rmap), GFP_KERNEL_ACCOUNT);
>  		if (!rmap)
>  			return -ENOMEM;
>  		rmap->raddr = raddr;
> -		rc = radix_tree_preload(GFP_KERNEL);
> +		rc = radix_tree_preload(GFP_KERNEL_ACCOUNT);
>  		if (rc) {
>  			kfree(rmap);
>  			return rc;
> @@ -1741,7 +1741,7 @@ int gmap_shadow_r2t(struct gmap *sg, unsigned long saddr, unsigned long r2t,
> 
>  	BUG_ON(!gmap_is_shadow(sg));
>  	/* Allocate a shadow region second table */
> -	page = alloc_pages(GFP_KERNEL, CRST_ALLOC_ORDER);
> +	page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
>  	if (!page)
>  		return -ENOMEM;
>  	page->index = r2t & _REGION_ENTRY_ORIGIN;
> @@ -1825,7 +1825,7 @@ int gmap_shadow_r3t(struct gmap *sg, unsigned long saddr, unsigned long r3t,
> 
>  	BUG_ON(!gmap_is_shadow(sg));
>  	/* Allocate a shadow region second table */
> -	page = alloc_pages(GFP_KERNEL, CRST_ALLOC_ORDER);
> +	page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
>  	if (!page)
>  		return -ENOMEM;
>  	page->index = r3t & _REGION_ENTRY_ORIGIN;
> @@ -1909,7 +1909,7 @@ int gmap_shadow_sgt(struct gmap *sg, unsigned long saddr, unsigned long sgt,
> 
>  	BUG_ON(!gmap_is_shadow(sg) || (sgt & _REGION3_ENTRY_LARGE));
>  	/* Allocate a shadow segment table */
> -	page = alloc_pages(GFP_KERNEL, CRST_ALLOC_ORDER);
> +	page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER);
>  	if (!page)
>  		return -ENOMEM;
>  	page->index = sgt & _REGION_ENTRY_ORIGIN;
> @@ -2116,7 +2116,7 @@ int gmap_shadow_page(struct gmap *sg, unsigned long saddr, pte_t pte)
>  	parent = sg->parent;
>  	prot = (pte_val(pte) & _PAGE_PROTECT) ? PROT_READ : PROT_WRITE;
> 
> -	rmap = kzalloc(sizeof(*rmap), GFP_KERNEL);
> +	rmap = kzalloc(sizeof(*rmap), GFP_KERNEL_ACCOUNT);
>  	if (!rmap)
>  		return -ENOMEM;
>  	rmap->raddr = (saddr & PAGE_MASK) | _SHADOW_RMAP_PGTABLE;
> @@ -2128,7 +2128,7 @@ int gmap_shadow_page(struct gmap *sg, unsigned long saddr, pte_t pte)
>  			rc = vmaddr;
>  			break;
>  		}
> -		rc = radix_tree_preload(GFP_KERNEL);
> +		rc = radix_tree_preload(GFP_KERNEL_ACCOUNT);
>  		if (rc)
>  			break;
>  		rc = -EAGAIN;
> 


[-- Attachment #1.1.2: OpenPGP_0xE354E6B8E238B9F8.asc --]
[-- Type: application/pgp-keys, Size: 7995 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] KVM: s390: Add memcg accounting to KVM allocations
  2020-11-17 15:10 ` [PATCH 1/2] KVM: s390: Add memcg accounting to KVM allocations Christian Borntraeger
@ 2020-11-17 15:22   ` Janosch Frank
  2020-11-23 16:08   ` Cornelia Huck
  1 sibling, 0 replies; 10+ messages in thread
From: Janosch Frank @ 2020-11-17 15:22 UTC (permalink / raw)
  To: Christian Borntraeger, Janosch Frank
  Cc: KVM, Cornelia Huck, David Hildenbrand, linux-s390, Heiko Carstens


[-- Attachment #1.1.1: Type: text/plain, Size: 11343 bytes --]

On 11/17/20 4:10 PM, Christian Borntraeger wrote:
> Almost all kvm allocations in the s390x KVM code can be attributed to
> process that triggers the allocation (in other words, no global
> allocation for other guests). This will help the memcg controller to do
> the right decisions.
> 
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Acked-by: Heiko Carstens <hca@linux.ibm.com>

Acked-by: Janosch Frank <frankja@linux.ibm.com>

> ---
>  arch/s390/kvm/guestdbg.c  |  8 ++++----
>  arch/s390/kvm/intercept.c |  2 +-
>  arch/s390/kvm/interrupt.c | 10 +++++-----
>  arch/s390/kvm/kvm-s390.c  | 20 ++++++++++----------
>  arch/s390/kvm/priv.c      |  4 ++--
>  arch/s390/kvm/pv.c        |  6 +++---
>  arch/s390/kvm/vsie.c      |  4 ++--
>  7 files changed, 27 insertions(+), 27 deletions(-)
> 
> diff --git a/arch/s390/kvm/guestdbg.c b/arch/s390/kvm/guestdbg.c
> index 394a5f53805b..3765c4223bf9 100644
> --- a/arch/s390/kvm/guestdbg.c
> +++ b/arch/s390/kvm/guestdbg.c
> @@ -184,7 +184,7 @@ static int __import_wp_info(struct kvm_vcpu *vcpu,
>  	if (wp_info->len < 0 || wp_info->len > MAX_WP_SIZE)
>  		return -EINVAL;
> 
> -	wp_info->old_data = kmalloc(bp_data->len, GFP_KERNEL);
> +	wp_info->old_data = kmalloc(bp_data->len, GFP_KERNEL_ACCOUNT);
>  	if (!wp_info->old_data)
>  		return -ENOMEM;
>  	/* try to backup the original value */
> @@ -234,7 +234,7 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu,
>  	if (nr_wp > 0) {
>  		wp_info = kmalloc_array(nr_wp,
>  					sizeof(*wp_info),
> -					GFP_KERNEL);
> +					GFP_KERNEL_ACCOUNT);
>  		if (!wp_info) {
>  			ret = -ENOMEM;
>  			goto error;
> @@ -243,7 +243,7 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu,
>  	if (nr_bp > 0) {
>  		bp_info = kmalloc_array(nr_bp,
>  					sizeof(*bp_info),
> -					GFP_KERNEL);
> +					GFP_KERNEL_ACCOUNT);
>  		if (!bp_info) {
>  			ret = -ENOMEM;
>  			goto error;
> @@ -349,7 +349,7 @@ static struct kvm_hw_wp_info_arch *any_wp_changed(struct kvm_vcpu *vcpu)
>  		if (!wp_info || !wp_info->old_data || wp_info->len <= 0)
>  			continue;
> 
> -		temp = kmalloc(wp_info->len, GFP_KERNEL);
> +		temp = kmalloc(wp_info->len, GFP_KERNEL_ACCOUNT);
>  		if (!temp)
>  			continue;
> 
> diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c
> index e7a7c499a73f..72b25b7cc6ae 100644
> --- a/arch/s390/kvm/intercept.c
> +++ b/arch/s390/kvm/intercept.c
> @@ -398,7 +398,7 @@ int handle_sthyi(struct kvm_vcpu *vcpu)
>  	if (!kvm_s390_pv_cpu_is_protected(vcpu) && (addr & ~PAGE_MASK))
>  		return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
> 
> -	sctns = (void *)get_zeroed_page(GFP_KERNEL);
> +	sctns = (void *)get_zeroed_page(GFP_KERNEL_ACCOUNT);
>  	if (!sctns)
>  		return -ENOMEM;
> 
> diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
> index 2f177298c663..e3183bd05910 100644
> --- a/arch/s390/kvm/interrupt.c
> +++ b/arch/s390/kvm/interrupt.c
> @@ -1792,7 +1792,7 @@ struct kvm_s390_interrupt_info *kvm_s390_get_io_int(struct kvm *kvm,
>  		goto out;
>  	}
>  gisa_out:
> -	tmp_inti = kzalloc(sizeof(*inti), GFP_KERNEL);
> +	tmp_inti = kzalloc(sizeof(*inti), GFP_KERNEL_ACCOUNT);
>  	if (tmp_inti) {
>  		tmp_inti->type = KVM_S390_INT_IO(1, 0, 0, 0);
>  		tmp_inti->io.io_int_word = isc_to_int_word(isc);
> @@ -2015,7 +2015,7 @@ int kvm_s390_inject_vm(struct kvm *kvm,
>  	struct kvm_s390_interrupt_info *inti;
>  	int rc;
> 
> -	inti = kzalloc(sizeof(*inti), GFP_KERNEL);
> +	inti = kzalloc(sizeof(*inti), GFP_KERNEL_ACCOUNT);
>  	if (!inti)
>  		return -ENOMEM;
> 
> @@ -2414,7 +2414,7 @@ static int enqueue_floating_irq(struct kvm_device *dev,
>  		return -EINVAL;
> 
>  	while (len >= sizeof(struct kvm_s390_irq)) {
> -		inti = kzalloc(sizeof(*inti), GFP_KERNEL);
> +		inti = kzalloc(sizeof(*inti), GFP_KERNEL_ACCOUNT);
>  		if (!inti)
>  			return -ENOMEM;
> 
> @@ -2462,7 +2462,7 @@ static int register_io_adapter(struct kvm_device *dev,
>  	if (dev->kvm->arch.adapters[adapter_info.id] != NULL)
>  		return -EINVAL;
> 
> -	adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
> +	adapter = kzalloc(sizeof(*adapter), GFP_KERNEL_ACCOUNT);
>  	if (!adapter)
>  		return -ENOMEM;
> 
> @@ -3290,7 +3290,7 @@ int kvm_s390_gib_init(u8 nisc)
>  		goto out;
>  	}
> 
> -	gib = (struct kvm_s390_gib *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
> +	gib = (struct kvm_s390_gib *)get_zeroed_page(GFP_KERNEL_ACCOUNT | GFP_DMA);
>  	if (!gib) {
>  		rc = -ENOMEM;
>  		goto out;
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index 425d3d75320b..282a13ece554 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -1254,7 +1254,7 @@ static int kvm_s390_set_processor(struct kvm *kvm, struct kvm_device_attr *attr)
>  		ret = -EBUSY;
>  		goto out;
>  	}
> -	proc = kzalloc(sizeof(*proc), GFP_KERNEL);
> +	proc = kzalloc(sizeof(*proc), GFP_KERNEL_ACCOUNT);
>  	if (!proc) {
>  		ret = -ENOMEM;
>  		goto out;
> @@ -1416,7 +1416,7 @@ static int kvm_s390_get_processor(struct kvm *kvm, struct kvm_device_attr *attr)
>  	struct kvm_s390_vm_cpu_processor *proc;
>  	int ret = 0;
> 
> -	proc = kzalloc(sizeof(*proc), GFP_KERNEL);
> +	proc = kzalloc(sizeof(*proc), GFP_KERNEL_ACCOUNT);
>  	if (!proc) {
>  		ret = -ENOMEM;
>  		goto out;
> @@ -1444,7 +1444,7 @@ static int kvm_s390_get_machine(struct kvm *kvm, struct kvm_device_attr *attr)
>  	struct kvm_s390_vm_cpu_machine *mach;
>  	int ret = 0;
> 
> -	mach = kzalloc(sizeof(*mach), GFP_KERNEL);
> +	mach = kzalloc(sizeof(*mach), GFP_KERNEL_ACCOUNT);
>  	if (!mach) {
>  		ret = -ENOMEM;
>  		goto out;
> @@ -1812,7 +1812,7 @@ static long kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
>  	if (args->count < 1 || args->count > KVM_S390_SKEYS_MAX)
>  		return -EINVAL;
> 
> -	keys = kvmalloc_array(args->count, sizeof(uint8_t), GFP_KERNEL);
> +	keys = kvmalloc_array(args->count, sizeof(uint8_t), GFP_KERNEL_ACCOUNT);
>  	if (!keys)
>  		return -ENOMEM;
> 
> @@ -1857,7 +1857,7 @@ static long kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
>  	if (args->count < 1 || args->count > KVM_S390_SKEYS_MAX)
>  		return -EINVAL;
> 
> -	keys = kvmalloc_array(args->count, sizeof(uint8_t), GFP_KERNEL);
> +	keys = kvmalloc_array(args->count, sizeof(uint8_t), GFP_KERNEL_ACCOUNT);
>  	if (!keys)
>  		return -ENOMEM;
> 
> @@ -2625,7 +2625,7 @@ static void sca_dispose(struct kvm *kvm)
> 
>  int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
>  {
> -	gfp_t alloc_flags = GFP_KERNEL;
> +	gfp_t alloc_flags = GFP_KERNEL_ACCOUNT;
>  	int i, rc;
>  	char debug_name[16];
>  	static unsigned long sca_offset;
> @@ -2670,7 +2670,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
> 
>  	BUILD_BUG_ON(sizeof(struct sie_page2) != 4096);
>  	kvm->arch.sie_page2 =
> -	     (struct sie_page2 *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
> +	     (struct sie_page2 *) get_zeroed_page(GFP_KERNEL_ACCOUNT | GFP_DMA);
>  	if (!kvm->arch.sie_page2)
>  		goto out_err;
> 
> @@ -2900,7 +2900,7 @@ static int sca_switch_to_extended(struct kvm *kvm)
>  	if (kvm->arch.use_esca)
>  		return 0;
> 
> -	new_sca = alloc_pages_exact(sizeof(*new_sca), GFP_KERNEL|__GFP_ZERO);
> +	new_sca = alloc_pages_exact(sizeof(*new_sca), GFP_KERNEL_ACCOUNT | __GFP_ZERO);
>  	if (!new_sca)
>  		return -ENOMEM;
> 
> @@ -3133,7 +3133,7 @@ void kvm_s390_vcpu_unsetup_cmma(struct kvm_vcpu *vcpu)
> 
>  int kvm_s390_vcpu_setup_cmma(struct kvm_vcpu *vcpu)
>  {
> -	vcpu->arch.sie_block->cbrlo = get_zeroed_page(GFP_KERNEL);
> +	vcpu->arch.sie_block->cbrlo = get_zeroed_page(GFP_KERNEL_ACCOUNT);
>  	if (!vcpu->arch.sie_block->cbrlo)
>  		return -ENOMEM;
>  	return 0;
> @@ -3243,7 +3243,7 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
>  	int rc;
> 
>  	BUILD_BUG_ON(sizeof(struct sie_page) != 4096);
> -	sie_page = (struct sie_page *) get_zeroed_page(GFP_KERNEL);
> +	sie_page = (struct sie_page *) get_zeroed_page(GFP_KERNEL_ACCOUNT);
>  	if (!sie_page)
>  		return -ENOMEM;
> 
> diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
> index cd74989ce0b0..9928f785c677 100644
> --- a/arch/s390/kvm/priv.c
> +++ b/arch/s390/kvm/priv.c
> @@ -879,7 +879,7 @@ static int handle_stsi(struct kvm_vcpu *vcpu)
>  	switch (fc) {
>  	case 1: /* same handling for 1 and 2 */
>  	case 2:
> -		mem = get_zeroed_page(GFP_KERNEL);
> +		mem = get_zeroed_page(GFP_KERNEL_ACCOUNT);
>  		if (!mem)
>  			goto out_no_data;
>  		if (stsi((void *) mem, fc, sel1, sel2))
> @@ -888,7 +888,7 @@ static int handle_stsi(struct kvm_vcpu *vcpu)
>  	case 3:
>  		if (sel1 != 2 || sel2 != 2)
>  			goto out_no_data;
> -		mem = get_zeroed_page(GFP_KERNEL);
> +		mem = get_zeroed_page(GFP_KERNEL_ACCOUNT);
>  		if (!mem)
>  			goto out_no_data;
>  		handle_stsi_3_2_2(vcpu, (void *) mem);
> diff --git a/arch/s390/kvm/pv.c b/arch/s390/kvm/pv.c
> index f5847f9dec7c..813b6e93dc83 100644
> --- a/arch/s390/kvm/pv.c
> +++ b/arch/s390/kvm/pv.c
> @@ -60,7 +60,7 @@ int kvm_s390_pv_create_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc)
>  	if (kvm_s390_pv_cpu_get_handle(vcpu))
>  		return -EINVAL;
> 
> -	vcpu->arch.pv.stor_base = __get_free_pages(GFP_KERNEL,
> +	vcpu->arch.pv.stor_base = __get_free_pages(GFP_KERNEL_ACCOUNT,
>  						   get_order(uv_info.guest_cpu_stor_len));
>  	if (!vcpu->arch.pv.stor_base)
>  		return -ENOMEM;
> @@ -72,7 +72,7 @@ int kvm_s390_pv_create_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc)
>  	uvcb.stor_origin = (u64)vcpu->arch.pv.stor_base;
> 
>  	/* Alloc Secure Instruction Data Area Designation */
> -	vcpu->arch.sie_block->sidad = __get_free_page(GFP_KERNEL | __GFP_ZERO);
> +	vcpu->arch.sie_block->sidad = __get_free_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO);
>  	if (!vcpu->arch.sie_block->sidad) {
>  		free_pages(vcpu->arch.pv.stor_base,
>  			   get_order(uv_info.guest_cpu_stor_len));
> @@ -120,7 +120,7 @@ static int kvm_s390_pv_alloc_vm(struct kvm *kvm)
>  	struct kvm_memory_slot *memslot;
> 
>  	kvm->arch.pv.stor_var = NULL;
> -	kvm->arch.pv.stor_base = __get_free_pages(GFP_KERNEL, get_order(base));
> +	kvm->arch.pv.stor_base = __get_free_pages(GFP_KERNEL_ACCOUNT, get_order(base));
>  	if (!kvm->arch.pv.stor_base)
>  		return -ENOMEM;
> 
> diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
> index 4f3cbf6003a9..c5d0a58b2c29 100644
> --- a/arch/s390/kvm/vsie.c
> +++ b/arch/s390/kvm/vsie.c
> @@ -1234,7 +1234,7 @@ static struct vsie_page *get_vsie_page(struct kvm *kvm, unsigned long addr)
> 
>  	mutex_lock(&kvm->arch.vsie.mutex);
>  	if (kvm->arch.vsie.page_count < nr_vcpus) {
> -		page = alloc_page(GFP_KERNEL | __GFP_ZERO | GFP_DMA);
> +		page = alloc_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO | GFP_DMA);
>  		if (!page) {
>  			mutex_unlock(&kvm->arch.vsie.mutex);
>  			return ERR_PTR(-ENOMEM);
> @@ -1336,7 +1336,7 @@ int kvm_s390_handle_vsie(struct kvm_vcpu *vcpu)
>  void kvm_s390_vsie_init(struct kvm *kvm)
>  {
>  	mutex_init(&kvm->arch.vsie.mutex);
> -	INIT_RADIX_TREE(&kvm->arch.vsie.addr_to_page, GFP_KERNEL);
> +	INIT_RADIX_TREE(&kvm->arch.vsie.addr_to_page, GFP_KERNEL_ACCOUNT);
>  }
> 
>  /* Destroy the vsie data structures. To be called when a vm is destroyed. */
> 


[-- Attachment #1.1.2: OpenPGP_0xE354E6B8E238B9F8.asc --]
[-- Type: application/pgp-keys, Size: 7995 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/2] KVM: s390: memcg awareness
  2020-11-17 15:10 [PATCH 0/2] KVM: s390: memcg awareness Christian Borntraeger
  2020-11-17 15:10 ` [PATCH 1/2] KVM: s390: Add memcg accounting to KVM allocations Christian Borntraeger
  2020-11-17 15:10 ` [PATCH 2/2] s390/gmap: make gmap memcg aware Christian Borntraeger
@ 2020-11-17 15:23 ` David Hildenbrand
  2020-11-23 17:15 ` Christian Borntraeger
  3 siblings, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2020-11-17 15:23 UTC (permalink / raw)
  To: Christian Borntraeger, Janosch Frank; +Cc: KVM, Cornelia Huck, linux-s390

On 17.11.20 16:10, Christian Borntraeger wrote:
> This got somehow lost.  (so this is kind of a v2)
> KVM does have memcg awareness. Lets implement this also for s390kvm
> and gmap.

Looks sane to me.


-- 
Thanks,

David / dhildenb

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] s390/gmap: make gmap memcg aware
  2020-11-17 15:22   ` Janosch Frank
@ 2020-11-17 15:31     ` Christian Borntraeger
  0 siblings, 0 replies; 10+ messages in thread
From: Christian Borntraeger @ 2020-11-17 15:31 UTC (permalink / raw)
  To: Janosch Frank, Janosch Frank
  Cc: KVM, Cornelia Huck, David Hildenbrand, linux-s390, Heiko Carstens



On 17.11.20 16:22, Janosch Frank wrote:
> On 11/17/20 4:10 PM, Christian Borntraeger wrote:
>> gmap allocations can be attributed to a process.
>>
>> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
>> Acked-by: Heiko Carstens <hca@linux.ibm.com>
>> ---
>>  arch/s390/mm/gmap.c | 30 +++++++++++++++---------------
>>  1 file changed, 15 insertions(+), 15 deletions(-)
>>
>> diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c
>> index 64795d034926..9bb2c7512cd5 100644
>> --- a/arch/s390/mm/gmap.c
>> +++ b/arch/s390/mm/gmap.c
>> @@ -2,7 +2,7 @@
>>  /*
>>   *  KVM guest address space mapping code
>>   *
>> - *    Copyright IBM Corp. 2007, 2016, 2018
>> + *    Copyright IBM Corp. 2007, 2020
> 
> Do you mean 2007 - 2020 or did you drop the 2016 and 2018?
> How does this even work?

Last time I checked this was the IBM preferred variant to define
the range. first and last contribution.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] KVM: s390: Add memcg accounting to KVM allocations
  2020-11-17 15:10 ` [PATCH 1/2] KVM: s390: Add memcg accounting to KVM allocations Christian Borntraeger
  2020-11-17 15:22   ` Janosch Frank
@ 2020-11-23 16:08   ` Cornelia Huck
  1 sibling, 0 replies; 10+ messages in thread
From: Cornelia Huck @ 2020-11-23 16:08 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: Janosch Frank, KVM, David Hildenbrand, linux-s390, Heiko Carstens

On Tue, 17 Nov 2020 16:10:22 +0100
Christian Borntraeger <borntraeger@de.ibm.com> wrote:

> Almost all kvm allocations in the s390x KVM code can be attributed to
> process that triggers the allocation (in other words, no global

s/process/the process/

> allocation for other guests). This will help the memcg controller to do

s/do/make/

> the right decisions.
> 
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Acked-by: Heiko Carstens <hca@linux.ibm.com>
> ---
>  arch/s390/kvm/guestdbg.c  |  8 ++++----
>  arch/s390/kvm/intercept.c |  2 +-
>  arch/s390/kvm/interrupt.c | 10 +++++-----
>  arch/s390/kvm/kvm-s390.c  | 20 ++++++++++----------
>  arch/s390/kvm/priv.c      |  4 ++--
>  arch/s390/kvm/pv.c        |  6 +++---
>  arch/s390/kvm/vsie.c      |  4 ++--
>  7 files changed, 27 insertions(+), 27 deletions(-)

Didn't do a deep review, but looks reasonable.

Acked-by: Cornelia Huck <cohuck@redhat.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] s390/gmap: make gmap memcg aware
  2020-11-17 15:10 ` [PATCH 2/2] s390/gmap: make gmap memcg aware Christian Borntraeger
  2020-11-17 15:22   ` Janosch Frank
@ 2020-11-23 16:10   ` Cornelia Huck
  1 sibling, 0 replies; 10+ messages in thread
From: Cornelia Huck @ 2020-11-23 16:10 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: Janosch Frank, KVM, David Hildenbrand, linux-s390, Heiko Carstens

On Tue, 17 Nov 2020 16:10:23 +0100
Christian Borntraeger <borntraeger@de.ibm.com> wrote:

> gmap allocations can be attributed to a process.
> 
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Acked-by: Heiko Carstens <hca@linux.ibm.com>
> ---
>  arch/s390/mm/gmap.c | 30 +++++++++++++++---------------
>  1 file changed, 15 insertions(+), 15 deletions(-)
> 

Acked-by: Cornelia Huck <cohuck@redhat.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/2] KVM: s390: memcg awareness
  2020-11-17 15:10 [PATCH 0/2] KVM: s390: memcg awareness Christian Borntraeger
                   ` (2 preceding siblings ...)
  2020-11-17 15:23 ` [PATCH 0/2] KVM: s390: memcg awareness David Hildenbrand
@ 2020-11-23 17:15 ` Christian Borntraeger
  3 siblings, 0 replies; 10+ messages in thread
From: Christian Borntraeger @ 2020-11-23 17:15 UTC (permalink / raw)
  To: Janosch Frank; +Cc: KVM, Cornelia Huck, David Hildenbrand, linux-s390



On 17.11.20 16:10, Christian Borntraeger wrote:
> This got somehow lost.  (so this is kind of a v2)
> KVM does have memcg awareness. Lets implement this also for s390kvm
> and gmap.
> 
> Christian Borntraeger (2):
>   KVM: s390: Add memcg accounting to KVM allocations
>   s390/gmap: make gmap memcg aware

both applied.
> 
>  arch/s390/kvm/guestdbg.c  |  8 ++++----
>  arch/s390/kvm/intercept.c |  2 +-
>  arch/s390/kvm/interrupt.c | 10 +++++-----
>  arch/s390/kvm/kvm-s390.c  | 20 ++++++++++----------
>  arch/s390/kvm/priv.c      |  4 ++--
>  arch/s390/kvm/pv.c        |  6 +++---
>  arch/s390/kvm/vsie.c      |  4 ++--
>  arch/s390/mm/gmap.c       | 30 +++++++++++++++---------------
>  8 files changed, 42 insertions(+), 42 deletions(-)
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-11-23 17:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-17 15:10 [PATCH 0/2] KVM: s390: memcg awareness Christian Borntraeger
2020-11-17 15:10 ` [PATCH 1/2] KVM: s390: Add memcg accounting to KVM allocations Christian Borntraeger
2020-11-17 15:22   ` Janosch Frank
2020-11-23 16:08   ` Cornelia Huck
2020-11-17 15:10 ` [PATCH 2/2] s390/gmap: make gmap memcg aware Christian Borntraeger
2020-11-17 15:22   ` Janosch Frank
2020-11-17 15:31     ` Christian Borntraeger
2020-11-23 16:10   ` Cornelia Huck
2020-11-17 15:23 ` [PATCH 0/2] KVM: s390: memcg awareness David Hildenbrand
2020-11-23 17:15 ` Christian Borntraeger

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.