All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nai Xia <nai.xia@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Izik Eidus <ieidus@redhat.com>,
	Hugh Dickins <hugh.dickins@tiscali.co.uk>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Chris Wright <chrisw@sous-sol.org>,
	Rik van Riel <riel@redhat.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] ksm: add vm_stat and meminfo entry to reflect pte mapping to ksm pages
Date: Fri, 18 Mar 2011 07:29:43 +0000	[thread overview]
Message-ID: <201103181529.43659.nai.xia@gmail.com> (raw)
In-Reply-To: <20110302143142.a3c0002b.akpm@linux-foundation.org>


>On Thursday 03 March 2011, at 06:31:42, <Andrew Morton <akpm@linux-foundation.org>> wrote
> This patch obviously wasn't tested with CONFIG_KSM=n, which was a
> pretty basic patch-testing failure :(

Oops, I will be careful to avoid similar mistakes next time.

> 
> I fixed up my tree with the below, but really the amount of ifdeffing
> is unacceptable - please find a cleaner way to fix up this patch.

Ok, I will have a try in my next patch submit. 

Thanks,
-Nai
> 
> --- a/mm/ksm.c~ksm-add-vm_stat-and-meminfo-entry-to-reflect-pte-mapping-to-ksm-pages-fix
> +++ a/mm/ksm.c
> @@ -883,7 +883,6 @@ static int try_to_merge_one_page(struct 
>  	 */
>  	if (write_protect_page(vma, page, &orig_pte) = 0) {
>  		if (!kpage) {
> -			long mapcount = page_mapcount(page);
>  			/*
>  			 * While we hold page lock, upgrade page from
>  			 * PageAnon+anon_vma to PageKsm+NULL stable_node:
> @@ -891,10 +890,12 @@ static int try_to_merge_one_page(struct 
>  			 */
>  			set_page_stable_node(page, NULL);
>  			mark_page_accessed(page);
> -			if (mapcount)
> +#ifdef CONFIG_KSM
> +			if (page_mapcount(page))
>  				add_zone_page_state(page_zone(page),
>  						    NR_KSM_PAGES_SHARING,
>  						    mapcount);
> +#endif
>  			err = 0;
>  		} else if (pages_identical(page, kpage))
>  			err = replace_page(vma, page, kpage, orig_pte);
> --- a/mm/memory.c~ksm-add-vm_stat-and-meminfo-entry-to-reflect-pte-mapping-to-ksm-pages-fix
> +++ a/mm/memory.c
> @@ -719,8 +719,10 @@ copy_one_pte(struct mm_struct *dst_mm, s
>  			rss[MM_ANONPAGES]++;
>  		else
>  			rss[MM_FILEPAGES]++;
> +#ifdef CONFIG_KSM
>  		if (PageKsm(page)) /* follows page_dup_rmap() */
>  			inc_zone_page_state(page, NR_KSM_PAGES_SHARING);
> +#endif
>  	}
>  
>  out_set_pte:
> --- a/mm/rmap.c~ksm-add-vm_stat-and-meminfo-entry-to-reflect-pte-mapping-to-ksm-pages-fix
> +++ a/mm/rmap.c
> @@ -893,11 +893,12 @@ void do_page_add_anon_rmap(struct page *
>  			__inc_zone_page_state(page,
>  					      NR_ANON_TRANSPARENT_HUGEPAGES);
>  	}
> +#ifdef CONFIG_KSM
>  	if (unlikely(PageKsm(page))) {
>  		__inc_zone_page_state(page, NR_KSM_PAGES_SHARING);
>  		return;
>  	}
> -
> +#endif
>  	VM_BUG_ON(!PageLocked(page));
>  	VM_BUG_ON(address < vma->vm_start || address >= vma->vm_end);
>  	if (first)
> @@ -955,9 +956,10 @@ void page_add_file_rmap(struct page *pag
>   */
>  void page_remove_rmap(struct page *page)
>  {
> +#ifdef CONFIG_KSM
>  	if (PageKsm(page))
>  		__dec_zone_page_state(page, NR_KSM_PAGES_SHARING);
> -
> +#endif
>  	/* page still mapped by someone else? */
>  	if (!atomic_add_negative(-1, &page->_mapcount))
>  		return;
> _
> 
> 

WARNING: multiple messages have this Message-ID (diff)
From: Nai Xia <nai.xia@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Izik Eidus <ieidus@redhat.com>,
	Hugh Dickins <hugh.dickins@tiscali.co.uk>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Chris Wright <chrisw@sous-sol.org>,
	Rik van Riel <riel@redhat.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] ksm: add vm_stat and meminfo entry to reflect pte mapping to ksm pages
Date: Fri, 18 Mar 2011 15:29:43 +0800	[thread overview]
Message-ID: <201103181529.43659.nai.xia@gmail.com> (raw)
In-Reply-To: <20110302143142.a3c0002b.akpm@linux-foundation.org>


>On Thursday 03 March 2011, at 06:31:42, <Andrew Morton <akpm@linux-foundation.org>> wrote
> This patch obviously wasn't tested with CONFIG_KSM=n, which was a
> pretty basic patch-testing failure :(

Oops, I will be careful to avoid similar mistakes next time.

> 
> I fixed up my tree with the below, but really the amount of ifdeffing
> is unacceptable - please find a cleaner way to fix up this patch.

Ok, I will have a try in my next patch submit. 

Thanks,
-Nai
> 
> --- a/mm/ksm.c~ksm-add-vm_stat-and-meminfo-entry-to-reflect-pte-mapping-to-ksm-pages-fix
> +++ a/mm/ksm.c
> @@ -883,7 +883,6 @@ static int try_to_merge_one_page(struct 
>  	 */
>  	if (write_protect_page(vma, page, &orig_pte) == 0) {
>  		if (!kpage) {
> -			long mapcount = page_mapcount(page);
>  			/*
>  			 * While we hold page lock, upgrade page from
>  			 * PageAnon+anon_vma to PageKsm+NULL stable_node:
> @@ -891,10 +890,12 @@ static int try_to_merge_one_page(struct 
>  			 */
>  			set_page_stable_node(page, NULL);
>  			mark_page_accessed(page);
> -			if (mapcount)
> +#ifdef CONFIG_KSM
> +			if (page_mapcount(page))
>  				add_zone_page_state(page_zone(page),
>  						    NR_KSM_PAGES_SHARING,
>  						    mapcount);
> +#endif
>  			err = 0;
>  		} else if (pages_identical(page, kpage))
>  			err = replace_page(vma, page, kpage, orig_pte);
> --- a/mm/memory.c~ksm-add-vm_stat-and-meminfo-entry-to-reflect-pte-mapping-to-ksm-pages-fix
> +++ a/mm/memory.c
> @@ -719,8 +719,10 @@ copy_one_pte(struct mm_struct *dst_mm, s
>  			rss[MM_ANONPAGES]++;
>  		else
>  			rss[MM_FILEPAGES]++;
> +#ifdef CONFIG_KSM
>  		if (PageKsm(page)) /* follows page_dup_rmap() */
>  			inc_zone_page_state(page, NR_KSM_PAGES_SHARING);
> +#endif
>  	}
>  
>  out_set_pte:
> --- a/mm/rmap.c~ksm-add-vm_stat-and-meminfo-entry-to-reflect-pte-mapping-to-ksm-pages-fix
> +++ a/mm/rmap.c
> @@ -893,11 +893,12 @@ void do_page_add_anon_rmap(struct page *
>  			__inc_zone_page_state(page,
>  					      NR_ANON_TRANSPARENT_HUGEPAGES);
>  	}
> +#ifdef CONFIG_KSM
>  	if (unlikely(PageKsm(page))) {
>  		__inc_zone_page_state(page, NR_KSM_PAGES_SHARING);
>  		return;
>  	}
> -
> +#endif
>  	VM_BUG_ON(!PageLocked(page));
>  	VM_BUG_ON(address < vma->vm_start || address >= vma->vm_end);
>  	if (first)
> @@ -955,9 +956,10 @@ void page_add_file_rmap(struct page *pag
>   */
>  void page_remove_rmap(struct page *page)
>  {
> +#ifdef CONFIG_KSM
>  	if (PageKsm(page))
>  		__dec_zone_page_state(page, NR_KSM_PAGES_SHARING);
> -
> +#endif
>  	/* page still mapped by someone else? */
>  	if (!atomic_add_negative(-1, &page->_mapcount))
>  		return;
> _
> 
> 

WARNING: multiple messages have this Message-ID (diff)
From: Nai Xia <nai.xia@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Izik Eidus <ieidus@redhat.com>,
	Hugh Dickins <hugh.dickins@tiscali.co.uk>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Chris Wright <chrisw@sous-sol.org>,
	Rik van Riel <riel@redhat.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] ksm: add vm_stat and meminfo entry to reflect pte mapping to ksm pages
Date: Fri, 18 Mar 2011 15:29:43 +0800	[thread overview]
Message-ID: <201103181529.43659.nai.xia@gmail.com> (raw)
In-Reply-To: <20110302143142.a3c0002b.akpm@linux-foundation.org>


>On Thursday 03 March 2011, at 06:31:42, <Andrew Morton <akpm@linux-foundation.org>> wrote
> This patch obviously wasn't tested with CONFIG_KSM=n, which was a
> pretty basic patch-testing failure :(

Oops, I will be careful to avoid similar mistakes next time.

> 
> I fixed up my tree with the below, but really the amount of ifdeffing
> is unacceptable - please find a cleaner way to fix up this patch.

Ok, I will have a try in my next patch submit. 

Thanks,
-Nai
> 
> --- a/mm/ksm.c~ksm-add-vm_stat-and-meminfo-entry-to-reflect-pte-mapping-to-ksm-pages-fix
> +++ a/mm/ksm.c
> @@ -883,7 +883,6 @@ static int try_to_merge_one_page(struct 
>  	 */
>  	if (write_protect_page(vma, page, &orig_pte) == 0) {
>  		if (!kpage) {
> -			long mapcount = page_mapcount(page);
>  			/*
>  			 * While we hold page lock, upgrade page from
>  			 * PageAnon+anon_vma to PageKsm+NULL stable_node:
> @@ -891,10 +890,12 @@ static int try_to_merge_one_page(struct 
>  			 */
>  			set_page_stable_node(page, NULL);
>  			mark_page_accessed(page);
> -			if (mapcount)
> +#ifdef CONFIG_KSM
> +			if (page_mapcount(page))
>  				add_zone_page_state(page_zone(page),
>  						    NR_KSM_PAGES_SHARING,
>  						    mapcount);
> +#endif
>  			err = 0;
>  		} else if (pages_identical(page, kpage))
>  			err = replace_page(vma, page, kpage, orig_pte);
> --- a/mm/memory.c~ksm-add-vm_stat-and-meminfo-entry-to-reflect-pte-mapping-to-ksm-pages-fix
> +++ a/mm/memory.c
> @@ -719,8 +719,10 @@ copy_one_pte(struct mm_struct *dst_mm, s
>  			rss[MM_ANONPAGES]++;
>  		else
>  			rss[MM_FILEPAGES]++;
> +#ifdef CONFIG_KSM
>  		if (PageKsm(page)) /* follows page_dup_rmap() */
>  			inc_zone_page_state(page, NR_KSM_PAGES_SHARING);
> +#endif
>  	}
>  
>  out_set_pte:
> --- a/mm/rmap.c~ksm-add-vm_stat-and-meminfo-entry-to-reflect-pte-mapping-to-ksm-pages-fix
> +++ a/mm/rmap.c
> @@ -893,11 +893,12 @@ void do_page_add_anon_rmap(struct page *
>  			__inc_zone_page_state(page,
>  					      NR_ANON_TRANSPARENT_HUGEPAGES);
>  	}
> +#ifdef CONFIG_KSM
>  	if (unlikely(PageKsm(page))) {
>  		__inc_zone_page_state(page, NR_KSM_PAGES_SHARING);
>  		return;
>  	}
> -
> +#endif
>  	VM_BUG_ON(!PageLocked(page));
>  	VM_BUG_ON(address < vma->vm_start || address >= vma->vm_end);
>  	if (first)
> @@ -955,9 +956,10 @@ void page_add_file_rmap(struct page *pag
>   */
>  void page_remove_rmap(struct page *page)
>  {
> +#ifdef CONFIG_KSM
>  	if (PageKsm(page))
>  		__dec_zone_page_state(page, NR_KSM_PAGES_SHARING);
> -
> +#endif
>  	/* page still mapped by someone else? */
>  	if (!atomic_add_negative(-1, &page->_mapcount))
>  		return;
> _
> 
> 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-03-18  7:29 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-26 14:56 [PATCH] ksm: add vm_stat and meminfo entry to reflect pte mapping to ksm pages Nai Xia
2011-02-26 14:56 ` Nai Xia
2011-02-26 14:56 ` Nai Xia
2011-03-01  2:21 ` [PATCH] ksm: add vm_stat and meminfo entry to reflect pte Dave Hansen
2011-03-01  2:21   ` [PATCH] ksm: add vm_stat and meminfo entry to reflect pte mapping to ksm pages Dave Hansen
2011-03-01  2:21   ` Dave Hansen
2011-03-18  6:44   ` xianai
2011-03-18  6:44     ` xianai
2011-03-18  6:44     ` xianai
2011-03-01 23:41 ` [PATCH] ksm: add vm_stat and meminfo entry to reflect pte Andrew Morton
2011-03-01 23:41   ` [PATCH] ksm: add vm_stat and meminfo entry to reflect pte mapping to ksm pages Andrew Morton
2011-03-01 23:41   ` Andrew Morton
2011-03-18  7:16   ` Nai Xia
2011-03-18  7:16     ` Nai Xia
2011-03-18  7:16     ` Nai Xia
2011-03-02 22:31 ` [PATCH] ksm: add vm_stat and meminfo entry to reflect pte Andrew Morton
2011-03-02 22:31   ` [PATCH] ksm: add vm_stat and meminfo entry to reflect pte mapping to ksm pages Andrew Morton
2011-03-02 22:31   ` Andrew Morton
2011-03-18  7:29   ` Nai Xia [this message]
2011-03-18  7:29     ` Nai Xia
2011-03-18  7:29     ` Nai Xia
2011-03-18 22:40     ` [PATCH] ksm: add vm_stat and meminfo entry to reflect pte mapping Hugh Dickins
2011-03-18 22:40       ` [PATCH] ksm: add vm_stat and meminfo entry to reflect pte mapping to ksm pages Hugh Dickins
2011-03-18 22:40       ` Hugh Dickins
2011-03-19 14:55       ` [PATCH] ksm: add vm_stat and meminfo entry to reflect pte mapping Nai Xia
2011-03-19 14:55         ` [PATCH] ksm: add vm_stat and meminfo entry to reflect pte mapping to ksm pages Nai Xia
2011-03-19 14:55         ` Nai Xia

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=201103181529.43659.nai.xia@gmail.com \
    --to=nai.xia@gmail.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=chrisw@sous-sol.org \
    --cc=hugh.dickins@tiscali.co.uk \
    --cc=ieidus@redhat.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=riel@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.