mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.cz>
To: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Mel Gorman <mgorman@suse.de>,
	Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>,
	linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] hugetlb: Do not account hugetlb pages as NR_FILE_PAGES
Date: Fri, 22 May 2015 08:01:37 +0200	[thread overview]
Message-ID: <20150522060136.GB5109@dhcp22.suse.cz> (raw)
In-Reply-To: <555E0573.3000009@oracle.com>

On Thu 21-05-15 09:18:59, Mike Kravetz wrote:
> On 05/21/2015 06:27 AM, Michal Hocko wrote:
> >hugetlb pages uses add_to_page_cache to track shared mappings. This
> >is OK from the data structure point of view but it is less so from the
> >NR_FILE_PAGES accounting:
> >	- huge pages are accounted as 4k which is clearly wrong
> >	- this counter is used as the amount of the reclaimable page
> >	  cache which is incorrect as well because hugetlb pages are
> >	  special and not reclaimable
> >	- the counter is then exported to userspace via /proc/meminfo
> >	  (in Cached:), /proc/vmstat and /proc/zoneinfo as
> >	  nr_file_pages which is confusing at least:
> >	  Cached:          8883504 kB
> >	  HugePages_Free:     8348
> >	  ...
> >	  Cached:          8916048 kB
> >	  HugePages_Free:      156
> >	  ...
> >	  thats 8192 huge pages allocated which is ~16G accounted as 32M
> >
> >There are usually not that many huge pages in the system for this to
> >make any visible difference e.g. by fooling __vm_enough_memory or
> >zone_pagecache_reclaimable.
> >
> >Fix this by special casing huge pages in both __delete_from_page_cache
> >and __add_to_page_cache_locked. replace_page_cache_page is currently
> >only used by fuse and that shouldn't touch hugetlb pages AFAICS but it
> >is more robust to check for special casing there as well.
> >
> >Hugetlb pages shouldn't get to any other paths where we do accounting:
> >	- migration - we have a special handling via
> >	  hugetlbfs_migrate_page
> >	- shmem - doesn't handle hugetlb pages directly even for
> >	  SHM_HUGETLB resp. MAP_HUGETLB
> >	- swapcache - hugetlb is not swapable
> >
> >This has a user visible effect but I believe it is reasonable because
> >the previously exported number is simply bogus.
> >
> >An alternative would be to account hugetlb pages with their real size
> >and treat them similar to shmem. But this has some drawbacks.
> >
> >First we would have to special case in kernel users of NR_FILE_PAGES and
> >considering how hugetlb is special we would have to do it everywhere. We
> >do not want Cached exported by /proc/meminfo to include it because the
> >value would be even more misleading.
> >__vm_enough_memory and zone_pagecache_reclaimable would have to do
> >the same thing because those pages are simply not reclaimable. The
> >correction is even not trivial because we would have to consider all
> >active hugetlb page sizes properly. Users of the counter outside of the
> >kernel would have to do the same.
> >So the question is why to account something that needs to be basically
> >excluded for each reasonable usage. This doesn't make much sense to me.
> >
> >It seems that this has been broken since hugetlb was introduced but I
> >haven't checked the whole history.
> >
> >Signed-off-by: Michal Hocko <mhocko@suse.cz>
> 
> Just for grins, I added this to my hugetlbfs fallocate stress testing
> which really exercises hugetlb add and delete from page cache.
> Everything is as expected.
> 
> Tested-by: Mike Kravetz <mike.kravetz@oracle.com>

Thanks for your testing!

-- 
Michal Hocko
SUSE Labs

  reply	other threads:[~2015-05-22  6:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-21 13:27 Michal Hocko
2015-05-21 13:52 ` Mel Gorman
2015-05-21 16:18 ` Mike Kravetz
2015-05-22  6:01   ` Michal Hocko [this message]
2015-05-21 17:09 ` Johannes Weiner
2015-05-22 14:21   ` Michal Hocko
2015-05-22 14:28     ` Michal Hocko
2015-05-22 14:35     ` Mel Gorman
2015-05-25 15:24       ` Vlastimil Babka
2015-06-02  9:25         ` Michal Hocko
2015-06-02  9:33           ` Vlastimil Babka
2015-06-02  9:38             ` Michal Hocko
2015-06-02 10:00               ` Michal Hocko
2015-05-22  5:09 ` Naoya Horiguchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150522060136.GB5109@dhcp22.suse.cz \
    --to=mhocko@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=mike.kravetz@oracle.com \
    --cc=n-horiguchi@ah.jp.nec.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®