Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3900310rwb; Tue, 20 Sep 2022 06:21:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4VGIcz66GIW7v6krtab1Mn1J/ukXN1bG9AxpmXRnwufVpCcLrTjJkkOzsuVnQ847S7NMVh X-Received: by 2002:a17:907:80b:b0:77a:86a1:db52 with SMTP id wv11-20020a170907080b00b0077a86a1db52mr17124297ejb.294.1663680088543; Tue, 20 Sep 2022 06:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663680088; cv=none; d=google.com; s=arc-20160816; b=XvxaTvtP5MfCmADfeueXOOUdMXpdrOJQn/VZpouSUh8PZdFQUln0QU18L3jIAeeklw Mnz/tFKjQQI38CQIq23ZEuR3qI8rtERyB8IkwFnrZsmd5QLyCgoSbZP8glGhiRv8/FHK E0ET3zV7KJXmH5lIJ946FKXf0wdZHSkvmAQsAAaqkWaxH4t9hdkhrTw75UpMXfFU0vNY 5bs9GKCIw/w/afjJsJc5apRkwX+Mef0RawE9S/8bv+2o/Cwq+s5hz5NPP5E+NeS740KB 6wbeRhndgsa0iez6c7uDPnyGbmFsSO0TDb1NfgNnRWUxqsPuNhgkoh0fDYb0ls1ooBvS gtfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:to:from; bh=lBuMZ5r6ubIc1cx3qfU2GarYu14AI3Ml0CoGOCxqKeQ=; b=l7RbrVAtiWfBPOE5mI3x4Cs/t85aOU9DS5zllHPpxIxn09rBplo3Juz4nUULRZqG1+ W2piqve2IO97VO8SEmMyp/eTZHDy+Ri4AKEcyht8QdEi/R63mQICwCn2Xs7gqYAy2dSx cIet1qWuq9LbzTQ9pwwiURzdLLQksByd56UtW670qxnQMIwRXCLO3fzI+4RZ+AwyfVs9 IIwZdI/jXr10Cr8u2yydnJsXeuFSq4rE6L8snfhueTt4xnkaxviQh4dKj3CcClMWByJY 1qSYDslyQLU5IV3OzdvbIKtDOxUpC4v0fIzOhvjdGfBztaXWcyw+mA2gYT9Q1J4+fSvJ LmCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr16-20020a170906d55000b0077951929341si1661629ejc.312.2022.09.20.06.21.03; Tue, 20 Sep 2022 06:21:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230236AbiITNMU (ORCPT + 99 others); Tue, 20 Sep 2022 09:12:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229655AbiITNMS (ORCPT ); Tue, 20 Sep 2022 09:12:18 -0400 Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9488A402E2 for ; Tue, 20 Sep 2022 06:12:16 -0700 (PDT) Received: from SHSend.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by SHSQR01.spreadtrum.com with ESMTPS id 28KDBRE4083462 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Tue, 20 Sep 2022 21:11:27 +0800 (CST) (envelope-from zhaoyang.huang@unisoc.com) Received: from bj03382pcu.spreadtrum.com (10.0.74.65) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 20 Sep 2022 21:11:28 +0800 From: "zhaoyang.huang" To: Andrew Morton , Catalin Marinas , Matthew Wilcox , Zhaoyang Huang , , , , Subject: [RFC PATCH] mm: track bad page via kmemleak Date: Tue, 20 Sep 2022 21:11:08 +0800 Message-ID: <1663679468-16757-1-git-send-email-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.0.74.65] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 28KDBRE4083462 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhaoyang Huang Bad pages will failed go back to allocator and leaved as orphan pages, track them down via kmemleak. Signed-off-by: Zhaoyang Huang --- mm/page_alloc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e5486d4..24f682e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1408,7 +1408,7 @@ static __always_inline bool free_pages_prepare(struct page *page, __memcg_kmem_uncharge_page(page, order); reset_page_owner(page, order); page_table_check_free(page, order); - return false; + goto err; } /* @@ -1442,7 +1442,7 @@ static __always_inline bool free_pages_prepare(struct page *page, if (check_free) bad += check_free_page(page); if (bad) - return false; + goto err; page_cpupid_reset_last(page); page->flags &= ~PAGE_FLAGS_CHECK_AT_PREP; @@ -1486,6 +1486,10 @@ static __always_inline bool free_pages_prepare(struct page *page, debug_pagealloc_unmap_pages(page, 1 << order); return true; +err: + kmemleak_alloc(page_address(page), PAGE_SIZE << order, 1, GFP_KERNEL); + return false; + } #ifdef CONFIG_DEBUG_VM -- 1.9.1