linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: do not inc NR_PAGETABLE if ptlock_init failed
@ 2015-10-19 12:14 Vladimir Davydov
  2015-10-19 12:21 ` Kirill A. Shutemov
  2015-10-19 13:20 ` Michal Hocko
  0 siblings, 2 replies; 3+ messages in thread
From: Vladimir Davydov @ 2015-10-19 12:14 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Kirill A. Shutemov, linux-mm, linux-kernel

If ALLOC_SPLIT_PTLOCKS is defined, ptlock_init may fail, in which case
we shouldn't increment NR_PAGETABLE.

Since small allocations, such as ptlock, normally do not fail (currently
they can fail if kmemcg is used though), this patch does not really fix
anything and should be considered as a code cleanup.

Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>
---
 include/linux/mm.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 6adf4167d664..30ef3b535444 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1553,8 +1553,10 @@ static inline void pgtable_init(void)
 
 static inline bool pgtable_page_ctor(struct page *page)
 {
+	if (!ptlock_init(page))
+		return false;
 	inc_zone_page_state(page, NR_PAGETABLE);
-	return ptlock_init(page);
+	return true;
 }
 
 static inline void pgtable_page_dtor(struct page *page)
-- 
2.1.4

--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: do not inc NR_PAGETABLE if ptlock_init failed
  2015-10-19 12:14 [PATCH] mm: do not inc NR_PAGETABLE if ptlock_init failed Vladimir Davydov
@ 2015-10-19 12:21 ` Kirill A. Shutemov
  2015-10-19 13:20 ` Michal Hocko
  1 sibling, 0 replies; 3+ messages in thread
From: Kirill A. Shutemov @ 2015-10-19 12:21 UTC (permalink / raw)
  To: Vladimir Davydov
  Cc: Andrew Morton, Kirill A. Shutemov, linux-mm, linux-kernel

On Mon, Oct 19, 2015 at 03:14:41PM +0300, Vladimir Davydov wrote:
> If ALLOC_SPLIT_PTLOCKS is defined, ptlock_init may fail, in which case
> we shouldn't increment NR_PAGETABLE.
> 
> Since small allocations, such as ptlock, normally do not fail (currently
> they can fail if kmemcg is used though), this patch does not really fix
> anything and should be considered as a code cleanup.
> 
> Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>

Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

-- 
 Kirill A. Shutemov

--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: do not inc NR_PAGETABLE if ptlock_init failed
  2015-10-19 12:14 [PATCH] mm: do not inc NR_PAGETABLE if ptlock_init failed Vladimir Davydov
  2015-10-19 12:21 ` Kirill A. Shutemov
@ 2015-10-19 13:20 ` Michal Hocko
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Hocko @ 2015-10-19 13:20 UTC (permalink / raw)
  To: Vladimir Davydov
  Cc: Andrew Morton, Kirill A. Shutemov, linux-mm, linux-kernel

On Mon 19-10-15 15:14:41, Vladimir Davydov wrote:
> If ALLOC_SPLIT_PTLOCKS is defined, ptlock_init may fail, in which case
> we shouldn't increment NR_PAGETABLE.
> 
> Since small allocations, such as ptlock, normally do not fail (currently
> they can fail if kmemcg is used though), this patch does not really fix
> anything and should be considered as a code cleanup.
> 
> Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com>

Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  include/linux/mm.h | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 6adf4167d664..30ef3b535444 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -1553,8 +1553,10 @@ static inline void pgtable_init(void)
>  
>  static inline bool pgtable_page_ctor(struct page *page)
>  {
> +	if (!ptlock_init(page))
> +		return false;
>  	inc_zone_page_state(page, NR_PAGETABLE);
> -	return ptlock_init(page);
> +	return true;
>  }
>  
>  static inline void pgtable_page_dtor(struct page *page)
> -- 
> 2.1.4
> 
> --
> 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/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

-- 
Michal Hocko
SUSE Labs

--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-19 13:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-19 12:14 [PATCH] mm: do not inc NR_PAGETABLE if ptlock_init failed Vladimir Davydov
2015-10-19 12:21 ` Kirill A. Shutemov
2015-10-19 13:20 ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox