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

Commit 07c9ccde authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: kgsl: Use pid struct to find the process to reclaim"

parents 95ff274d a637a43b
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ static inline struct kgsl_pagetable *_get_memdesc_pagetable(

static void kgsl_mem_entry_detach_process(struct kgsl_mem_entry *entry);

static const struct file_operations kgsl_fops;
static const struct vm_operations_struct kgsl_gpumem_vm_ops;

/*
 * The memfree list contains the last N blocks of memory that have been freed.
@@ -2437,7 +2437,7 @@ static int check_vma(unsigned long hostptr, u64 size)
			return false;

		/* Don't remap memory that we already own */
		if (vma->vm_file && vma->vm_file->f_op == &kgsl_fops)
		if (vma->vm_file && vma->vm_ops == &kgsl_gpumem_vm_ops)
			return false;

		cur = vma->vm_end;
@@ -2594,7 +2594,7 @@ static int kgsl_setup_dmabuf_useraddr(struct kgsl_device *device,
		 * Check to see that this isn't our own memory that we have
		 * already mapped
		 */
		if (vma->vm_file->f_op == &kgsl_fops) {
		if (vma->vm_ops == &kgsl_gpumem_vm_ops) {
			up_read(&current->mm->mmap_sem);
			return -EFAULT;
		}
@@ -4973,9 +4973,10 @@ static int kgsl_mmap(struct file *file, struct vm_area_struct *vma)
		}
	}

	vma->vm_file = file;

	entry->memdesc.vma = vma;
	if (entry->memdesc.shmem_filp) {
		fput(vma->vm_file);
		vma->vm_file = get_file(entry->memdesc.shmem_filp);
	}

	/*
	 * kgsl gets the entry id or the gpu address through vm_pgoff.
+1 −5
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2008-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2008-2021, The Linux Foundation. All rights reserved.
 */
#ifndef __KGSL_H
#define __KGSL_H
@@ -227,10 +227,6 @@ struct kgsl_memdesc {
	unsigned int page_count;
	unsigned int cur_bindings;
	struct file *shmem_filp;
	/**
	 * @vma: Pointer to the vm_area_struct this memdesc is mapped to
	 */
	struct vm_area_struct *vma;
	/**
	 * @lock: Spinlock to protect the pages array
	 */
+13 −5
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
 */

#include <linux/kthread.h>
@@ -196,12 +196,21 @@ ssize_t kgsl_proc_max_reclaim_limit_show(struct device *dev,
static int kgsl_reclaim_callback(struct notifier_block *nb,
		unsigned long pid, void *data)
{
	struct kgsl_process_private *process;
	struct kgsl_process_private *p, *process = NULL;
	struct kgsl_mem_entry *entry;
	struct kgsl_memdesc *memdesc;
	int valid_entry, next = 0, ret;

	process = kgsl_process_private_find(pid);
	spin_lock(&kgsl_driver.proclist_lock);
	list_for_each_entry(p, &kgsl_driver.process_list, list) {
		if ((unsigned long)p->pid == pid) {
			if (kgsl_process_private_get(p))
				process = p;
			break;
		}
	}
	spin_unlock(&kgsl_driver.proclist_lock);

	if (!process)
		return NOTIFY_OK;

@@ -269,8 +278,7 @@ static int kgsl_reclaim_callback(struct notifier_block *nb,
			memdesc->priv |= KGSL_MEMDESC_RECLAIMED;

			ret = reclaim_address_space
				(memdesc->shmem_filp->f_mapping,
				data, memdesc->vma);
				(memdesc->shmem_filp->f_mapping, data);

			memdesc->reclaimed_page_count += memdesc->page_count;
			atomic_add(memdesc->page_count,
+3 −3
Original line number Diff line number Diff line
@@ -1686,7 +1686,7 @@ static void proc_reclaim_notify(unsigned long pid, void *rp)
}

int reclaim_address_space(struct address_space *mapping,
			struct reclaim_param *rp, struct vm_area_struct *vma)
			struct reclaim_param *rp)
{
	struct radix_tree_iter iter;
	void __rcu **slot;
@@ -1727,7 +1727,7 @@ int reclaim_address_space(struct address_space *mapping,
		}
	}
	rcu_read_unlock();
	reclaimed = reclaim_pages_from_list(&page_list, vma);
	reclaimed = reclaim_pages_from_list(&page_list, NULL);
	rp->nr_reclaimed += reclaimed;

	if (rp->nr_scanned >= rp->nr_to_reclaim)
@@ -1821,7 +1821,7 @@ struct reclaim_param reclaim_task_nomap(struct task_struct *task,
		goto out;
	down_read(&mm->mmap_sem);

	proc_reclaim_notify(task_tgid_nr(task), (void *)&rp);
	proc_reclaim_notify((unsigned long)task_pid(task), (void *)&rp);

	up_read(&mm->mmap_sem);
	mmput(mm);
+1 −1
Original line number Diff line number Diff line
@@ -3058,7 +3058,7 @@ extern struct reclaim_param reclaim_task_anon(struct task_struct *task,
extern struct reclaim_param reclaim_task_nomap(struct task_struct *task,
		int nr_to_reclaim);
extern int reclaim_address_space(struct address_space *mapping,
		struct reclaim_param *rp, struct vm_area_struct *vma);
		struct reclaim_param *rp);
extern int proc_reclaim_notifier_register(struct notifier_block *nb);
extern int proc_reclaim_notifier_unregister(struct notifier_block *nb);
#endif