From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932715Ab0HYDC2 (ORCPT ); Tue, 24 Aug 2010 23:02:28 -0400 Received: from mga01.intel.com ([192.55.52.88]:20484 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932651Ab0HYDCZ (ORCPT ); Tue, 24 Aug 2010 23:02:25 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.56,266,1280732400"; d="scan'208";a="599920811" Date: Wed, 25 Aug 2010 11:02:02 +0800 From: Wu Fengguang To: Naoya Horiguchi Cc: Andi Kleen , Andrew Morton , Christoph Lameter , Mel Gorman , "Jun'ichi Nomura" , linux-mm , LKML Subject: Re: [PATCH 6/8] HWPOISON, hugetlb: soft offlining for hugepage Message-ID: <20100825030202.GB15129@localhost> References: <1282694127-14609-1-git-send-email-n-horiguchi@ah.jp.nec.com> <1282694127-14609-7-git-send-email-n-horiguchi@ah.jp.nec.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1282694127-14609-7-git-send-email-n-horiguchi@ah.jp.nec.com> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +static int is_hugepage_on_freelist(struct page *hpage) > +{ > + struct page *page; > + struct page *tmp; > + struct hstate *h = page_hstate(hpage); > + int nid = page_to_nid(hpage); > + > + spin_lock(&hugetlb_lock); > + list_for_each_entry_safe(page, tmp, &h->hugepage_freelists[nid], lru) { > + if (page == hpage) { > + spin_unlock(&hugetlb_lock); > + return 1; > + } > + } > + spin_unlock(&hugetlb_lock); > + return 0; > +} Ha! That looks better than the page_count test in my previous email. > +void isolate_hwpoisoned_huge_page(struct page *hpage) > +{ > + lock_page(hpage); > + if (is_hugepage_on_freelist(hpage)) > + __isolate_hwpoisoned_huge_page(hpage); > + unlock_page(hpage); > +} However it should still be racy if the test/isolate actions are not performed in the same hugetlb_lock. Thanks, Fengguang