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

Commit e58813a8 authored by Harshdeep Dhatt's avatar Harshdeep Dhatt
Browse files

msm: kgsl: Add accounting for memory mapped in userspace



For proper memory accounting, a key metric is to know how much
memory kgsl allocated for a process and how much of it the process
is actually using. This is done by keeping track of memory in our
vmfault routines. This information is provided via the process
mem file.

Change-Id: I7e3371a708ea5fdade3840b2384b3bc4012ad004
Signed-off-by: default avatarHarshdeep Dhatt <hdhatt@codeaurora.org>
parent 1c2c6d7f
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
/* Copyright (c) 2008-2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2008-2016, 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
@@ -147,6 +147,7 @@ struct kgsl_memdesc_ops {
 * @gpuaddr: GPU virtual address
 * @physaddr: Physical address of the memory object
 * @size: Size of the memory object
 * @mapsize: Size of memory mapped in userspace
 * @priv: Internal flags and settings
 * @sgt: Scatter gather table for allocated pages
 * @ops: Function hooks for the memdesc memory type
@@ -163,6 +164,7 @@ struct kgsl_memdesc {
	uint64_t gpuaddr;
	phys_addr_t physaddr;
	uint64_t size;
	uint64_t mapsize;
	unsigned int priv;
	struct sg_table *sgt;
	struct kgsl_memdesc_ops *ops;
+5 −5
Original line number Diff line number Diff line
/* Copyright (c) 2002,2008-2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2002,2008-2016, 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
@@ -144,12 +144,12 @@ static int print_mem_entry(int id, void *ptr, void *data)

	kgsl_get_memory_usage(usage, sizeof(usage), m->flags);

	seq_printf(s, "%pK %pK %16llu %5d %8s %10s %16s %5d",
	seq_printf(s, "%pK %pK %16llu %5d %8s %10s %16s %5d %16llu",
			(uint64_t *)(uintptr_t) m->gpuaddr,
			(unsigned long *) m->useraddr,
			m->size, entry->id, flags,
			memtype_str(kgsl_memdesc_usermem_type(m)),
			usage, m->sgt->nents);
			usage, m->sgt->nents, m->mapsize);

	if (entry->metadata[0] != 0)
		seq_printf(s, " %s", entry->metadata);
@@ -163,9 +163,9 @@ static int process_mem_print(struct seq_file *s, void *unused)
{
	struct kgsl_process_private *private = s->private;

	seq_printf(s, "%8s %8s %8s %5s %8s %10s %16s %5s\n",
	seq_printf(s, "%16s %16s %16s %5s %8s %10s %16s %5s %16s\n",
		   "gpuaddr", "useraddr", "size", "id", "flags", "type",
		   "usage", "sglen");
		   "usage", "sglen", "mapsize");

	spin_lock(&private->mem_lock);
	idr_for_each(&private->mem_idr, print_mem_entry, s);
+5 −1
Original line number Diff line number Diff line
/* Copyright (c) 2002,2007-2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2002,2007-2016, 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
@@ -385,6 +385,8 @@ static int kgsl_page_alloc_vmfault(struct kgsl_memdesc *memdesc,
			get_page(page);
			vmf->page = page;

			memdesc->mapsize += PAGE_SIZE;

			return 0;
		}

@@ -550,6 +552,8 @@ static int kgsl_contiguous_vmfault(struct kgsl_memdesc *memdesc,
	else if (ret == -EFAULT)
		return VM_FAULT_SIGBUS;

	memdesc->mapsize += PAGE_SIZE;

	return VM_FAULT_NOPAGE;
}