Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754639AbbGGHCi (ORCPT ); Tue, 7 Jul 2015 03:02:38 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:52039 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754012AbbGGHC2 (ORCPT ); Tue, 7 Jul 2015 03:02:28 -0400 X-AuditID: cbfee68f-f793b6d000005f66-d5-559b797cb466 From: PINTU KUMAR To: "'Xishi Qiu'" Cc: corbet@lwn.net, akpm@linux-foundation.org, vbabka@suse.cz, gorcunov@openvz.org, mhocko@suse.cz, emunson@akamai.com, kirill.shutemov@linux.intel.com, standby24x7@gmail.com, hannes@cmpxchg.org, vdavydov@parallels.com, hughd@google.com, minchan@kernel.org, tj@kernel.org, rientjes@google.com, xypron.glpk@gmx.de, dzickus@redhat.com, prarit@redhat.com, ebiederm@xmission.com, rostedt@goodmis.org, uobergfe@redhat.com, paulmck@linux.vnet.ibm.com, iamjoonsoo.kim@lge.com, ddstreet@ieee.org, sasha.levin@oracle.com, koct9i@gmail.com, mgorman@suse.de, cj@linux.com, opensource.ganesh@gmail.com, vinmenon@codeaurora.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pm@vger.kernel.org, cpgs@samsung.com, pintu_agarwal@yahoo.com, vishnu.ps@samsung.com, rohit.kr@samsung.com, iqbal.ams@samsung.com, pintu.ping@gmail.com References: <1435929607-3435-1-git-send-email-pintu.k@samsung.com> <559A56FD.6010701@huawei.com> <0ffe01d0b7f4$dd2706d0$97751470$@samsung.com> <559B2D89.2070802@huawei.com> In-reply-to: <559B2D89.2070802@huawei.com> Subject: RE: [PATCH 1/1] kernel/sysctl.c: Add /proc/sys/vm/shrink_memory feature Date: Tue, 07 Jul 2015 12:30:39 +0530 Message-id: <10f201d0b882$c9dc9480$5d95bd80$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AQIslilycOCfT8Oq4c8d4RbMXOXODQHvnMqoAcz5VxYBsKwB9pzsY2wQ Content-language: en-us X-Brightmail-Tracker: H4sIAAAAAAAAA02SfUxTVxjGd+4994NGsmsH86yLmSEYN40fCLjX4RazZeaEZFEiJHPJ1A5u wAyQtEDUuQi7fCiznaObYguKTB0yYl0bFj5MLQVFYxA2SESxtSLyoVQRA34tuluvS/jvec95 fu/z/PGKrL6GN4jbcvNlU64xO4bX4caohO+W7t7pSFtR8zwWqp2NPDjHFQTD3nIE474PoLes DYO/Ow5e/lUiwP2eRwycc08y8IfrC7gzZcVw6keFB8ezSgaujVar474gB8fKjmPoa63mIdD4 koNHlk4EtvsjCO4qjzk4Of1AgNLrtzGE3Op4dfwghpnQoLr9iUWAmYNtCMqO/8nAqFKKwbM3 yMBvnYMs/FN1VYBnv59HYB0+wYCj2Iqgr+kwC84mrwC/WP0IOn6dRGvfp7bOWpZ2TDxgaZ/V wtAWu1+gkw830xLPdYHWugpoSWeIo3cOtDPU1bCPp66pSoFWhPoZerHqOabD/YcYeuRSCg36 3HjDu1/p1mTI2dsKZdPyT7bqsjrulfJ5F5bsaK1ZWIQ8sRUoQiRSAglOViNNv016A06+AulE vXQCkcf7+7n/TaPKNNY+DiFypupfpA0hRI4WP1QRUeSlReSCNzIMREkLySVlgAt7WOkuT+rL /2Y04Awit9p7cdgVIS0mLTftOAy/JW0gxXUfhZ+xCu8dq2PDOlJaTQ539XKankue2AKvUFZF nS1djKbfI+7GEKs1XUCau+8hrcQ60jN18bVnHqkM3hI0T42OdLjjtCyJzNh8ryoQaT5xeV+v eYe01w/gA4jYZyXbZyXbZyXbZyXUItyAouW89DzzN5mm+GVmY465IDdzWfr2HBdSr/byi5Gf mpHfm+RDkohi5kQOEEeanjMWmnfm+FCi2uhn1hCdvl099Nz8LXHxq1ZCYkJi/MoPV6+KmRd5 zPB0o17KNObL38pynmzaYirIls0+xIgRhiL0efKXw2knM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9dLzs/dxAhO5c+kdzCuarA4xCjAwajEw3tTYnaoEGtiWXFl7iFGCQ5mJRFe3VKgEG9K YmVValF+fFFpTmrxIUZToE8nMkuJJucD80xeSbyhsYm5qbGppYmFiZmlkjjvyXyfUCGB9MSS 1OzU1ILUIpg+Jg5OqQbG1X1Oko0rzJ9WWruebgswP9SluWxVy6PUmo17LWQOMFqc49n64ffL R2H3JH/VRM5yPjY7Pi290fhzbdjKC4/c/wiVf1FYEfvE8uvBF9oJ13c1vZaddLnVfEsa8860 szNWzS2rKLYJCE5aIJYuedD6566DszjuLDx4oc3l2uFp28OaLu762+4brcRSnJFoqMVcVJwI AF0tN3f7AwAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5681 Lines: 143 Hi, > -----Original Message----- > From: Xishi Qiu [mailto:qiuxishi@huawei.com] > Sent: Tuesday, July 07, 2015 7:08 AM > To: PINTU KUMAR > Cc: corbet@lwn.net; akpm@linux-foundation.org; vbabka@suse.cz; > gorcunov@openvz.org; mhocko@suse.cz; emunson@akamai.com; > kirill.shutemov@linux.intel.com; standby24x7@gmail.com; > hannes@cmpxchg.org; vdavydov@parallels.com; hughd@google.com; > minchan@kernel.org; tj@kernel.org; rientjes@google.com; > xypron.glpk@gmx.de; dzickus@redhat.com; prarit@redhat.com; > ebiederm@xmission.com; rostedt@goodmis.org; uobergfe@redhat.com; > paulmck@linux.vnet.ibm.com; iamjoonsoo.kim@lge.com; ddstreet@ieee.org; > sasha.levin@oracle.com; koct9i@gmail.com; mgorman@suse.de; cj@linux.com; > opensource.ganesh@gmail.com; vinmenon@codeaurora.org; linux- > doc@vger.kernel.org; linux-kernel@vger.kernel.org; linux-mm@kvack.org; linux- > pm@vger.kernel.org; cpgs@samsung.com; pintu_agarwal@yahoo.com; > vishnu.ps@samsung.com; rohit.kr@samsung.com; iqbal.ams@samsung.com > Subject: Re: [PATCH 1/1] kernel/sysctl.c: Add /proc/sys/vm/shrink_memory > feature > > On 2015/7/6 22:03, PINTU KUMAR wrote: > > > Hi, > > > >> -----Original Message----- > >> From: Xishi Qiu [mailto:qiuxishi@huawei.com] > >> Sent: Monday, July 06, 2015 3:53 PM > >> To: Pintu Kumar > >> Cc: corbet@lwn.net; akpm@linux-foundation.org; vbabka@suse.cz; > >> gorcunov@openvz.org; mhocko@suse.cz; emunson@akamai.com; > >> kirill.shutemov@linux.intel.com; standby24x7@gmail.com; > >> hannes@cmpxchg.org; vdavydov@parallels.com; hughd@google.com; > >> minchan@kernel.org; tj@kernel.org; rientjes@google.com; > >> xypron.glpk@gmx.de; dzickus@redhat.com; prarit@redhat.com; > >> ebiederm@xmission.com; rostedt@goodmis.org; uobergfe@redhat.com; > >> paulmck@linux.vnet.ibm.com; iamjoonsoo.kim@lge.com; > >> ddstreet@ieee.org; sasha.levin@oracle.com; koct9i@gmail.com; > >> mgorman@suse.de; cj@linux.com; opensource.ganesh@gmail.com; > >> vinmenon@codeaurora.org; linux- doc@vger.kernel.org; > >> linux-kernel@vger.kernel.org; linux-mm@kvack.org; linux- > >> pm@vger.kernel.org; cpgs@samsung.com; pintu_agarwal@yahoo.com; > >> vishnu.ps@samsung.com; rohit.kr@samsung.com; iqbal.ams@samsung.com > >> Subject: Re: [PATCH 1/1] kernel/sysctl.c: Add > >> /proc/sys/vm/shrink_memory feature > >> > >> On 2015/7/3 21:20, Pintu Kumar wrote: > >> > >>> This patch provides 2 things: > >>> 1. Add new control called shrink_memory in /proc/sys/vm/. > >>> This control can be used to aggressively reclaim memory system-wide > >>> in one shot from the user space. A value of 1 will instruct the > >>> kernel to reclaim as much as totalram_pages in the system. > >>> Example: echo 1 > /proc/sys/vm/shrink_memory > >>> > >>> 2. Enable shrink_all_memory API in kernel with new > >> CONFIG_SHRINK_MEMORY. > >>> Currently, shrink_all_memory function is used only during hibernation. > >>> With the new config we can make use of this API for non-hibernation > >>> case also without disturbing the hibernation case. > >>> > >>> The detailed paper was presented in Embedded Linux Conference, > >>> Mar-2015 > >>> http://events.linuxfoundation.org/sites/events/files/slides/ > >>> %5BELC-2015%5D-System-wide-Memory-Defragmenter.pdf > >>> > >>> Scenarios were this can be used and helpful are: > >>> 1) Can be invoked just after system boot-up is finished. > >>> 2) Can be invoked just before entering entire system suspend. > >>> 3) Can be invoked from kernel when order-4 pages starts failing. > >>> 4) Can be helpful to completely avoid or delay the kerenl OOM condition. > >>> 5) Can be developed as a system-tool to quickly defragment entire system > >>> from user space, without the need to kill any application. > >>> > >> > >> Hi Pintu, > >> > >> How about increase min_free_kbytes and Android lowmemorykiller's level? > >> > > Thanks for the review. > > Actually in Tizen, we don't use Android LMK and we wanted to delay the > > LMK with aggressive direct_reclaim offline. > > And increasing min_free value also may not help much. > > Currently, in our case free memory never falls below 10MB, with 512MB > > RAM configuration. > > > > How about the performance as you reclaim so much memory? > (e.g. shrink page cache, use zram, ksm, compaction...) When launching the same > app next time, it may be slow, right? > Yes, obviously, there will be slight degrade in performance for relaunch of application. But, it will be better that the first launch. Please check the following data: Browser Launch: 01-01 12:06:26.550 01-01 12:06:28.340 Time taken: 1790 ms Relaunch: 01-01 12:09:08.130 01-01 12:09:08.380 Time: 250ms After shrink_memory again: 01-01 12:12:17.280 01-01 12:12:17.770 Time: 490ms The main point here is that the killing is avoided and application data is retained. Also, when the memory pressure situation arises leading to slowpath again and again, We will be already in the performance degraded state. Instead of continuous performance degradation, a one time is better. > How about use cgroup to manage the apps, but I don't know how to do the > detail. > Yes, we already use cgroups, vmpressure, to manage memory threshold for reclaim, swap and kill. Even cgroup also have a similar force_reclaim mechanism, to reclaim pages within groups for a particular threshold. But, that is at a later stages and also it does not care about order of the pages. It does not perform system-wide reclaim. > Thanks, > Xishi Qiu > > > > > > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/