Re: 答复: 答复: low memory killer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu 20-11-14 12:05:00, zhiyuan_zhu@xxxxxxx wrote:
> Hi Greg/Michal
> Very sorry I have a mistake in previous mail. (It should be nr_file_pages not nr_free_pages)
> I rearrange this problem.
> 
> // *********** log begin **********
> 6      161030.084144       2014-11-07 21:44:53.304        lowmemorykiller: Killing 'om.htc.launcher' (4486), adj 294,
> 6      161030.084144       2014-11-07 21:44:53.304           to free 47856kB on behalf of 'kworker/u8:14' (20594) because
> 6      161030.084144       2014-11-07 21:44:53.304           cache 72460kB is below limit 73728kB for oom_score_adj 235

This is missing the last line which dumps Free memory (at least from the
snippet below, because nothing like that is in the current driver code
anymore)

> //  **** /proc/meminfo 's result
> 4      161030.084797       2014-11-07 21:44:53.304        Cached:           142448 kB
> // *********** log end **********
> 
> After I checked the android's low memory strategy: kernel/drivers/staging/android/lowmemorykiller.c
> 
> // ****** code begin *********
> 		other_file = global_page_state(NR_FILE_PAGES) -
> 						global_page_state(NR_SHMEM) -
> 						total_swapcache_pages();
> 
> 		lowmem_print(1, "Killing '%s' (%d), adj %hd,\n" \
> 				"   to free %ldkB on behalf of '%s' (%d) because\n" \
> 				"   cache %ldkB is below limit %ldkB for oom_score_adj %hd\n" \
> 				"   Free memory is %ldkB above reserved\n",
> 			     selected->comm, selected->pid,
> 			     selected_oom_score_adj,
> 			     selected_tasksize * (long)(PAGE_SIZE / 1024),
> 			     current->comm, current->pid,
> 			     other_file * (long)(PAGE_SIZE / 1024),
> 			     minfree * (long)(PAGE_SIZE / 1024),
> 			     min_score_adj,
> 			     other_free * (long)(PAGE_SIZE / 1024));
> // ******* code end ************
> 
> So android's strategy's free memory is = other_file = (nr file pages - nr shmem - total swapcache pages) * 4K = [cache 72460kB]
> But the system's free memory is: Cached:        142448 kB  // from /proc/meminfo

I have already pointed you at meminfo_proc_show() which calculates the
shown value as:
	cached = global_page_state(NR_FILE_PAGES) -
	                        total_swapcache_pages() - i.bufferram;

That means that the two differ by NR_SHMEM - i.bufferram. 

> And system's free memory is: Cached + MemFree + Buffers is largely
> than the memory which anroid lowmemorykiller calculated memory [cache
> 72460K] At this time point, system will kill some important processes,
> but system have enough memory.  This is android's lowmemorykiller
> defect? or Linux kernel memory's defect?

It looks most likely be lowmemory killer bug but this is hard to tell as
I do not know which kernel version are you looking at and what are the
additional patch on top of Vanilla kernel.
The upstream code doesn't care about Cached value as presented by
/proc/meminfo

> So I have some questions:
> I have a question: what's the nr file pages mean?

It counts page cache pages (aka pages backed by a file). This includes
also SHMEM pages.

> What different between nr_file_pages from Cached (from /proc/meminfo)?

See above about meminfo_proc_show.

> And nr shmem, swapcache pages are small, so I think this is the key
> problem why android's stragegy calculated free memory is largely less
> than /proc/meminfo Cached's value.

I do not see the value of shmem and swapcache from the time when the
situation was evaluated.

Anyway I do not think there would be problem with counters but rather
the way how they are used by lowmemory killer and I would be looking
into that code first before checking the core kernel.
-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]