From: "ming.ling" <ming.ling@spreadtrum.com>
To: <labbott@redhat.com>, <sumit.semwal@linaro.org>,
<gregkh@linuxfoundation.org>, <arve@android.com>,
<riandrews@android.com>
Cc: <devel@driverdev.osuosl.org>, <linux-kernel@vger.kernel.org>,
<orson.zhai@spreadtrum.com>, <geng.ren@spreadtrum.com>,
<chunyan.zhang@spreadtrum.com>, <zhizhou.tian@spreadtrum.com>,
<yuming.han@spreadtrum.com>, <xiajing@spreadst.com>,
<mark.yang@spreadtrum.com>, <wenan.hu@spreadtrum.com>,
Ming Ling <ming.ling@spreadtrum.com>
Subject: [PATCH] staging: android: ion: Make ion_free asynchronous more actively.
Date: Tue, 11 Oct 2016 10:31:53 +0800 [thread overview]
Message-ID: <1476153113-19072-1-git-send-email-ming.ling@spreadtrum.com> (raw)
From: Ming Ling <ming.ling@spreadtrum.com>
So far some ion heaps such as carveout_heap, chunk_heap,
system_heap have freed buffers asynchrounously. Freed buffers
are placed on a free list and freed from a low priority background
thread. If allocations from a particular heap fail, the free list
is drained.
But that mechanism does not work well to free those buffers when
cpu is very busy:
1.That low priority background thread has no chance to run.
2.And with helps of kinds of memory reclaim mechanisms,
allocations from a system_heap never fail, so the free list
can't be drained on that condition.
3.Ion_heap_shrink_scan can shrink the free list, but it is
too slow.
Too many freed buffers in heap's free list waiting to be freed will
lead to low memory killer over-killing innocent processes.
For example:
On my Android Mobile phone(arm32, 2G ram)
lowmemorykiller: Killing 'viders.calendar' (2271), adj 15,
to free 45060kB on behalf of 'kswapd0' (60) because
cache 17208kB is below limit 46080kB for oom_score_adj 0.
Free memory is 3424kB above reserved.
Memory footprint is as below:
--------------------------------------------
MemTotal: 1972164 kB
--------------------------------------------
Normal free:43624kB min:3228kB low:5308kB high:6116kB active_anon:
656kB inactive_anon:1308kB active_file:10600kB inactive_file:6628kB
HighMem free:13208kB min:512kB low:4720kB high:6352kB active_anon:
126188kB inactive_anon:74364kB active_file:325720kB inactive_file:
585832k
--------------------------------------------
ion system heap:
--------------------
total orphaned 9961472
total 58986496
deferred free 630575104
--------------------------------------------
There are about 630575104=601MB memory on ion system heap's free
list waiting to be freed. And it kills more processes, until ion low
priority background thread gets a chance to run as below:
lowmemorykiller: Killing 'd.process.media' (1402), adj 11,
lowmemorykiller: Killing 'dsrt.srtmemtest' (2552), adj 9,
lowmemorykiller: Killing 'rd.engineermode' (2167), adj 8,
lowmemorykiller: Killing 'rd.fileexplorer' (2431), adj 7,
lowmemorykiller: Killing 'd.process.acore' (1499), adj 5,
...
Limit ion_heap_deferred_free thread as a low priority thread doesn't
make any sense. Remove that restriction makes ion_free asynchronous
more actively, and more background applications can survive.
Signed-off-by: Ming Ling <ming.ling@spreadtrum.com>
---
drivers/staging/android/ion/ion_heap.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/staging/android/ion/ion_heap.c b/drivers/staging/android/ion/ion_heap.c
index 4e5c0f1..d68a80c 100644
--- a/drivers/staging/android/ion/ion_heap.c
+++ b/drivers/staging/android/ion/ion_heap.c
@@ -250,8 +250,6 @@ static int ion_heap_deferred_free(void *data)
int ion_heap_init_deferred_free(struct ion_heap *heap)
{
- struct sched_param param = { .sched_priority = 0 };
-
INIT_LIST_HEAD(&heap->free_list);
init_waitqueue_head(&heap->waitqueue);
heap->task = kthread_run(ion_heap_deferred_free, heap,
@@ -261,7 +259,6 @@ int ion_heap_init_deferred_free(struct ion_heap *heap)
__func__);
return PTR_ERR_OR_ZERO(heap->task);
}
- sched_setscheduler(heap->task, SCHED_IDLE, ¶m);
return 0;
}
--
1.9.1
next reply other threads:[~2016-10-11 2:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-11 2:31 ming.ling [this message]
2016-10-13 0:08 ` Laura Abbott
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1476153113-19072-1-git-send-email-ming.ling@spreadtrum.com \
--to=ming.ling@spreadtrum.com \
--cc=arve@android.com \
--cc=chunyan.zhang@spreadtrum.com \
--cc=devel@driverdev.osuosl.org \
--cc=geng.ren@spreadtrum.com \
--cc=gregkh@linuxfoundation.org \
--cc=labbott@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.yang@spreadtrum.com \
--cc=orson.zhai@spreadtrum.com \
--cc=riandrews@android.com \
--cc=sumit.semwal@linaro.org \
--cc=wenan.hu@spreadtrum.com \
--cc=xiajing@spreadst.com \
--cc=yuming.han@spreadtrum.com \
--cc=zhizhou.tian@spreadtrum.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®