Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752866AbbG2L4q (ORCPT ); Wed, 29 Jul 2015 07:56:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56901 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751785AbbG2L4p (ORCPT ); Wed, 29 Jul 2015 07:56:45 -0400 Message-ID: <55B8BF73.4060207@redhat.com> Date: Wed, 29 Jul 2015 13:56:35 +0200 From: Jerome Marchand User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Minchan Kim CC: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hugh Dickins , Bongkyu Kim , Sergey Senozhatsky , Jonathan Corbet Subject: Re: [PATCH v2] mm: show proportional swap share of the mapping References: <1434373614-1041-1-git-send-email-minchan@kernel.org> <55B88FF1.7050502@redhat.com> <20150729102849.GA19352@bgram> In-Reply-To: <20150729102849.GA19352@bgram> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="euLVffF4KRGBvB1ub0ttdFGmAbOKn6Rdt" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3926 Lines: 126 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --euLVffF4KRGBvB1ub0ttdFGmAbOKn6Rdt Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 07/29/2015 12:30 PM, Minchan Kim wrote: > Hi Jerome, >=20 > On Wed, Jul 29, 2015 at 10:33:53AM +0200, Jerome Marchand wrote: >> On 06/15/2015 03:06 PM, Minchan Kim wrote: >>> We want to know per-process workingset size for smart memory manageme= nt >>> on userland and we use swap(ex, zram) heavily to maximize memory effi= ciency >>> so workingset includes swap as well as RSS. >>> >>> On such system, if there are lots of shared anonymous pages, it's >>> really hard to figure out exactly how many each process consumes >>> memory(ie, rss + wap) if the system has lots of shared anonymous >>> memory(e.g, android). >>> >>> This patch introduces SwapPss field on /proc//smaps so we can ge= t >>> more exact workingset size per process. >>> >>> Bongkyu tested it. Result is below. >>> >>> 1. 50M used swap >>> SwapTotal: 461976 kB >>> SwapFree: 411192 kB >>> >>> $ adb shell cat /proc/*/smaps | grep "SwapPss:" | awk '{sum +=3D $2} = END {print sum}'; >>> 48236 >>> $ adb shell cat /proc/*/smaps | grep "Swap:" | awk '{sum +=3D $2} END= {print sum}'; >>> 141184 >> >> Hi Minchan, >> >> I just found out about this patch. What kind of shared memory is that?= >> Since it's android, I'm inclined to think something specific like >> ashmem. I'm asking because this patch won't help for more common type = of >> shared memory. See my comment below. >=20 > It's normal heap of parent(IOW, MAP_ANON|MAP_PRIVATE memory which is sh= are > by child processes). Ok. I didn't imagine CoW pages would represent such a big share of swapped out pages. >=20 >> >>> >>> 2. 240M used swap >>> SwapTotal: 461976 kB >>> SwapFree: 216808 kB >>> >>> $ adb shell cat /proc/*/smaps | grep "SwapPss:" | awk '{sum +=3D $2} = END {print sum}'; >>> 230315 >>> $ adb shell cat /proc/*/smaps | grep "Swap:" | awk '{sum +=3D $2} END= {print sum}'; >>> 1387744 >>> >> snip >>> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c >>> index 6dee68d013ff..d537899f4b25 100644 >>> --- a/fs/proc/task_mmu.c >>> +++ b/fs/proc/task_mmu.c >>> @@ -446,6 +446,7 @@ struct mem_size_stats { >>> unsigned long anonymous_thp; >>> unsigned long swap; >>> u64 pss; >>> + u64 swap_pss; >>> }; >>> =20 >>> static void smaps_account(struct mem_size_stats *mss, struct page *p= age, >>> @@ -492,9 +493,20 @@ static void smaps_pte_entry(pte_t *pte, unsigned= long addr, >>> } else if (is_swap_pte(*pte)) { >> >> This won't work for sysV shm, tmpfs and MAP_SHARED | MAP_ANONYMOUS >> mapping pages which are pte_none when paged out. They're currently not= >> accounted at all when in swap. >=20 > This patch doesn't handle those pages because we don't have supported > thoses pages. IMHO, if someone need it, it should be another patch and > he can contribute it in future. Sure. >=20 > Thanks. >=20 --euLVffF4KRGBvB1ub0ttdFGmAbOKn6Rdt Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJVuL95AAoJEHTzHJCtsuoChD0H/jNa3nZvVNcHbF/r3MgOYYP2 5vlLkC4SFksy4jbZ778nKgIgdv51OLSZLCPuPBWzROP4QIbYC0zVWVuTiY7FD5Ph +fLyf2QhdkZWk6GBfItNkeacxXrUCeleVk32TdB++dqGHKwIFCqjQnrJV8+oonzF fLMNe8iq28nbrNTRX70RQLvhWMgq3gW27LaafSmln+E6ElnKR0/AoaWh6MeoyJvR ImoyHMXGSq+MHwKBLmiPASKu2topPsZh1BlinmLqVJs65mnmCXM8ASLqbSUeeAHe SgCp9HiArVpF8OrmnBYFK2SZKC5PX92l2XlzJ4qmODYRM+74UNRZBOT3NTPcYzc= =+F1/ -----END PGP SIGNATURE----- --euLVffF4KRGBvB1ub0ttdFGmAbOKn6Rdt-- -- 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/