Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753293AbdCAVRn (ORCPT ); Wed, 1 Mar 2017 16:17:43 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:55077 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751495AbdCAVRh (ORCPT ); Wed, 1 Mar 2017 16:17:37 -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 10:18: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: <20170301181809.GA17275@shli-mbp.local> References: <89efde633559de1ec07444f2ef0f4963a97a2ce8.1487965799.git.shli@fb.com> <20170301133624.GF1124@dhcp22.suse.cz> <20170301173710.GA12867@shli-mbp.local> <20170301174955.GB20360@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20170301174955.GB20360@dhcp22.suse.cz> User-Agent: Mutt/1.6.1 (2016-04-27) X-Originating-IP: [2620:10d:c090:200::3bf0] X-ClientProxiedBy: DM5PR2201CA0047.namprd22.prod.outlook.com (10.174.180.164) To MWHPR15MB1646.namprd15.prod.outlook.com (10.175.138.23) X-MS-Office365-Filtering-Correlation-Id: 0192d36f-9e48-4c5e-8e86-08d460cf5961 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:MWHPR15MB1646; X-Microsoft-Exchange-Diagnostics: 1;MWHPR15MB1646;3:+5GpBga2alpOFCkNUd/q5/f0e6KHqHKjv5gmfmupY17Xk3Ln6dF97gK9MeDhny/UxlSwzphqrASsmZegnsoJbgkXbc0Y23OOucR3qt9o4a6u+mXNdgThA49nw5dWAj/Zu7TEFIZeIWifNSqNIBm4CkcxOi3o6WBzlsdS8wsOj4U+9G1lJs25kbt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aiBc9Q3KRonFpPHjK4WSsLcWrjCcXIj3+cAkEUYG9+DhFjNx282VPxi4WOEy+6q6dgamHKEp0DUGDJQSiEcNQbgF4OiPQJ62IrYeZcVQwErETN4HdBLddUoOFeqNl5L640mgv14kzaPEUnF4yTmZvYD8MTdBxCEsYHvo7it5fQjH8v83W6abcSwbQkdc/rAXm2vuwNpDiwFnr5rf/ffcKuca1qCEtckvVwcBbWoJYx7aEfeqfme00UbSFfVYLB3sZUxOLCmm9vwBWuOncllS91FkTQwQnz5mOdH5FHMzVk3I04nNTzxJJy4uWUS1SB1l 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)(20161123562025)(20161123558025)(20161123560025)(20161123555025)(20161123564025)(6072148);SRVR:MWHPR15MB1646;BCL:0;PCL:0;RULEID:;SRVR:MWHPR15MB1646; X-Microsoft-Exchange-Diagnostics: 1;MWHPR15MB1646;4:eSPsOS3x5t8KsMfRghlCMpWP8/5kryUNR9k8cNUYC4h6Np/1NJzf11p6kaB7Q+wKpIbAkFCORm3yJSRPEvttC7xP57tns9rkmQ2QYLpmMG8grrxeXQdh0NG7oqPojzV/LdINDp3jQdZfQKMOiP7ybIt1lgyeM0ZZF01TmjHIwbhjHC+de8C9xfQC4vFbXBp7jdIfIw1KuCQB/VB7LjQY+ijMsw6Ka1OxV5sxzKvwL3zxqUnXF8huvBzGsZ7+2ozvakdWDbQrc39pUST+9CpfsHVWTkknWkeweYMWpIswpvZkDOnBrUjElXpGfM4wKuJrWKKlil77OsG1AS85ODfxTg4GD4/6JLsGGwtzVwYC9FkC2BybEMJ2PI/phvJqICFOcvEYo7cJlOMT8WI19eYY6T8DjeejgNCys7plrcTWoE2v/C0HsXYoOl+nbG16ZMP8hAYoTlsgkRFGdEqbH/DWXxfynKbnHNkCHLqxUpBBGAJYJtwzCtGuWjRO2EujOOQ4pkyye7PgCz2WQrnE+7eXNKgL6CHBVG9anybWdBEWxmL88+G+iJCc+cnzklVuMM7ulJB/MzVHlC8DtWEQNIl3Vso7BoHVWQrPD0Zi1bWTx23GgRwy0Hxl8n6+5xHDYys+URruqBJzVfCORr+xO1iLlA== X-Forefront-PRVS: 0233768B38 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(7916002)(39830400002)(39410400002)(39450400003)(377424004)(24454002)(98436002)(92566002)(97756001)(2906002)(23726003)(76176999)(54356999)(1076002)(54906002)(6666003)(50986999)(93886004)(25786008)(305945005)(7736002)(55016002)(189998001)(2950100002)(6916009)(53936002)(38730400002)(81166006)(33656002)(110136004)(83506001)(8676002)(6116002)(50466002)(229853002)(9686003)(5660300001)(6506006)(86362001)(4326008)(46406003)(42186005)(6246003)(18370500001);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR15MB1646;H:shli-mbp.local;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;MWHPR15MB1646;23:SPtu7a/NirXvhnD9wcMqJdU3DtlAGsQ8jF0Qb+Scv?= =?us-ascii?Q?5FWv0eXZIbPJa7i3rXbXmu7LphBI7BObU0PCuLvoZW0pIrmYDFSczkAHGcL1?= =?us-ascii?Q?XEwW9+byz2vlyCdNMToQT4up9iBthcLUEWNUY4TCqMwxY5o4OHpTGoU741nv?= =?us-ascii?Q?Ft86J6Mz0Y1Osb4/28ZVzxGUpYJ4ta6bz6rrLlCGFnip5fk63K7273R0g2gd?= =?us-ascii?Q?tro1/Q9cEzOVqhpoNzTdZgTTllyUwt92NmqzapeIV1kqZ7hs+SdjlRo3z9K4?= =?us-ascii?Q?Su0Ck0g+p+4QWRjMl8QROJv+z+8TZ+Ecimkc0bSzfHwSTridAw230GOAZYTp?= =?us-ascii?Q?WL4jlDACogx0oz/4QnYYcG/J/8xxulpDDlLthJ2ALVw5AintLPETyvKug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HPy4RKtovlA41JF5bbQNvzzoyVBqz8/Shnc3kYMoi8sp4VrGSBFDLcLYP8sOG568OQXAlYtE/gx0mr4qPTjFRcHQ= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2017 18:18:22.3321 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR15MB1646 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: 2474 Lines: 53 On Wed, Mar 01, 2017 at 06:49:56PM +0100, Michal Hocko wrote: > On Wed 01-03-17 09:37:10, Shaohua Li wrote: > > 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. > > but multiply that by the number of CPUs. > > > Like what you said, I doubt this is noticeable to userspace. > > maybe I wasn't clear enough. I've noticed and I expect others would as > well. We really shouldn't leak implementation details like that. So I > _believe_ this should be fixed. Draining all pagevecs is rather coarse > but it is the simplest thing to do. If you do not want to fold this > into the original patch I can send a standalone one. Or do you have any > concerns about draining? No, no objection at all. Just doubt it's worthy. Looks nobody complains similar issue, For exmaple, deactivate_file_page does the similar thing, then the smaps 'Referenced' could be inaccurate. Thanks, Shaohua