On Thu, Nov 20, 2014 at 8:05 PM, 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 > // **** /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 > > 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? > > So I have some questions: > I have a question: what's the nr file pages mean? What different between nr_file_pages from Cached (from /proc/meminfo)? > 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. > > Why lowmemkiller -total_swapcache_pages()? see commit 058dbde92: staging: android: lowmemorykiller: neglect swap cached pages in other_file With ZRAM enabled it is observed that lowmemory killer doesn't trigger properly. swap cached pages are accounted in NR_FILE, and lowmemorykiller considers this as reclaimable and adds to other_file. But these pages can't be reclaimed unless lowmemorykiller triggers. So subtract swap pages from other_file. and commit 31d59a4198f will also make help, please check it. > Thanks > Zhiyuan zhu > > -----邮件原件----- > 发件人: Michal Hocko [mailto:mhocko@suse.cz] > 发送时间: 2014年11月20日 18:19 > 收件人: Zhiyuan Zhu(朱志遠) > 抄送: hannes@cmpxchg.org; Future Zhou(周未來); Rachel Zhang(張瑩); bsingharora@gmail.com; kamezawa.hiroyu@jp.fujitsu.com; cgroups@vger.kernel.org; linux-mm@kvack.org; greg@kroah.com > 主题: Re: 答复: low memory killer > > On Thu 20-11-14 10:09:25, zhiyuan_zhu@htc.com wrote: > > Hi Michal > > Thanks for your kindly support. > > I got a device, and dump the /proc/meminfo and /proc/vmstat files, > > they are the Linux standard proc files. > > I found that: Cached = 339880 KB, but nr_free_pages=14675*4 = 58700KB > > and nr_shmem = 508*4=2032KB > > > > nr_shmem is just a little memory, and nr free pages + nr_shmem is > > largely less than Cached. So why nr_free_pages is largely less than > > Cached? Thank you. > > nr_free_pages refers to pages which are not allocated. Cached referes to a used memory which is easily reclaimable so it can be reused should there be a need and free memory drops down. So this is a normal situation. How is this related to the lowmemory killer question posted previously? > > [...] > -- > Michal Hocko > SUSE Labs > > > CONFIDENTIALITY NOTE : The information in this e-mail is confidential and > privileged; it is intended for use solely by the individual or entity named > as the recipient hereof. Disclosure, copying, distribution, or use of the > contents of this e-mail by persons other than the intended recipient is > strictly prohibited and may violate applicable laws. If you have received > this e-mail in error, please delete the original message and notify us by > return email or collect call immediately. Thank you. HTC Corporation >