From patchwork Mon Jan 9 22:16:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaac Manjarres X-Patchwork-Id: 13094425 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48C93C5479D for ; Mon, 9 Jan 2023 22:16:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA64D8E0002; Mon, 9 Jan 2023 17:16:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B86578E0001; Mon, 9 Jan 2023 17:16:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A6C498E0002; Mon, 9 Jan 2023 17:16:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 9875F8E0001 for ; Mon, 9 Jan 2023 17:16:31 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6DDF01211E7 for ; Mon, 9 Jan 2023 22:16:31 +0000 (UTC) X-FDA: 80336670582.03.76521A7 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) by imf14.hostedemail.com (Postfix) with ESMTP id ABA66100014 for ; Mon, 9 Jan 2023 22:16:29 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=pWhUBCLp; spf=pass (imf14.hostedemail.com: domain of 3PJK8Yw4KCHcdnVVXhVieVmmZnbjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--isaacmanjarres.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=3PJK8Yw4KCHcdnVVXhVieVmmZnbjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--isaacmanjarres.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673302589; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=7dbGFSGl2P15wdLGEBTQ02HXgB4f3UQ0vhNqyU5IrAQ=; b=aRwpQYo2Y0q6KaB6rLhcTWkAiv0MmQwI8k1xOSNXI74PhTVrlX7WE57ZCCc/lsfSKG1/Wl PId+A1z/msohqCH7Y7CiEaWv2AcAWxw+yW3ZfYqYUxR/o5MDQzNocy0BvW9kAwcnvlchyW HP1YfPPbq8hJrb6guH9VIRTdgh/qEBI= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=pWhUBCLp; spf=pass (imf14.hostedemail.com: domain of 3PJK8Yw4KCHcdnVVXhVieVmmZnbjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--isaacmanjarres.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=3PJK8Yw4KCHcdnVVXhVieVmmZnbjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--isaacmanjarres.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673302589; a=rsa-sha256; cv=none; b=U1wOaQbsPMIeMt0hjUdtHFfMWtZUa2oLtLLBlVAiWM6UnXZL5b+ABxem5nqB41VIpTwy42 EWQrKc2Fl7ztI8tLejKxzAgb9z4We/mG06d9IdQBf7LD/u8arC/wSQQdquCmi2Axavw8TW xwJLIrTHUXQiRxktxZbsJWy83zaSxiQ= Received: by mail-pg1-f201.google.com with SMTP id bk2-20020a056a02028200b004a7e2a790d2so4242279pgb.18 for ; Mon, 09 Jan 2023 14:16:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=7dbGFSGl2P15wdLGEBTQ02HXgB4f3UQ0vhNqyU5IrAQ=; b=pWhUBCLpFd1CC7BFLkaI3kmyIoiv/iRvocf3G+aXcpoSRXCxWCuvK82+P3vUepBNQE bFiILQ5FH39WJP97Z9yOfLnr8BjULIJim4Kw3GHHg+N5+zbDvYldwBrqKztLh/hM9w0A qvzoQtXeTiq3/fS1GlmAMaFxEfTG5SxrmASQsS2nQu9/dM+T1ozA9lNWwr22vgpqzy3g C0QRvPGzYocQipXNwv+gJW2e+dYNCYfJSxka+4u8p6NerIbu/Y6BcbAxR24FE39FURIK sBBD+TYPVEmDUI50NQUXSBpGiJmNUxeP9CSi9N7dDupPRaDHeoT2aqHP9NF/Mywmh4gA GOWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=7dbGFSGl2P15wdLGEBTQ02HXgB4f3UQ0vhNqyU5IrAQ=; b=5RbHojD9kb+VdfWytq+yuldGGlUhcXwu7ld42oxpkZQNOtcGQGeWE0L1qKxiH2j6MG Qv/l+FTwIoWbA5EUQfUW+TK3wRmuwTy0GeiMGGN7nsnKDnv7k1K366C853NKQdKDnN48 oC63kQmyJz62lvUub11MS6S/xfFbuwgU1JoCGGGxTDu2owrfvv7iV4H2/3yaRqWSaE2X BGLx+zJE4vzq2pSVU4daNzjuQt3MYuq6wPAXWahufMte7kZKeWx9Swhz6T53kbQgNBwn IhrFQYG9j6rGk0qbRN7tji1dQC4k7NQNjUrY4qOWz/MICQD5LY8SmjAZhfVCv2jC296A aTBg== X-Gm-Message-State: AFqh2kpS64v4uDrrRD7v+N9C/U7h6/VrujCNfVu0RJtsAgNLkDMQ6HC6 1/9T7XFbuIQ7nod8vvoRGQGh3TjqZtn/fbIxEjQbhA== X-Google-Smtp-Source: AMrXdXsV5dTjdmva6/QYT+10ElqKQltDtJDhXtnNH/Y7Wne3MIBWFqUYajmbsxrbX/FVmUXI3UrD39ci8xfypfC8sv26nQ== X-Received: from isaacmanjarres.irv.corp.google.com ([2620:15c:2d:3:3990:5e50:b0f8:bcdd]) (user=isaacmanjarres job=sendgmr) by 2002:a17:90b:23c8:b0:226:e800:120e with SMTP id md8-20020a17090b23c800b00226e800120emr860160pjb.54.1673302588362; Mon, 09 Jan 2023 14:16:28 -0800 (PST) Date: Mon, 9 Jan 2023 14:16:21 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20230109221624.592315-1-isaacmanjarres@google.com> Subject: [PATCH v1 0/2] Fixes for kmemleak tracking with CMA regions From: "Isaac J. Manjarres" To: Andrew Morton Cc: Saravana Kannan , Suren Baghdasaryan , "Isaac J. Manjarres" , kernel-team@android.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: ABA66100014 X-Rspam-User: X-Stat-Signature: cpisjn3eb3d3skuj9w7qmyskxodco87a X-HE-Tag: 1673302589-984645 X-HE-Meta: U2FsdGVkX1/mQkpXqCIGqQi9aYhWtBqPOAvGROnpvK6KCLXXlpE6Z8VFp0Qgf2+4X4gmhlTJqaArd6kqJ6EcIJjSpAvtVFySlCZ//obNyNj6XmLhzF3yAtxcfvF1vNei/BHwKsNkfMjItdzdTM51spoYZGeHi5DYV0C5OoYIOcDWXOlWsIFwuZ5pAisSuNXYEtCAsQtVLA9i7kmFl93s6QWZNQAAuV2wq3spN4WeCJpt9QybkNKkalVGy2bKmp6TTrNv3HKH0thVBAe37yMeCi+HCsfcd4GVFnZTkKFibevk8pEetw7j7qnkp6sqMLfOjDJFFIxKdnhsSwSpysHyk93Y6Hi/rGlvYw5m/fLj9gMiRr7X6SdgE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.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When trying to boot a device with an ARM64 kernel with the following config options enabled: CONFIG_DEBUG_PAGEALLOC=y CONFIG_DEBUG_PAGEALLOC_ENABLE_DEFAULT=y CONFIG_DEBUG_KMEMLEAK=y a page-fault is encountered when kmemleak starts to scan the list of gray or allocated objects that it maintains. Upon closer inspection, it was observed that these page-faults always occurred when kmemleak attempted to scan a CMA region. At the moment, kmemleak is made aware of CMA regions that are specified through the devicetree to be created at specific memory addresses or dynamically allocated within a range of addresses. However, if the CMA region is constrained to a certain range of addresses through the command line, the region is reserved through the memblock_reserve() function, but kmemleak_alloc_phys() is not invoked. Furthermore, kmemleak is never informed about CMA regions being freed to buddy at boot, which is problematic when CONFIG_DEBUG_PAGEALLOC is enabled, as all CMA regions are unmapped from the kernel's address space, and subsequently causes a page-fault when kmemleak attempts to scan any of them. This series makes it so that kmemleak is aware of every CMA region before they are freed to the buddy allocator, so that at that time, kmemleak can be informed that each region is about to be freed, and thus it should not attempt to scan those regions. Isaac J. Manjarres (2): mm/cma.c: Make kmemleak aware of all CMA regions mm/cma.c: Delete kmemleak objects when freeing CMA areas to buddy at boot mm/cma.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)