From patchwork Mon Jan 9 22:16:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaac Manjarres X-Patchwork-Id: 13094426 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 F1C6DC63797 for ; Mon, 9 Jan 2023 22:16:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7870F8E0001; Mon, 9 Jan 2023 17:16:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7379D900002; Mon, 9 Jan 2023 17:16:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 600308E0005; Mon, 9 Jan 2023 17:16:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 517FD8E0001 for ; Mon, 9 Jan 2023 17:16:35 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 30C971A132E for ; Mon, 9 Jan 2023 22:16:35 +0000 (UTC) X-FDA: 80336670750.06.837742F Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf14.hostedemail.com (Postfix) with ESMTP id 9577A100003 for ; Mon, 9 Jan 2023 22:16:33 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=UEui1WQc; spf=pass (imf14.hostedemail.com: domain of 3QJK8Yw4KCHshrZZblZmiZqqdrfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--isaacmanjarres.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3QJK8Yw4KCHshrZZblZmiZqqdrfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--isaacmanjarres.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673302593; a=rsa-sha256; cv=none; b=2c1KWbIcN1vxaUhtyzRZmyu401wzJHuw3pPcfVb1zShREWFp8gpooRq+RaQJJTNrnVFpao H9q51xdBHUJxjfv0hYJLXmPiBRDyTdfTx8hh5Lpp9tIM5+Z3wpFaQYxpGIagNQiMUDw+ia fTm91iGWRxzSQV2cUlZmOei40FxfJ9w= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=UEui1WQc; spf=pass (imf14.hostedemail.com: domain of 3QJK8Yw4KCHshrZZblZmiZqqdrfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--isaacmanjarres.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3QJK8Yw4KCHshrZZblZmiZqqdrfnnfkd.bnlkhmtw-lljuZbj.nqf@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=1673302593; 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:in-reply-to:references:references:dkim-signature; bh=UAY7ziXR1pDWT8yIaOxG4IQsxtcRX6+lmyo9rcOBFQI=; b=RyNhhOY0jMxNMeKCKKWuC+ity8X36FED+KlJGCAyHxVw2OvDgcYfO8N7Hy5e4woq9Zh3vr YEahB85YV7SptQTZIOSrrtHuzIdN/CpcJachlTpPQLsg4xC4GmuQ2lhPjU2xmK40bNvhvL B7pmKYJl9fl/LjHJItwC8q653jQ7RHs= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-4c16ff0159eso107835927b3.17 for ; Mon, 09 Jan 2023 14:16:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=UAY7ziXR1pDWT8yIaOxG4IQsxtcRX6+lmyo9rcOBFQI=; b=UEui1WQccphNYJS2B2rBldr80G72ZMsvoPivgTxDn/fxNbkP3rl2cZegNrl31wiaJT YWRA3jP5BrD3xglYqWwZOfFl/74UQK2ntqKI8UxjMlnvXsrObTXRacBD1jvkt9U0pv0N Rz6yX12fdD0UTvmPzwtyRL69HEjoWr6xF72eVcgjMKIwVTabZpr1OKMy01LQRmUelK34 uoJL9SNCI4SOmZf1qKQGaD9pPn6QfObQYClE7Mk4i0jKselSNB1MRU7B3RGPs/M3WYXA PmQuYNpgcql7zAPOU+xV8XEM/v8in/FSMDrsPu9J1WTG35YD3VEUUbyMXCfFe8PA+/hf OYug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UAY7ziXR1pDWT8yIaOxG4IQsxtcRX6+lmyo9rcOBFQI=; b=fKQJY2G6b/hjFvk0BTzw67MjX6yCj54ANWdhm3PYymcMD+SAY0MqkZegOfQdOcNKVY 1NdJEAYKtIufVz4qddm60+hm/Hbj1pxjedc4qH4k6MvMd7YaCR51EqUuxV4Ze8I+6281 Cl0gNgET0N0VVPFOEOu087KifZPr83j2O8Jq9UkDe0nD0BnHpIKWbV38yXbO9dIxk1Js YYI5P2I3bh4cVjoXZgjJy4l+GwcCG3gUXY3bydeK87lnbWDz5BdHLY1xrKv7LSqasLqk 7Hv9ypzpyt8Jx5ZtfGy2WVBRLN28GPeWLqXZTIlf5EpzpzsoJ06maeh2KtsSH53ExtGu wTjg== X-Gm-Message-State: AFqh2kp5XGBQlgssSRGSRWY0AAmXfdqwL1zZfPZM2jPx7xHt2FqLyTY0 lEHbu9SPsDxE0fsWe0ZKFgRkOEJ8tYJO7+JuC/wmFg== X-Google-Smtp-Source: AMrXdXsf7/34OOYlD8ImdQqEPY+KiIDRkgSsEo2WjPbDVqBrR8MswUATMamEBK1Wv6pIN7qPxVRK/kO82VgT8MFNA9fdcA== X-Received: from isaacmanjarres.irv.corp.google.com ([2620:15c:2d:3:3990:5e50:b0f8:bcdd]) (user=isaacmanjarres job=sendgmr) by 2002:a0d:d944:0:b0:46a:a08b:b5c9 with SMTP id b65-20020a0dd944000000b0046aa08bb5c9mr712139ywe.431.1673302592743; Mon, 09 Jan 2023 14:16:32 -0800 (PST) Date: Mon, 9 Jan 2023 14:16:22 -0800 In-Reply-To: <20230109221624.592315-1-isaacmanjarres@google.com> Mime-Version: 1.0 References: <20230109221624.592315-1-isaacmanjarres@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20230109221624.592315-2-isaacmanjarres@google.com> Subject: [PATCH v1 1/2] mm/cma.c: Make kmemleak aware of all 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, stable@vger.kernel.org X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 9577A100003 X-Stat-Signature: rx4uchw1uddxz1krcj5of4tjr8p6m8ez X-HE-Tag: 1673302593-67717 X-HE-Meta: U2FsdGVkX18PlnBAxFgMPCNcsn2Y14exyzlEzf3Y+EvtqMDrwx0WVfgHqGH7CBv8wOOdkjuaosIY3PD6WqStt9xYdwzxsXPO5Kx1Cn8exfvgTQc/T22QQFwS3cex2GmTKsbI+W+MdRCS+C+sn5L85m/a2u8UlpC1puWM0S3hxz/muviSXtr9Ls6Og5pjL0Ee7hj8Ajr4PqQI6JdM+V0zqQsB6PCN5ELunscHlvxAtqT3xK/tHTSaIkNRfu8b0L+9d5UQUQZ1IkpO6xVPV+sUXA1QgES/d02BCo5ccA8sZIPX/x1Zh4E0wqklQYhmLHP9/Uc1PkIMj3Os9FXQpFWDxHdm4cOHNXcj+VE7hYxG8h9aVKgUi5f0glRhtkmJ2g+AO3oR7C5kXWFnDG5X170KNgC3nDAFSk0ZhVeTLazuS6F0/bQGaI229gMAu5xOWxDpX2+rUs32UgID1gCtTKmIF3Rpcocr67vv8uFPXpQT2RXNAvnz3n08CGosdfPGHhSpDaNwjbQjFNP3znBXWONhFllaOQszyNbQ9b6kf7PV6G4zlRJ0e9E8m6zjKnMsNszc5Tw7XxvDIDyJbRdqwrgu5MX/zZ0r03t3ID9MrN8CFCQl9+iPwKThCjfIc+Rz1+o3xx0INIzudSi3virfqQjXogQNt6L4L2FBMsLqWolpWVJ2FP2C2owhgyyq+A0Yepq/akt6NU3cuwwcSRBJnKq0j8qnE04cYJtJNcXCF8FxOhpEwQNhek/eyZiTkGXMcmyI2u5p0/RWpLmRCZYJGEsu2BzAlWTFv1YgpWIBKOSgAxTH6xNNBox9l+JV9ZQaeXdg/wnBa1Dk2Wmd6kFf4hJnt05OKZIoIzwmEiR9qT9ewfXyenAJqnpHt0OJsahuVcnG76YRZomXh6q/5xzshmFtW2KAhJrMNQFuFc3xMprJPX2FHn937et40tPGabgr74gcaBdfovwdrYa+6paxDRj VJNGAMjV hzi8fjxPoVIEusVdNgJa7ayZeu/fRcmUlX46fUA2w6hQrXp1yaEYMheUQTKhFRQ69Dt+Q2iKcdXyLniPMeMdoscM+TlqVOYzErg+IPGU+GpbG3WpvTff6uQ0LyngsuwEZYX/Auu9skPcqFAYBXz7jyw5MNtay0nGCA23QA5zGFk0iKecQHQECmsiuLQMTQYssVDWgSMc0YHfA9e0/+LcF5SkRs69x3b6AGth9si+AkX8/3oIxDLWJWFW8CPA4pkJlNvb17MZQ4+9tSlEXpJ6DI3LmcAhWAecyWKsfIYwdMzE8DVdrV0Gl1OAJa3lxz3TKkCwTrjD9yzobaBeI5OqCpSYnqW19F4AKLfHIRONsw7jDrzRklkYmSAIkIIVj+ACx1os+fjYltWFUf+SZhdTjXmFLVRH2jY5i8iNzL4/8K59OvQ8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Currently, kmemleak tracks CMA regions that are specified through the devicetree. However, if the global CMA region is specified through the commandline, kmemleak will be unaware of the CMA region because kmemleak_alloc_phys() is not invoked after memblock_reserve(). Add the missing call to kmemleak_alloc_phys() so that all CMA regions are tracked by kmemleak before they are freed to the page allocator in cma_activate_area(). Cc: stable@vger.kernel.org Signed-off-by: Isaac J. Manjarres --- mm/cma.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/cma.c b/mm/cma.c index 4a978e09547a..674b7fdd563e 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -318,6 +318,8 @@ int __init cma_declare_contiguous_nid(phys_addr_t base, ret = -EBUSY; goto err; } + + kmemleak_alloc_phys(base, size, 0); } else { phys_addr_t addr = 0; From patchwork Mon Jan 9 22:16:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaac Manjarres X-Patchwork-Id: 13094427 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 AB69CC54EBD for ; Mon, 9 Jan 2023 22:16:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C835900003; Mon, 9 Jan 2023 17:16:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 47879900002; Mon, 9 Jan 2023 17:16:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34033900003; Mon, 9 Jan 2023 17:16:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 27471900002 for ; Mon, 9 Jan 2023 17:16:39 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 014641612DB for ; Mon, 9 Jan 2023 22:16:38 +0000 (UTC) X-FDA: 80336670918.11.1E3C049 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf02.hostedemail.com (Postfix) with ESMTP id 62D238000A for ; Mon, 9 Jan 2023 22:16:37 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=C0Hc9uF3; spf=pass (imf02.hostedemail.com: domain of 3RJK8Yw4KCH8lvddfpdqmduuhvjrrjoh.frpolqx0-ppnydfn.ruj@flex--isaacmanjarres.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3RJK8Yw4KCH8lvddfpdqmduuhvjrrjoh.frpolqx0-ppnydfn.ruj@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=1673302597; 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:in-reply-to:references:references:dkim-signature; bh=y9TFZ1eWP+JIndu1JdgCdrPRh+jAT3LtUVgzdE/rI84=; b=nqN9FopGKA1Zc+WkQOiwF9ob+ApJwAoQIYlvAqGLqSCegFJQTpuQSojK9PiDDYgNJXJhho /EeWV4c/HBOUBN+gx/c4oKjU4cDES9VBWtccBr3mmgGQ++7LfL/n1LSqwQE7y3uS673HaB mF2PZl+qv0diGwQqezEnU95egKwh5N0= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=C0Hc9uF3; spf=pass (imf02.hostedemail.com: domain of 3RJK8Yw4KCH8lvddfpdqmduuhvjrrjoh.frpolqx0-ppnydfn.ruj@flex--isaacmanjarres.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3RJK8Yw4KCH8lvddfpdqmduuhvjrrjoh.frpolqx0-ppnydfn.ruj@flex--isaacmanjarres.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673302597; a=rsa-sha256; cv=none; b=dzUp6KIjfNkKwHzKC3s+IfgyDRSGl6AAHoLsdrS5ye/jsnAgRHs00XqnsPbQjIKEe2jj4x hBKDSzRiP7/vAlxFidHVshHlrOIhYxQMV9bux8RISBtK5/hB23b5KDBdBpNRK+xg2momrm n5SsxYne/C/eWbB4gsJGd3EomSj2LkQ= Received: by mail-yb1-f201.google.com with SMTP id e12-20020a25500c000000b007b48c520262so10552748ybb.14 for ; Mon, 09 Jan 2023 14:16:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=y9TFZ1eWP+JIndu1JdgCdrPRh+jAT3LtUVgzdE/rI84=; b=C0Hc9uF3im6Ys2/s/4e6nNvgxvlythCwW8m17GdXHrOqWQ9yn0iW0LTZyj+MdItAEY iybja8FN1XyhoSwQX36EF+9wSfenpbb6LvJn2ASIr9ARjPf3bBYDEf0TmC1ADROKbIzA uqBW5UJwXEglstUm+YQchdmDfMIzIajQqCXdq5tXej2n/om0MByQQj7QiCcAlkoHzW+f 0EvQf8SiwDxeGivZRKBfCGtD95VHgBTkc0pBRfvgB/JhWJIan9MB+IxMjhlK+NPhAWfg dNKLyThxKdiUaJhH8Ndfdtdxjx9wWLvlbjqkUFmWXQ0tbaB5ICv8vHAarsuXw/gDkqnj gHfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=y9TFZ1eWP+JIndu1JdgCdrPRh+jAT3LtUVgzdE/rI84=; b=0wtmUL8Ep+tMeiwTEZisfKbrKz5fKnUgDuS02HDOWAWoe1MLxT1NO+Dj2aq0RPCEPq yAAB5PPG6fU+JaSzKbXVYfsdgiHWnCAlg7Z3gnylaYn7evdMFAiqwOIc8l+35ZYhrGF1 Mgnr3oyHyZp9wvxMoEqiuhNNrjDI5J1k1SOGbJ/GvqnDH6s3jNrEP3By39MMR+KPV1Wz kNAzdF52bhRny2ZlamRwLLwXGBIv4a5YTmxskg9iRhO9xprXC22iFxCrxA7r3D0wLOzt A3ncn/FuJruQXygoTgtnTDhtm/kLjGIrHWjhszKHQg3V4GchRJwG0YnNooa+d6LGi+W7 d9yQ== X-Gm-Message-State: AFqh2kpbYbGsSJIWbpC3YpGsUiW9SuEUHteCmqVlpLODBojQrr+7NYEV k80AZbkjn7WH+vPWTdZSiPqkLaLgqQ9MStzOt5dlQw== X-Google-Smtp-Source: AMrXdXvHobRDwuXj4MA5OcW3NVM1spLgSqNMAAiW4GhwomXZXFwO2kaU1GbMWchPaX3UjiQoZHyyjBmkbD8YjhmyaldVbQ== X-Received: from isaacmanjarres.irv.corp.google.com ([2620:15c:2d:3:3990:5e50:b0f8:bcdd]) (user=isaacmanjarres job=sendgmr) by 2002:a05:690c:b08:b0:469:28df:b2c2 with SMTP id cj8-20020a05690c0b0800b0046928dfb2c2mr1656471ywb.122.1673302596557; Mon, 09 Jan 2023 14:16:36 -0800 (PST) Date: Mon, 9 Jan 2023 14:16:23 -0800 In-Reply-To: <20230109221624.592315-1-isaacmanjarres@google.com> Mime-Version: 1.0 References: <20230109221624.592315-1-isaacmanjarres@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20230109221624.592315-3-isaacmanjarres@google.com> Subject: [PATCH v1 2/2] mm/cma.c: Delete kmemleak objects when freeing CMA areas to buddy at boot 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, stable@vger.kernel.org X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 62D238000A X-Stat-Signature: fjiefxpbs98pmfttbmmr7tmwx887jt3x X-HE-Tag: 1673302597-100266 X-HE-Meta: U2FsdGVkX1+nCZ78I/nje6iKDBWYEIph6PbjUvghS3E4Irwa+hxmVFZpi9AMdNVjpP85RilwE/ofjDpVgPipswMSsAIlKqTZ4zNAhJ1ShiX/K2BmpOTnhHKKF9ip662ZqsWZUTA0IqhfRyK/mkVg3xMhUhfZFp3Je5AgV3UIcMslY5Ph/QporXvW42ZHTSuuUlORJtaj9Dj4kKY3hLxsOs3JYxZGoGiSTcOukW9HZ0UYgnBuGk9ouRvhsnGXkGuB90XhQ3vtviJrfkWSUobUzzV+aDIDKxm2MhjO/NriwzptlR+ikmmRrBEROhGkRqFBad7WA3HBVQmcWA4IIzZgzuVWDn/vkXi8LyNQdHbe0gzjZFEO0J93seoU8p8K0Ggx0i1Qn1vdTi2Jxkv6CkCjOo5c62R8r1wlNcZRGyzWb2UAhBJNRdUUZ+FC7h7jPAVn/8/4Ot46t/xlYfSfgifmOtGBF868JLSuu8k0yNg9QPAVXaMpTfiuYl/qJ3a0bKaLf0e24oUwYi2bINnWQWeu6Tbh8s55LgoTm4h57sDOYlVHcBbuXmizKYHg0E2x4QZ91IHUgXqt8lzZrhC5U7Grl8mXEqSADEoS280TzVUPT7Y/bpehbczBlPfAIogyxKyZKoXmtSVNGFhMlBNRD5ceNOC3LKnqn5AmCqEO1BXs3zZqHbNneu7PFtxsxC+CKCeDIR8wBTtp3y1eHXvS0lfFMBn/99jqPKj6IArF5xR7P4KDmD56FKUvupmWmd6gG8vTBRMBPEUW98F6W6fDCcwD8Dqh/MGY9cm72ujKxOSbLFG+gUASeBFLGBCocBo58KonTsOHeMupqwkGg/88tGZoWhYyxyGz1WSM1igUs9LCmsOo8WzE/DRqSXVZ3c3ADYxVr78YXSwanOejqgzcyTLt7kcrS1EZzVWuVmn3agVg2MGkxL25fQXpiMYM6yZNdtOn9kah3ZKLfh4jcANxkwE xUTwJYGU 6Ifc6T4vgaXs0TRKQgpi9T1Pm6+X4JNWp87bFB/JC006cKa5CGFXiHaBZ1rDPTabH310je837pVu4K4xa1VglCboV6lLRuan7Lm7sF/bAvb4KfMPqgZa34xeetkz5x8V868uBvl5NedJhVAdDhNGx/KQCyERvFnnVwl+f2oNPxXAg0mK0o8yWpT19C1sLPk7pO+1ejLI568k66+YJBmzFWsjo8DEp84Xmpi+PsioGRpOxlBItb3hscUTx8QEpmb4VPJdZh40soHcFIGQv9b8S9AZSczXQ8EAWBDcy3mXrcLIeTycVGmXLC1sjr+AQ9psghV11z+sXZkJZ1s96irSKbEEpoE47WLO5ewutDYIqX28eHzvpNsSE1WdNxbsmJyfvFzd8J76JAMwR3XJsduubJY0OKX51yh34MQxLzWBAlapY8+I= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Since every CMA region is now tracked by kmemleak at the time cma_activate_area() is invoked, and cma_activate_area() is called for each CMA region, invoke kmemleak_free_part_phys() during cma_activate_area() to inform kmemleak that the CMA region will be freed. Doing so also removes the need to invoke kmemleak_ignore_phys() when the global CMA region is being created, as the kmemleak object for it will be deleted. This helps resolve a crash when kmemleak and CONFIG_DEBUG_PAGEALLOC are both enabled, since CONFIG_DEBUG_PAGEALLOC causes the CMA region to be unmapped from the kernel's address space when the pages are freed to buddy. Without this patch, kmemleak will attempt to scan the CMA regions, even though they are unmapped, which leads to a page-fault. Cc: stable@vger.kernel.org Signed-off-by: Isaac J. Manjarres --- mm/cma.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mm/cma.c b/mm/cma.c index 674b7fdd563e..dd25b095d9ca 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -102,6 +102,13 @@ static void __init cma_activate_area(struct cma *cma) if (!cma->bitmap) goto out_error; + /* + * The CMA region was marked as allocated by kmemleak when it was either + * dynamically allocated or statically reserved. In any case, + * inform kmemleak that the region is about to be freed to the page allocator. + */ + kmemleak_free_part_phys(cma_get_base(cma), cma_get_size(cma)); + /* * alloc_contig_range() requires the pfn range specified to be in the * same zone. Simplify by forcing the entire CMA resv range to be in the @@ -361,11 +368,6 @@ int __init cma_declare_contiguous_nid(phys_addr_t base, } } - /* - * kmemleak scans/reads tracked objects for pointers to other - * objects but this address isn't mapped and accessible - */ - kmemleak_ignore_phys(addr); base = addr; }