From patchwork Mon Nov 12 11:07:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 12810 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id BF82D23EFB for ; Mon, 12 Nov 2012 11:08:02 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 1D0D9A198D2 for ; Mon, 12 Nov 2012 11:08:02 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so8416295iej.11 for ; Mon, 12 Nov 2012 03:08:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:x-auditid :from:to:date:message-id:x-mailer:x-brightmail-tracker:cc:subject :x-beenthere:x-mailman-version:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-gm-message-state; bh=8IC5qRb31lEEY903PMMTqLChaw4/BNTeA9ScW8W2+6g=; b=Ss2VCgT2RXR/VB4SuAkblALAHa5/alP3flyaDg8k2J3o2JwpMeBu6texEd8b+qc9wG jDdGN7z8YF3x5kHiFTshbi9oL9MLFR60etGrDKz78mx6olur0c7upUc23I/WBRFED/7q yM9THOByJjtif6u/S9MMOcC4CrSNnHvi3hzoqYZXnJE/JI7+rnWInhf1UEKR3bz+GhgL +yBmRjscxyjUFiQwaW42uwe9VPfxYgyQqDWS3q5yglSAkDyJ5gzyQN6FFOZoXK+D4LsR oQs5i+5CHzEzLSBaJ1lwmJPdGu2I8YzRz5sfbNHAEGl8+E38peAleGAHXibtMh1QLLI6 mOPQ== Received: by 10.50.40.166 with SMTP id y6mr7502317igk.57.1352718481543; Mon, 12 Nov 2012 03:08:01 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp343172igt; Mon, 12 Nov 2012 03:08:00 -0800 (PST) Received: by 10.204.11.133 with SMTP id t5mr7129959bkt.14.1352718480209; Mon, 12 Nov 2012 03:08:00 -0800 (PST) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id il13si11291165bkc.72.2012.11.12.03.07.57; Mon, 12 Nov 2012 03:08:00 -0800 (PST) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TXrrw-0004ab-57; Mon, 12 Nov 2012 11:07:56 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TXrru-0004aV-92 for linaro-mm-sig@lists.linaro.org; Mon, 12 Nov 2012 11:07:54 +0000 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MDD004SQG92MYZ0@mailout2.samsung.com> for linaro-mm-sig@lists.linaro.org; Mon, 12 Nov 2012 20:07:50 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-ac-50a0d88634aa Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 56.FB.12699.688D0A05; Mon, 12 Nov 2012 20:07:50 +0900 (KST) Received: from localhost.localdomain ([106.116.147.30]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MDD005O9G8TX340@mmp1.samsung.com> for linaro-mm-sig@lists.linaro.org; Mon, 12 Nov 2012 20:07:50 +0900 (KST) From: Marek Szyprowski To: linux-mm@kvack.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org Date: Mon, 12 Nov 2012 12:07:26 +0100 Message-id: <1352718446-32313-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFJMWRmVeSWpSXmKPExsVy+t9jAd22GwsCDGZuMLX4cuUhkwOjx+1/ j5kDGKO4bFJSczLLUov07RK4MtZPnsVSsJ69YvnuzAbGFrYuRk4OCQETif8zrjNB2GISF+6t B4pzcQgJLGKUWL30KSOEs4pJovfLK1aQKjYBQ4mut11g3SICYRJ/GrexghQxC6xgkrh4dx9Y kbCAncSjAz2MIDaLgKrEzu8vwFbwCnhIbL/yn6WLkQNonYLEnEk2Exi5FzAyrGIUTS1ILihO Ss810itOzC0uzUvXS87P3cQI9uEz6R2MqxosDjEKcDAq8fAqRCwIEGJNLCuuzD3EKMHBrCTC 67sTKMSbklhZlVqUH19UmpNafIhRmoNFSZy32SMlQEggPbEkNTs1tSC1CCbLxMEp1cC4xm/R Ta31UzM+O16bpGuqUpa/QGg9r0F1p5Qbjz7rBWm2iU9lJ5kK7frzZru0YtJxjlSe5WcvaEc9 981u6DiywbFCkfPS/lc+OUm7So9yu5UlrtvZfm2Xxv1HeoJqmd+z3lRMjvLMkt98taL/urXz SdPKq6eYVNm3tR7mSJr81OpnQIP0IkYlluKMREMt5qLiRAAq7rl53QEAAA== Cc: Bartlomiej Zolnierkiewicz , Mel Gorman , Michal Nazarewicz , Minchan Kim , Kyungmin Park , Andrew Morton Subject: [Linaro-mm-sig] [PATCH] mm: cma: WARN if freed memory is still in use X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQlrkXFq5Q2GMzKBSKF1zBCxWdohwqClM3G1QPuak1tyz7dZ9GHrp4p+nkF3GaL7J2CpZrYV Memory return to free_contig_range() must have no other references. Let kernel to complain loudly if page reference count is not equal to 1. Signed-off-by: Marek Szyprowski Reviewed-by: Kyungmin Park CC: Michal Nazarewicz --- mm/page_alloc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 022e4ed..290c2eb 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5888,8 +5888,13 @@ done: void free_contig_range(unsigned long pfn, unsigned nr_pages) { - for (; nr_pages--; ++pfn) - __free_page(pfn_to_page(pfn)); + struct page *page = pfn_to_page(pfn); + int refcount = nr_pages; + for (; nr_pages--; page++) { + refcount -= page_count(page) == 1; + __free_page(page); + } + WARN(refcount != 0, "some pages are still in use!\n"); } #endif