From patchwork Tue Nov 13 06:47:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 12824 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 7A5AF23E0B for ; Tue, 13 Nov 2012 06:48:51 +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 12F25A194B2 for ; Tue, 13 Nov 2012 06:48:50 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so9869192iej.11 for ; Mon, 12 Nov 2012 22:48:50 -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:in-reply-to:references :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=PX+/oy80/w9/I2mOQJ5M263mx1YP+sFf95iVOa+JJKU=; b=JKH2dMaRp2CylV5Ux1IU4Sh7o/uRzkz2Lsqf16LFpe+YeMTxoXprGMzOHam+tW60+T 9JlUPqcBxz/+rEkg3jicyfEE8ZIgu30wlo2K7pZOJ0HaBG06Euu08Wnmro/serVg+yCl Prs1+hMMo3FFLRtAZvDcnc1ByEcp1evvDcJXh5VFL9KKOz33Geiwfc/A5zFtOBBNUPwB qZ+aKoBJVfhkdjt3+wZxwvJwfyNfPCwWagnMHjFqePwCRhiWHs2ksPWGKH69jXJudOfN LhFw6PLFHn4Ss8P3JjI4ky0vPJeX9X0yi114wIPBlIL2ZrP8JNRTKB0XuLlb+PkkpaUV Hl6g== Received: by 10.50.91.195 with SMTP id cg3mr10143173igb.57.1352789330504; Mon, 12 Nov 2012 22:48:50 -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 n20csp472337igt; Mon, 12 Nov 2012 22:48:49 -0800 (PST) Received: by 10.14.179.1 with SMTP id g1mr71802286eem.14.1352789329313; Mon, 12 Nov 2012 22:48:49 -0800 (PST) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id l45si16577456eep.39.2012.11.12.22.48.46; Mon, 12 Nov 2012 22:48:49 -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 1TYAIe-0006pm-4H; Tue, 13 Nov 2012 06:48:44 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TYAIc-0006oy-2n for linaro-mm-sig@lists.linaro.org; Tue, 13 Nov 2012 06:48:42 +0000 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MDE005OZYWO2DR0@mailout1.samsung.com> for linaro-mm-sig@lists.linaro.org; Tue, 13 Nov 2012 15:48:38 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-53-50a1ed46b8a8 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id C0.9C.12699.64DE1A05; Tue, 13 Nov 2012 15:48:38 +0900 (KST) Received: from localhost.localdomain ([106.116.147.30]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MDE00EQHYWPNX40@mmp2.samsung.com> for linaro-mm-sig@lists.linaro.org; Tue, 13 Nov 2012 15:48:38 +0900 (KST) From: Marek Szyprowski To: linux-mm@kvack.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org Date: Tue, 13 Nov 2012 07:47:51 +0100 Message-id: <1352789271-18461-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: References: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEJMWRmVeSWpSXmKPExsVy+t9jQV23twsDDFrOiFp8ufKQyYHR4/a/ x8wBjFFcNimpOZllqUX6dglcGc8+L2QpWMZesfrabeYGxl+sXYwcHBICJhLzezi6GDmBTDGJ C/fWs3UxcnEICUxnlOjZeIwJwlnFJDH73zE2kCo2AUOJrrddYLaIQJjEn8ZtrCBFzAIrmCQu 3t3HCpIQFnCUmHf0NROIzSKgKvH66k5GEJtXwEPi8+GzbBCbFSTmTLIBCXMKaEncmfSEHcQW EtCUWNxxmW0CI+8CRoZVjKKpBckFxUnpuUZ6xYm5xaV56XrJ+bmbGME+fya9g3FVg8UhRgEO RiUeXkXLhQFCrIllxZW5hxglOJiVRHjN64FCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeZs9UgKE BNITS1KzU1MLUotgskwcnFINjCmWa9qVQpfELXpS+sf4nqK2YmH7co4PbOd/8i6VYTc5kqtn HL6u4pppr84m1QVSS8PEOrRm3T2xI/FpcXTBZ2WzG27WnmtWtvg95v94/GGLvYnat1SFm9/N 2r+8eX7mkpi7Tv+iJku/d1NyRS0ytPpF2WaqZTcHVEzQ1TUN+S9lOUHuwMswJZbijERDLeai 4kQAE63CrfUBAAA= Cc: Bartlomiej Zolnierkiewicz , Mel Gorman , Michal Nazarewicz , Minchan Kim , Kyungmin Park , Andrew Morton Subject: [Linaro-mm-sig] [PATCH v2] 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: ALoCoQkigJSTAvYGqiGiOdHtSZgCpnBcnozn/WkxF+gGxh4nrhgUDQvmawFY8fZG8wazpq1akjDD Memory returned 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 count = 0; + for (; nr_pages--; page++) { + count += page_count(page) != 1; + __free_page(page); + } + WARN(count != 0, "%d pages are still in use!\n", count); } #endif