Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752308AbdCASN7 (ORCPT ); Wed, 1 Mar 2017 13:13:59 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:34235 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751047AbdCASN5 (ORCPT ); Wed, 1 Mar 2017 13:13:57 -0500 Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=fb.com; Date: Wed, 1 Mar 2017 09:37:10 -0800 From: Shaohua Li To: Michal Hocko CC: , , , , , , , , Subject: Re: [PATCH V5 6/6] proc: show MADV_FREE pages info in smaps Message-ID: <20170301173710.GA12867@shli-mbp.local> References: <89efde633559de1ec07444f2ef0f4963a97a2ce8.1487965799.git.shli@fb.com> <20170301133624.GF1124@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20170301133624.GF1124@dhcp22.suse.cz> User-Agent: Mutt/1.6.1 (2016-04-27) X-Originating-IP: [2620:10d:c090:200::3bf0] X-ClientProxiedBy: MWHPR14CA0042.namprd14.prod.outlook.com (10.171.142.156) To CY4PR15MB1637.namprd15.prod.outlook.com (10.175.119.149) X-MS-Office365-Filtering-Correlation-Id: 90532aad-4efc-4e4e-d9fc-08d460c99b61 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY4PR15MB1637; X-Microsoft-Exchange-Diagnostics: 1;CY4PR15MB1637;3:aKLkYMLCS1BTb8WpaCxBQ18WrjXKg/d1WuvVi7u4MhZAJ8os6ANBFTHswwomCrcpcbyZ7zWQ3MMi3hBMCcPuD+WclfQtLo9Ojb1kCwdB+QSErKchV3gC3OadT+xboOvBRoExU+oOiiLVXEtOVCTKA7Sjf3tiwu0kWOah3F3C8TQ8CPd86rU7q+qrw/QstgGz6Ei7fga2M5LnMB8YLbNTLf2BMy3G916n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RnvZ4TwjNHKt52EjPuzi2OiXa90KLeySfMsBIbdIWqejpK97XjBVZrk2+6hX7YqHNtl9Qr4VwTN87jdQwr7jbb9lcmIYVBWhHOpBcjlkOri+fmi8iTadO1ulOC3YDMos8jLXgFSOPA5MuYSPZUFpBx/x48jcpODUYGbWsOsao2y1P0QLFAkwwMECwv0KwxfXLa6K/DSbmMxZFT6FtiqX8Lk4Hdnb6OCCy2wlP80 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(72170088055959); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123558025)(20161123560025)(20161123564025)(20161123555025)(20161123562025)(6072148);SRVR:CY4PR15MB1637;BCL:0;PCL:0;RULEID:;SRVR:CY4PR15MB1637; X-Microsoft-Exchange-Diagnostics: 1;CY4PR15MB1637;4:W21hLng5a/937XCIPOXLnQ0kVcp4BsfKOu6zK7xxR7rKuTooxYbSYamH8zPA4NND738PMHdsqJLZoj1yvL72mnp88YxrIC4hobDIl+NAxzuj9lhUalvWhV97GCwipyoJ31PNOSInOX7KdnRTGrb7wrXsdbRa/hmZA1hJQkphSWeb/Ux5UNvbV/3cHf7xQc1noFwYGsC03sTJveC+8F1EmY+o9aYNlSOD8+rSvo5D5g7PtRvS6iDi05obNxDei9Duqql5yMPeAm4mhtPon9Xnf6clOJMNrBjujyP2GMhhLTRhhpOI1tOIhTzW6FIaUvQQFlao74aLg85HWjLreZ7fxsXrL9DuswVk5qzzZt7rlTebCuR9+eQtLqX8UjDWmB+ZSZ0g73B79fYk1xhn3PGOlFsSr6Z9mJmzp7zZXtMxphRMAy7+8tWYox+y50eNUFKFEbEBao2Dehd75o2dtLUJg5pXZntdw24EoWyo4MfXCwW8B9otx0Em5drF9zMLsMZ9MnF0j35hVW3tEeXySDzO4Px8MBXe43w50pdTpNRjvLq00TIxClv5vwqoBHOrsoh9vH2LaJa5gzeySc6UwD0JBfCcLxIqIyRjZr6QTvR7nvQwT4F4crmauWrIPW4ycQtkQ7lMFz/jOW+E1LqgNzEr+g== X-Forefront-PRVS: 0233768B38 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(7916002)(39450400003)(39410400002)(39830400002)(377424004)(24454002)(54906002)(2906002)(5660300001)(55016002)(9686003)(38730400002)(4326008)(23726003)(6116002)(98436002)(6666003)(6506006)(6916009)(1076002)(2950100002)(83506001)(25786008)(7736002)(86362001)(42186005)(229853002)(110136004)(305945005)(6246003)(46406003)(81166006)(92566002)(97756001)(33656002)(189998001)(53936002)(54356999)(50466002)(50986999)(76176999)(8676002)(18370500001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY4PR15MB1637;H:shli-mbp.local;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY4PR15MB1637;23:LhOZwX4n342gXCOhIpJ8Lx/mb/J6aEwrQF89gN7oA?= =?us-ascii?Q?l0v40qO9giAEncpJjzHAHtizrlE+BNHWvjEO5AxxaJjPEBByn6oTRtfXMzxc?= =?us-ascii?Q?5ZJ1+i78ibW5m6zxy2u7UjXLSOg3oc5bQS70EBEWZTynbhbTkSoWsTBwYx3j?= =?us-ascii?Q?bXjVQbt0Qhtx7flxXT350nfuPY8mX/AMYZYGfv3vLICWYWrkTmJHPidEG8kk?= =?us-ascii?Q?JWyU3mJ9uvcgyhzU6az+v3vQWp9J8lFajwB1yh7L4A2Abvog5buvI7I+RMCN?= =?us-ascii?Q?SnCvQgvD7B6yB2hJl4lWJZwo9vFwm53FDPrh8vSkg1WR+bp9baqmBimJhuST?= =?us-ascii?Q?mUZZSggjBiCt4CWvuXK6I4Z5xWEQG6S0wJEyid+QOOEGHdwbyb6+Gl5F6JDT?= =?us-ascii?Q?auM9UqtY+BbSBZcazL7KmHpxEI593YmXa4TQBPK2PrpRhttiGmrxgoWEPi2g?= =?us-ascii?Q?j5SC4NF71cDTiYq7+c77vF+f2HoyenBSm2Ym+4iGJMgZzgbdQHLKFltVmI2V?= =?us-ascii?Q?5hGe86FU/TeaaLQ3/8uJTzLQO18TCFLGWmwAyh8IOH5B6RFNZmjUjSUQoi++?= =?us-ascii?Q?Zxg0DMRtd05NKgPGkjlW3sF1u0PB7dirHEZ8mJUAzaQGY+sgu4kv2beKZB41?= =?us-ascii?Q?u36/dSZBdXS+JJUgV5LuyrwdVJfj/OXM28FRFcBOX+V081UGibsSiNyJDoQp?= =?us-ascii?Q?4waprWp6IQFl+5bq2A6e7OXCorSAFg+jqojMXg7+bl28V08fu/9uq4QQtN+s?= =?us-ascii?Q?fbvQJ1ijnQDewsmvNb2Byar/6phPkCjVbas+Tr0Y4le1JbIyYuHG+g7jnN+K?= =?us-ascii?Q?YdaAUKOI5nAD5+R7h8dX7ri7/yFQC2eVpBgvXo2XHis9t/WFcCxHqA2iDRge?= =?us-ascii?Q?QW6nnolmH9N+A0sc5SIe+3RO5shRfAatp0VBV34GWA5akti00CkxlPg+lqzP?= =?us-ascii?Q?JqoGjuzKeC83tYk/0dzqll529Jbu9vwHPPisH+KpfhaZlD+UXM04wAkJDf+H?= =?us-ascii?Q?XSkJoZfVBR/RU7jJu13CBmUfKN77XDYG5CUqf6MNFA9Yfpe051i2isSHuUhD?= =?us-ascii?Q?YhEbKJeyHetsbeTlaMvL5e9BbJy5LngBSfAeDqZAyJ4cSELmWxiny+6sVC20?= =?us-ascii?Q?lVph7ITcfY=3D?= X-Microsoft-Exchange-Diagnostics: 1;CY4PR15MB1637;6:odijw/pg8C3j4nPQ5EFmhyHsZYwSxDCCNGoLjBvFn9NckW3nVXwgze95GbXWG+zUhwco+4gyJgw23vIkz08QXwiANMu1TtDiP6Hpmwyr7shUSLu7Aocwqp6NS7u53sm9roM16Iy7pCGloXABqoEtUM/6eHoB7guwjgIHHieC+nBcDKCUOmTqRtRknzAhmYTzuLiL2+WKud0oqE7jOQ/4RYuLv23FFBimqu4QDWjp4lu98O8qFL0GP/TOONr0NdM8DAH1Y2mSLTd9qNQEdE8EXOx9rYfBWlYZ/WxLqHf41zNFf/LpAm0HFDm4PjBH/468gbWzJ34kBkToEhq6CdpuSLlzUB2tLPjJdpv6ZEXfyezJOCaelyEtxWVm06Jnk5Vum3eifla+JImwrM6KeRVT/w==;5:MtrYd/NMQL85aab7HyJghwfGsuNjfA/oCDC5OfMzaBuKnx+0KLOw6bBKSYQnQhlVT0McYz6UnNvI5PFqgj6AtD18OzvjtlxAFVHhZjH8tzadKssxTFYR1JBWn3Qinowo1Qieh3pLGNAM131wZ7Dv+w==;24:fFkVRColDRvzxlJi1fqYRvUV3k3KaDtkE7Nko8tyUJUPh8qDca8Gd4jdvvWyVPmRxo6coQXEb1gFZLMwulSsZK+f0Yy9UudrIbWgAQY9Adg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY4PR15MB1637;7:9o8ZEFzO8of1+qFpfgBu9wNvvOiMXEBN5fM9/SHi9YefTJ+tqhtgjloZqxR4+AzAEcMCdZIz95ANEk9Ucthi+n4slaHl97sw43P8OPv4azhm1pRx4D22/MvInXYoj6K4MR0Pf7Fg+qsFjDTNywwfCM6aKmfcaP9IMKW5trDO0o96wjd5Txiruv43oovWtOySINq10s3lAL1h9Ljbmmxx7UM9ru8XfeFTa828WgXANYzW4Cyh3Htc5yQ0MsZ4vFQu6HR6R1X/PUqFGqcbKXGLffFE5lrC2JAd/5eymbpIpvqMK2j8n8W+RlECTf6+OWhE8aF+5ygiHpfR6qeTCtIRfQ==;20:5UuzhXUtRs/J3xEWT0BjplSsJHll88X9EQ8DZkDJdADzZ0l31ypx8wIoBwalCJom8xoXoDINVCLDv+IIWZUajfmsanhfWr+hcsc3P1thsGkeCc4X8JAVmREFDgoM3CfT1Ninua7FKVqMDrYgBn4Jx8Gv3ITq1pFBGg3nOZVGzTA= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2017 17:37:17.0560 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR15MB1637 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-03-01_13:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2044 Lines: 56 On Wed, Mar 01, 2017 at 02:36:24PM +0100, Michal Hocko wrote: > On Fri 24-02-17 13:31:49, Shaohua Li wrote: > > show MADV_FREE pages info of each vma in smaps. The interface is for > > diganose or monitoring purpose, userspace could use it to understand > > what happens in the application. Since userspace could dirty MADV_FREE > > pages without notice from kernel, this interface is the only place we > > can get accurate accounting info about MADV_FREE pages. > > I have just got to test this patchset and noticed something that was a > bit surprising > > madvise(mmap(len), len, MADV_FREE) > Size: 102400 kB > Rss: 102400 kB > Pss: 102400 kB > Shared_Clean: 0 kB > Shared_Dirty: 0 kB > Private_Clean: 102400 kB > Private_Dirty: 0 kB > Referenced: 0 kB > Anonymous: 102400 kB > LazyFree: 102368 kB > > It took me a some time to realize that LazyFree is not accurate because > there are still pages on the per-cpu lru_lazyfree_pvecs. I believe this > is an implementation detail which shouldn't be visible to the userspace. > Should we simply drain the pagevec? A crude way would be to simply > lru_add_drain_all after we are done with the given range. We can also > make this lru_lazyfree_pvecs specific but I am not sure this is worth > the additional code. Minchan's original patch includes a drain of pvec. I discard it because I think it's not worth the effort. There aren't too many memory in the per-cpu vecs. Like what you said, I doubt this is noticeable to userspace. Thanks, Shaohua > --- > diff --git a/mm/madvise.c b/mm/madvise.c > index dc5927c812d3..d2c318db16c9 100644 > --- a/mm/madvise.c > +++ b/mm/madvise.c > @@ -474,7 +474,7 @@ static int madvise_free_single_vma(struct vm_area_struct *vma, > madvise_free_page_range(&tlb, vma, start, end); > mmu_notifier_invalidate_range_end(mm, start, end); > tlb_finish_mmu(&tlb, start, end); > - > + lru_add_drain_all(); > return 0; > } > > -- > Michal Hocko > SUSE Labs