Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755291Ab0G1PO7 (ORCPT ); Wed, 28 Jul 2010 11:14:59 -0400 Received: from smtp106.prem.mail.ac4.yahoo.com ([76.13.13.45]:23514 "HELO smtp106.prem.mail.ac4.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1755242Ab0G1PO4 (ORCPT ); Wed, 28 Jul 2010 11:14:56 -0400 X-Yahoo-SMTP: _Dag8S.swBC1p4FJKLCXbs8NQzyse1SYSgnAbY0- X-YMail-OSG: 7VUJacQVM1nLae8e3Gn1jaM7axYdcM6nU0S1wbvg3Zls5r5 sKRFGXCyNO.WtQcE1ho101NYymIkRo5LCbC4dkbth8_Y7lX9kijOKnFd6DeO uD1ieKBg6AWIK127X7k19J2rCbpwBZzLK77KyoWaiynzWz500fFjCFJ2WBmc dtb18N9yc8pdQznmENSect1XiIqf42iRUNGLhYpXvMlSoQHgIRfmAdE2ngXh b X-Yahoo-Newman-Property: ymail-3 Date: Wed, 28 Jul 2010 10:14:51 -0500 (CDT) From: Christoph Lameter X-X-Sender: cl@router.home To: Minchan Kim cc: KAMEZAWA Hiroyuki , Milton Miller , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Russell King , Mel Gorman , Johannes Weiner , Kukjin Kim Subject: Re: [PATCH] Tight check of pfn_valid on sparsemem - v4 In-Reply-To: Message-ID: References: <1280159163-23386-1-git-send-email-minchan.kim@gmail.com> <20100727171351.98d5fb60.kamezawa.hiroyu@jp.fujitsu.com> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1178 Lines: 32 On Wed, 28 Jul 2010, Minchan Kim wrote: > static inline int memmap_valid(unsigned long pfn) > { > struct page *page = pfn_to_page(pfn); > struct page *__pg = virt_to_page(page); Does that work both for vmemmap and real mmapping? > return page_private(__pg) == MAGIC_MEMMAP && PageReserved(__pg); > } Problem is that pages may be allocated for the mmap from a variety of places. The pages in mmap_init_zone() and allocated during boot may have PageReserved set whereas the page allocated via vmemmap_alloc_block() have PageReserved cleared since they came from the page allocator. You need to have consistent use of PageReserved in page structs for the mmap in order to do this properly. Simplest scheme would be to clear PageReserved() in all page struct associated with valid pages and clear those for page structs that do not refer to valid pages. Then mmap_valid = !PageReserved(xxx(pfn_to_page(pfn)) -- 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/