高通平台采用gpu-mmu的时候发生显存耗完而整个系统内存尚有的情况导致crash和重启

来源:互联网 发布:软件安装管理器 编辑:程序博客网 时间:2024/04/29 01:43

原因在于kgsl_mmu.c中,定义了gpu使用的内存大小,7x30中限定了256MB,当显存耗光而内存尚剩余很多的时候就会发生问题:不能触发LMK或OOM来释放内存,而又没有显存可用,进而可能引起各进程watchdogtimeout,如果系统进程发生watchdogtimeout,会导致system serverrestart,而restart之后也不能释放gpu显存,会一直反复重启:

unsigned int kgsl_mmu_get_ptsize(void){/* * For IOMMU, we could do up to 4G virtual range if we wanted to, but * it makes more sense to return a smaller range and leave the rest of * the virtual range for future improvements */if (KGSL_MMU_TYPE_GPU == kgsl_mmu_type)return CONFIG_MSM_KGSL_PAGE_TABLE_SIZE;else if (KGSL_MMU_TYPE_IOMMU == kgsl_mmu_type)return SZ_2G - KGSL_PAGETABLE_BASE;elsereturn 0;}

Lowmemorykiller.c 添加一个新函数


void lowmem_shrink_gpu(void){struct task_struct *tsk;struct task_struct *selected = NULL;int tasksize;int selected_tasksize = 0;rcu_read_lock();for_each_process(tsk) {struct task_struct *p;if (tsk->flags & PF_KTHREAD)continue;p = find_lock_task_mm(tsk);if (!p)continue;if (test_tsk_thread_flag(p, TIF_MEMDIE) &&    time_before_eq(jiffies, lowmem_deathpending_timeout)) {task_unlock(p);rcu_read_unlock();return ;}tasksize = get_mm_rss(p->mm);task_unlock(p);if ((tasksize <= 0) || (p->signal->oom_score_adj <= 1))continue;if (selected) {if (tasksize <= selected_tasksize)continue;}selected = p;selected_tasksize = tasksize;lowmem_print(2, "AKeywordSE select %d (%s), size %d, to kill\n",     p->pid, p->comm, tasksize);}if (selected) {lowmem_print(1, "AKeywordSE send sigkill to %d (%s), size %d\n",     selected->pid, selected->comm,selected_tasksize);lowmem_deathpending_timeout = jiffies + HZ;send_sig(SIGKILL, selected, 0);set_tsk_thread_flag(selected, TIF_MEMDIE);}rcu_read_unlock();return ;}

Kgs_mmu.c中声明

extern void lowmem_shrink_gpu(void );

并在kgsl_mmu_map中调用


if (memdesc->gpuaddr == 0) {lowmem_shrink_gpu();KGSL_CORE_ERR("gen_pool_alloc(%d) failed from pool: %s\n",size,(pool == pagetable->kgsl_pool) ?"kgsl_pool" : "general_pool");KGSL_CORE_ERR(" [%d] allocated=%d, entries=%d\n",pagetable->name, pagetable->stats.mapped,pagetable->stats.entries);return -ENOMEM;}


0 0
原创粉丝点击