mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Fan Du <fan.du@intel.com>,
	akpm@linux-foundation.org, hch@lst.de, dan.j.williams@intel.com,
	mhocko@kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] Add /proc/PID/smaps support for DAX
Date: Thu, 26 Oct 2017 07:03:01 -0700	[thread overview]
Message-ID: <482dcf1c-6013-c800-3e95-7476b9e52020@intel.com> (raw)
In-Reply-To: <1508994790-15427-1-git-send-email-fan.du@intel.com>

I'm honestly not understanding what problem this solves.  Could you,
perhaps, do a before and after of smaps with and without this patch?

> +/* page structure behind DAX mappings is NOT compound page
> + * when it's a huge page mappings, so introduce new API to
> + * account for both PMD and PUD mapping.
> + */

Why do they need to be compound?  Why don't we just make them compound
instead of adding all this code which is *just* for DAX?

> +static void smaps_account_dax_huge(struct mem_size_stats *mss,
> +			struct page *page, unsigned long size, bool young, bool dirty)
> +{
> +	int mapcount = page_mapcount(page);
> +
> +	if (PageAnon(page)) {
> +		mss->anonymous += size;
> +		if (!PageSwapBacked(page) && !dirty && !PageDirty(page))
> +			mss->lazyfree += size;
> +	}

How can you have DAX anonymous huge pages?

> +	mss->resident += size;
> +	/* Accumulate the size in pages that have been accessed. */
> +	if (young || page_is_young(page) || PageReferenced(page))
> +		mss->referenced += size;

Isn't this just a copy'n'paste of smaps_account() code?

> +	/*
> +	 * page_count(page) == 1 guarantees the page is mapped exactly once.
> +	 * If any subpage of the compound page mapped with PTE it would elevate
> +	 * page_count().
> +	 */
> +	if (page_count(page) == 1) {
> +		if (dirty || PageDirty(page))
> +			mss->private_dirty += size;
> +		else
> +			mss->private_clean += size;
> +		mss->pss += (u64)size << PSS_SHIFT;
> +		return;
> +	}

PSS makes *zero* sense for DAX.  The "memory" is used whether the
mapping exists or not.

Also, the idea of "private" doesn't really make sense here.

> +	if (mapcount >= 2) {
> +		if (dirty || PageDirty(page))
> +			mss->shared_dirty += size;
> +		else
> +			mss->shared_clean += size;
> +		mss->pss += (size << PSS_SHIFT) / mapcount;
> +	} else {
> +		if (dirty || PageDirty(page))
> +			mss->private_dirty += size;
> +		else
> +			mss->private_clean += size;
> +		mss->pss += size << PSS_SHIFT;
> +	}
> +}
> +
>  #ifdef CONFIG_SHMEM
>  static int smaps_pte_hole(unsigned long addr, unsigned long end,
>  		struct mm_walk *walk)
> @@ -528,7 +577,16 @@ static void smaps_pte_entry(pte_t *pte, unsigned long addr,
>  	struct page *page = NULL;
>  
>  	if (pte_present(*pte)) {
> -		page = vm_normal_page(vma, addr, *pte);
> +		if (!vma_is_dax(vma))
> +			page = vm_normal_page(vma, addr, *pte);
> +		else if (pte_devmap(*pte)) {
> +			struct dev_pagemap *pgmap;
> +
> +			pgmap = get_dev_pagemap(pte_pfn(*pte), NULL);
> +			if (!pgmap)
> +				return;
> +			page = pte_page(*pte);
> +		}
>  	} else if (is_swap_pte(*pte)) {
>  		swp_entry_t swpent = pte_to_swp_entry(*pte);
>  
> @@ -579,7 +637,19 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr,
>  	struct page *page;
>  
>  	/* FOLL_DUMP will return -EFAULT on huge zero page */
> -	page = follow_trans_huge_pmd(vma, addr, pmd, FOLL_DUMP);
> +	if (!vma_is_dax(vma))
> +		page = follow_trans_huge_pmd(vma, addr, pmd, FOLL_DUMP);
> +	else if (pmd_devmap(*pmd)) {
> +		struct dev_pagemap *pgmap;
> +
> +		pgmap = get_dev_pagemap(pmd_pfn(*pmd), NULL);
> +		if (!pgmap)
> +			return;
> +		page = pmd_page(*pmd);
> +		smaps_account_dax_huge(mss, page, PMD_SIZE, pmd_young(*pmd),
> +			pmd_dirty(*pmd));
> +		return;
> +	}
>  	if (IS_ERR_OR_NULL(page))
>  		return;
>  	if (PageAnon(page))
> 

There's a fair amount of copying and pasting going on here.  There is,
again, a bunch of specialized DAX code.  Isn't there a way to do this
more generically?

  parent reply	other threads:[~2017-10-26 14:03 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-25  0:27 [PATCHv3 1/2] proc: mm: export PTE sizes directly in smaps Fan Du
2017-10-25  0:27 ` [PATCH 2/2] Add /proc/PID/{smaps, numa_maps} support for DAX Fan Du
2017-10-25  9:30   ` Michal Hocko
2017-10-25 17:14     ` Dave Hansen
2017-10-26 14:16       ` Michal Hocko
2017-10-26 14:24         ` Dave Hansen
2017-10-26 14:31           ` Michal Hocko
2017-10-26 14:51             ` Dave Hansen
2017-10-26 15:07               ` Michal Hocko
2017-10-26 15:56                 ` Dan Williams
2017-10-27  4:00               ` Du, Fan
2017-10-27 10:31                 ` Dan Williams
2017-10-28  2:07   ` kbuild test robot
2017-10-25  9:28 ` [PATCHv3 1/2] proc: mm: export PTE sizes directly in smaps Michal Hocko
2017-10-26  1:41   ` Du, Fan
2017-10-26  5:13     ` [PATCH v4] Add /proc/PID/smaps support for DAX Fan Du
2017-10-26  9:16       ` Dan Williams
2017-10-27  2:49         ` Du, Fan
2017-10-26 14:03       ` Dave Hansen [this message]
2017-10-27  2:47         ` Du, Fan
2017-10-27  8:07           ` Michal Hocko
2017-10-27  8:24             ` Du, Fan
2017-10-27  8:42               ` Michal Hocko
2017-10-27  9:03                 ` Du, Fan
2017-10-27  9:09                   ` Michal Hocko
2017-10-27  9:17                     ` Du, Fan
2017-10-27  9:26                       ` Michal Hocko
2017-10-27  9:34                 ` Du, Fan
2017-10-26 14:19     ` [PATCHv3 1/2] proc: mm: export PTE sizes directly in smaps Michal Hocko
2017-10-26 14:25       ` Dave Hansen
2017-10-29 14:19 ` [lkp-robot] [proc] eb948c71f7: WARNING:at_mm/hugetlb.c:#hugetlb_add_hstate kernel test robot

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=482dcf1c-6013-c800-3e95-7476b9e52020@intel.com \
    --to=dave.hansen@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=dan.j.williams@intel.com \
    --cc=fan.du@intel.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhocko@kernel.org \
    /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®