Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756583AbbHZOyt (ORCPT ); Wed, 26 Aug 2015 10:54:49 -0400 Received: from m12-14.163.com ([220.181.12.14]:38371 "EHLO m12-14.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756377AbbHZOys (ORCPT ); Wed, 26 Aug 2015 10:54:48 -0400 Date: Wed, 26 Aug 2015 22:50:46 +0800 From: Yaowei Bai To: Michal Hocko Cc: akpm@linux-foundation.org, mgorman@suse.de, vbabka@suse.cz, js1304@gmail.com, hannes@cmpxchg.org, alexander.h.duyck@redhat.com, sasha.levin@oracle.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm/page_alloc: add a helper function to check page before alloc/free Message-ID: <20150826145046.GB4194@bbox> References: <1440509190-3622-1-git-send-email-bywxiaobai@163.com> <20150825140322.GC6285@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150825140322.GC6285@dhcp22.suse.cz> User-Agent: Mutt/1.5.21 (2010-09-15) X-CM-TRANSID: DsCowEA5ylBF0t1V3vKtAg--.33410S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7Zr4xGw4xWryftF18Aw1fWFg_yoW8Cw45pF 48AFyDAan5trWUGr4vqrnF9F1FyrnIqrWxZ3sxGw13J3sIqF1SvFyIkF4Y9r1I934xA34I qF4Ikry3ua1Yk3JanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j3cTPUUUUU= X-Originating-IP: [114.216.24.199] X-CM-SenderInfo: xe1z5x5dretxi6rwjhhfrp/1tbiuwpiT1O-vwFN4AAAsj Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2208 Lines: 65 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: I missed that check mistakenly, it should be there. > 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 investigated the commit you mentioned above. AFAICS, that commit assumes that __PG_HWPOISON check should be performed in the alloc path, while in the free path it doesn't need to. So there is a bit different in alloc/free paths. So Michal, do you think there is any obvious points to refactor these two functions still? Anyway, appreciate your reviewing. > > > - 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/