Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 700518d5 authored by Puranam V G Tejaswi's avatar Puranam V G Tejaswi
Browse files

msm: kgsl: add kgsl stats to vm_stat and rss_stat counters



Update the vm_stat counter NR_UNRECLAIMABLE_PAGES to
account for the total memory allocated. Update the vm_stat
counter NR_INDIRECTLY_RECLAIMABLE_BYTES to account for the
memory held in pools. Update the rss_stat counter
MM_UNRECLAIMABLE to account for the memory allocated and
memory imported per process.

Change-Id: I302834502c21376136d7b5081024812b0cecd150
Signed-off-by: default avatarPuranam V G Tejaswi <pvgtejas@codeaurora.org>
parent 4541f68e
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
#include <linux/idr.h>
#include <linux/pm_qos.h>
#include <linux/sched.h>
#include <linux/sched/task.h>
#include <linux/sched/mm.h>

#include "kgsl.h"
#include "kgsl_mmu.h"
@@ -564,12 +566,31 @@ static inline void kgsl_process_add_stats(struct kgsl_process_private *priv,
	priv->stats[type].cur += size;
	if (priv->stats[type].max < priv->stats[type].cur)
		priv->stats[type].max = priv->stats[type].cur;
	add_mm_counter(current->mm, MM_UNRECLAIMABLE, (size >> PAGE_SHIFT));
}

static inline void kgsl_process_sub_stats(struct kgsl_process_private *priv,
	unsigned int type, uint64_t size)
{
	struct pid *pid_struct;
	struct task_struct *task;
	struct mm_struct *mm;

	priv->stats[type].cur -= size;
	pid_struct = find_get_pid(priv->pid);
	if (pid_struct) {
		task = get_pid_task(pid_struct, PIDTYPE_PID);
		if (task) {
			mm = get_task_mm(task);
			if (mm) {
				add_mm_counter(mm, MM_UNRECLAIMABLE,
					-(size >> PAGE_SHIFT));
				mmput(mm);
			}
			put_task_struct(task);
		}
		put_pid(pid_struct);
	}
}

static inline bool kgsl_is_register_offset(struct kgsl_device *device,
+10 −2
Original line number Diff line number Diff line
/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2017, 2019 The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -89,6 +89,8 @@ _kgsl_pool_add_page(struct kgsl_page_pool *pool, struct page *p)
	list_add_tail(&p->lru, &pool->page_list);
	pool->page_count++;
	spin_unlock(&pool->list_lock);
	mod_node_page_state(page_pgdat(p), NR_INDIRECTLY_RECLAIMABLE_BYTES,
				(PAGE_SIZE << pool->pool_order));
}

/* Returns a page from specified pool */
@@ -104,7 +106,8 @@ _kgsl_pool_get_page(struct kgsl_page_pool *pool)
		list_del(&p->lru);
	}
	spin_unlock(&pool->list_lock);

	mod_node_page_state(page_pgdat(p), NR_INDIRECTLY_RECLAIMABLE_BYTES,
				-(PAGE_SIZE << pool->pool_order));
	return p;
}

@@ -390,6 +393,8 @@ int kgsl_pool_alloc_page(int *page_size, struct page **pages,
		pcount++;
	}

	mod_node_page_state(page_pgdat(page), NR_UNRECLAIMABLE_PAGES,
					(1 << order));
	return pcount;

eagain:
@@ -409,6 +414,9 @@ void kgsl_pool_free_page(struct page *page)

	page_order = compound_order(page);

	mod_node_page_state(page_pgdat(page), NR_UNRECLAIMABLE_PAGES,
					-(1 << page_order));

	if (!kgsl_pool_max_pages ||
			(kgsl_pool_size_total() < kgsl_pool_max_pages)) {
		pool = _kgsl_get_pool_from_order(page_order);
+8 −0
Original line number Diff line number Diff line
@@ -625,6 +625,9 @@ static void kgsl_cma_coherent_free(struct kgsl_memdesc *memdesc)
			atomic_long_sub(memdesc->size,
				&kgsl_driver.stats.coherent);

		mod_node_page_state(page_pgdat(phys_to_page(memdesc->physaddr)),
			NR_UNRECLAIMABLE_PAGES, -(memdesc->size >> PAGE_SHIFT));

		dma_free_attrs(memdesc->dev, (size_t) memdesc->size,
			memdesc->hostptr, memdesc->physaddr, attrs);
	}
@@ -1283,6 +1286,8 @@ int kgsl_sharedmem_alloc_contig(struct kgsl_device *device,
	KGSL_STATS_ADD(size, &kgsl_driver.stats.coherent,
		&kgsl_driver.stats.coherent_max);

	mod_node_page_state(page_pgdat(phys_to_page(memdesc->physaddr)),
			NR_UNRECLAIMABLE_PAGES, (size >> PAGE_SHIFT));
err:
	if (result)
		kgsl_sharedmem_free(memdesc);
@@ -1398,6 +1403,9 @@ static int kgsl_cma_alloc_secure(struct kgsl_device *device,
	/* Record statistics */
	KGSL_STATS_ADD(aligned, &kgsl_driver.stats.secure,
	       &kgsl_driver.stats.secure_max);

	mod_node_page_state(page_pgdat(phys_to_page(memdesc->physaddr)),
			NR_UNRECLAIMABLE_PAGES, (aligned >> PAGE_SHIFT));
err:
	if (result)
		kgsl_sharedmem_free(memdesc);