Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1214553

Re: [PATCH v2] mm/page_alloc: add a helper function to check page before alloc/free

From Yaowei Bai <bywxiaobai@163.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2] mm/page_alloc: add a helper function to check page before alloc/free
Date 2015-08-27 15:10 +0200
Message-ID <q256h-5kI-13@gated-at.bofh.it> (permalink)
References <q1mCe-7Ts-17@gated-at.bofh.it> <q1n5g-fR-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Aug 25, 2015 at 04:03:22PM +0200, Michal Hocko wrote:
> On Tue 25-08-15 21:26:30, Yaowei Bai wrote:
> [...]
> >  static inline int check_new_page(struct page *page)
> >  {
> > -	const char *bad_reason = NULL;
> > -	unsigned long bad_flags = 0;
> > -
> > -	if (unlikely(page_mapcount(page)))
> > -		bad_reason = "nonzero mapcount";
> > -	if (unlikely(page->mapping != NULL))
> > -		bad_reason = "non-NULL mapping";
> > -	if (unlikely(atomic_read(&page->_count) != 0))
> > -		bad_reason = "nonzero _count";
> > -	if (unlikely(page->flags & __PG_HWPOISON)) {
> > -		bad_reason = "HWPoisoned (hardware-corrupted)";
> > -		bad_flags = __PG_HWPOISON;
> > -	}
> 
> You have removed this check AFAICS. Now looking at 39ad4f19671d ("mm:
> check __PG_HWPOISON separately from PAGE_FLAGS_CHECK_AT_*") I am not
> sure it is correct to check it in the free path as it was removed from
> the mask by this commit.

I just refactored these two function and it looks well, will resend it soon.

> 
> > -	if (unlikely(page->flags & PAGE_FLAGS_CHECK_AT_PREP)) {
> > -		bad_reason = "PAGE_FLAGS_CHECK_AT_PREP flag set";
> > -		bad_flags = PAGE_FLAGS_CHECK_AT_PREP;
> > -	}
> > -#ifdef CONFIG_MEMCG
> > -	if (unlikely(page->mem_cgroup))
> > -		bad_reason = "page still charged to cgroup";
> > -#endif
> > -	if (unlikely(bad_reason)) {
> > -		bad_page(page, bad_reason, bad_flags);
> > -		return 1;
> > -	}
> > -	return 0;
> > +	return check_one_page(page, PAGE_FLAGS_CHECK_AT_PREP);
> >  }
> >  
> >  static int prep_new_page(struct page *page, unsigned int order, gfp_t gfp_flags,
> > -- 
> > 1.9.1
> > 
> 
> -- 
> Michal Hocko
> SUSE Labs

--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v2] mm/page_alloc: add a helper function to check page before alloc/free Yaowei Bai <bywxiaobai@163.com> - 2015-08-25 15:40 +0200
  Re: [PATCH v2] mm/page_alloc: add a helper function to check page  before alloc/free Michal Hocko <mhocko@kernel.org> - 2015-08-25 16:10 +0200
    Re: [PATCH v2] mm/page_alloc: add a helper function to check page  before alloc/free Yaowei Bai <bywxiaobai@163.com> - 2015-08-26 17:00 +0200
    Re: [PATCH v2] mm/page_alloc: add a helper function to check page  before alloc/free Yaowei Bai <bywxiaobai@163.com> - 2015-08-27 15:10 +0200

csiph-web