Loading drivers/gpu/msm/kgsl_reclaim.c +29 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,9 @@ #include <linux/kthread.h> #include <linux/notifier.h> #include <linux/pagevec.h> #include <linux/shmem_fs.h> #include <linux/swap.h> #include "kgsl_reclaim.h" #include "kgsl_sharedmem.h" Loading Loading @@ -193,6 +195,12 @@ ssize_t kgsl_proc_max_reclaim_limit_show(struct device *dev, return scnprintf(buf, PAGE_SIZE, "%d\n", kgsl_reclaim_max_page_limit); } static void kgsl_release_page_vec(struct pagevec *pvec) { check_move_unevictable_pages(pvec->pages, pvec->nr); __pagevec_release(pvec); } static int kgsl_reclaim_callback(struct notifier_block *nb, unsigned long pid, void *data) { Loading Loading @@ -266,20 +274,39 @@ static int kgsl_reclaim_callback(struct notifier_block *nb, if (!kgsl_mmu_unmap(memdesc->pagetable, memdesc)) { int i; struct pagevec pvec; /* * Pages that are first allocated are by default added * to unevictable list. To reclaim them, we first clear * the AS_UNEVICTABLE flag of the shmem file address * space thus check_move_unevictable_pages() places * them on the evictable list. * * Once reclaim is done, hint that further shmem * allocations will have to be on the unevictable list. */ mapping_clear_unevictable( memdesc->shmem_filp->f_mapping); pagevec_init(&pvec); for (i = 0; i < memdesc->page_count; i++) { set_page_dirty_lock(memdesc->pages[i]); spin_lock(&memdesc->lock); put_page(memdesc->pages[i]); pagevec_add(&pvec, memdesc->pages[i]); memdesc->pages[i] = NULL; spin_unlock(&memdesc->lock); if (pagevec_count(&pvec) == PAGEVEC_SIZE) kgsl_release_page_vec(&pvec); } if (pagevec_count(&pvec)) kgsl_release_page_vec(&pvec); memdesc->priv |= KGSL_MEMDESC_RECLAIMED; ret = reclaim_address_space (memdesc->shmem_filp->f_mapping, data); mapping_set_unevictable(memdesc->shmem_filp->f_mapping); memdesc->reclaimed_page_count += memdesc->page_count; atomic_add(memdesc->page_count, &process->reclaimed_page_count); Loading drivers/gpu/msm/kgsl_sharedmem.c +2 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * Copyright (c) 2002,2007-2021, The Linux Foundation. All rights reserved. */ Loading Loading @@ -974,6 +975,7 @@ static int kgsl_memdesc_file_setup(struct kgsl_memdesc *memdesc, uint64_t size) memdesc->shmem_filp = NULL; return ret; } mapping_set_unevictable(memdesc->shmem_filp->f_mapping); } return 0; Loading Loading
drivers/gpu/msm/kgsl_reclaim.c +29 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,9 @@ #include <linux/kthread.h> #include <linux/notifier.h> #include <linux/pagevec.h> #include <linux/shmem_fs.h> #include <linux/swap.h> #include "kgsl_reclaim.h" #include "kgsl_sharedmem.h" Loading Loading @@ -193,6 +195,12 @@ ssize_t kgsl_proc_max_reclaim_limit_show(struct device *dev, return scnprintf(buf, PAGE_SIZE, "%d\n", kgsl_reclaim_max_page_limit); } static void kgsl_release_page_vec(struct pagevec *pvec) { check_move_unevictable_pages(pvec->pages, pvec->nr); __pagevec_release(pvec); } static int kgsl_reclaim_callback(struct notifier_block *nb, unsigned long pid, void *data) { Loading Loading @@ -266,20 +274,39 @@ static int kgsl_reclaim_callback(struct notifier_block *nb, if (!kgsl_mmu_unmap(memdesc->pagetable, memdesc)) { int i; struct pagevec pvec; /* * Pages that are first allocated are by default added * to unevictable list. To reclaim them, we first clear * the AS_UNEVICTABLE flag of the shmem file address * space thus check_move_unevictable_pages() places * them on the evictable list. * * Once reclaim is done, hint that further shmem * allocations will have to be on the unevictable list. */ mapping_clear_unevictable( memdesc->shmem_filp->f_mapping); pagevec_init(&pvec); for (i = 0; i < memdesc->page_count; i++) { set_page_dirty_lock(memdesc->pages[i]); spin_lock(&memdesc->lock); put_page(memdesc->pages[i]); pagevec_add(&pvec, memdesc->pages[i]); memdesc->pages[i] = NULL; spin_unlock(&memdesc->lock); if (pagevec_count(&pvec) == PAGEVEC_SIZE) kgsl_release_page_vec(&pvec); } if (pagevec_count(&pvec)) kgsl_release_page_vec(&pvec); memdesc->priv |= KGSL_MEMDESC_RECLAIMED; ret = reclaim_address_space (memdesc->shmem_filp->f_mapping, data); mapping_set_unevictable(memdesc->shmem_filp->f_mapping); memdesc->reclaimed_page_count += memdesc->page_count; atomic_add(memdesc->page_count, &process->reclaimed_page_count); Loading
drivers/gpu/msm/kgsl_sharedmem.c +2 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * Copyright (c) 2002,2007-2021, The Linux Foundation. All rights reserved. */ Loading Loading @@ -974,6 +975,7 @@ static int kgsl_memdesc_file_setup(struct kgsl_memdesc *memdesc, uint64_t size) memdesc->shmem_filp = NULL; return ret; } mapping_set_unevictable(memdesc->shmem_filp->f_mapping); } return 0; Loading