From mboxrd@z Thu Jan 1 00:00:00 1970 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 CAFEECD13D1 for ; Mon, 18 Sep 2023 07:13:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D34A6B0254; Mon, 18 Sep 2023 03:13:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 582C96B0256; Mon, 18 Sep 2023 03:13:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 471776B0257; Mon, 18 Sep 2023 03:13:01 -0400 (EDT) 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 396A56B0254 for ; Mon, 18 Sep 2023 03:13:01 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 02F2040B54 for ; Mon, 18 Sep 2023 07:13:00 +0000 (UTC) X-FDA: 81248851362.21.CCB7215 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf13.hostedemail.com (Postfix) with ESMTP id 2A8032002D for ; Mon, 18 Sep 2023 07:12:55 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of ruanjinjie@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=ruanjinjie@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695021179; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AacGfaippiOOY9VjuPkc21freTF5zlKfISJR9NbgLqE=; b=vv+vxCnrIjlTPYjxBBqvGlVlVVDAXciTJsv5gqF5JQ/hVW2SLzW9efYIgAtb7XHU4nlB7s /CHbdkykZsIDCBq8qQL/OOWxKi7joGcoMKbJAQf3W9/FQBeP4OYqBChYCUiDi87y4a3BmN iitzcYpmh4bpIUR0+VfGXY6ExoxWlGw= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of ruanjinjie@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=ruanjinjie@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695021179; a=rsa-sha256; cv=none; b=YLTQnOCTG+bMmSKKn+Vf2UB6ON+Z+oHh0PT8Eb0zY9FwzVjnFN8IwmDYrTnlk1J0IyuzHZ 6hQ67kqgE05jeyj0jQDhE+IF1uhwVR7uc40QQt4NUZae8iSesJ/GyUJTutfhqIWbvpPeP5 THLSNOqxXLKU0XS2SPkiWc0Nm8Cev9U= Received: from kwepemi500008.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Rpwtb19WqzrSJQ; Mon, 18 Sep 2023 15:10:47 +0800 (CST) Received: from [10.67.109.254] (10.67.109.254) by kwepemi500008.china.huawei.com (7.221.188.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Mon, 18 Sep 2023 15:12:50 +0800 Message-ID: <51f76d81-77f7-48b0-7a94-b28b2e5ed868@huawei.com> Date: Mon, 18 Sep 2023 15:12:49 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH RESEND 2/2] mm/damon/core-test: Fix memory leak in damon_new_ctx() Content-Language: en-US To: SeongJae Park CC: , , , , , , , References: <20230918054326.74929-1-sj@kernel.org> From: Ruan Jinjie In-Reply-To: <20230918054326.74929-1-sj@kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.109.254] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemi500008.china.huawei.com (7.221.188.139) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 2A8032002D X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: sridgo34xzqzr1bgez4wapg1hipd6sr3 X-HE-Tag: 1695021175-922350 X-HE-Meta: U2FsdGVkX1+I+mNey4dS33bvL5VTcetzomdBHBEYaXrAKqr00LVkhji177r0UUVpgOPMY+m+v34VnmNp9vYQ7FjW0FS43bkqyHaDcuSxoj3MJhYmw68gGYNHS5MIm6fBoo4ZGn15yUGPU3Js/e3VwstqSMeQ/Hxq0m+qD6bGQ33HuJLSPr1HaPgEKUWorv+uTJg8GlX5FRsHyBsSNiEg2bQYJQSH3Ja2KlAEyyUhGBxUsBKu4RdxxOHq+/4L5h3b+ScTjoWDqilscnXrdKMRER/lYKUuetcr6KTfabEo0XVfk/bjAWpulj1RJvIf4Hxtkvxg5EG9IurS9K3Z/a96I5brhb0pEXZo1+eXQXcjxLtM6xPBcLOF/ISgxX+NBCwm7V+3Wk2vFB1Pp3Y+le5A+Dk189JBVkz3J+EAFzF3cDGlOncrP4qVLkq2uBxMwt7noci22+0HMElWfKqelBEZaeHxXg0e0QSgML9Y9gza1fuE9LqSbqUzNlnW5/F9uTEZmHgN1DZT4qOvk1+KK0Q0+1+FyAaEYSthY0gsuqjPf/dFRKIomMjFCj75JaJK3SyeSx/pR1yRkxUPZptgPF5vlYauXr/MHJefHKk/WRKDfllc9c1npz/OYbdoTlKniyRgqSIT/kQYXTNjRIDHAPQQYVraf8kfqHcBKD/bu37v8faRz3+ZCrK+vBRIXS4Y6ZnZpj1DjRtkxwSVV44sniVCFuSZcJsQUSbHozJjBnaknIY86tpFUDWJ7m+MLTTqrg9stR1S086QkdMB3VGFj8LEUMDKtukLAG1nfqaxTftWvD48P3jSGWMe4Cc/Aoz3Iv97JJ/0IbPLdf2L9rySKRKAXe1+V5rKPkGGBXKU++Cv7EJYDKiycwTnaTvh8BEUyiu93VS7abPwdiLELupKmibE672ehuzu0Q7EV5wZFxMW1W95YSMY5OQz8pQs51OlSXwXrQBDGcLsw52mY8zRdlW vXEPhCN3 Lco/fzjyGi8+W/Ewk1k/4yg55iXg38UET0No24D5zPb+aRNfpQ5+CfZkF/nwUsdAB94Sfp3jT3hDTamIAQ9rIJf0pY6FbRQwcgP82TWE7w7Uq0PYCepMrDZ0o+45HVVMKZ05/4SY6w+zI4coYlTrBvwC3hUEKeYhWWvyIqUlgP/vtkZH0HPeqyowwHLh81w5HqP5Rzajkzmo+MA84sA9WIomfmtWcLQTQz0s2sFf2Rsaz/JdxezRWopc45WdqRmtToWdKkto+SaiICBM= 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: On 2023/9/18 13:43, SeongJae Park wrote: > Hi Jinjie, > > On Mon, 18 Sep 2023 13:10:44 +0800 Jinjie Ruan wrote: > >> The damon_ctx which is allocated by kzalloc() in damon_new_ctx() in >> damon_test_ops_registration() and damon_test_set_attrs() are not freed and >> it causes below memory leak. So use damon_destroy_ctx() to free it. >> >> unreferenced object 0xffff2b49c6968800 (size 512): >> comm "kunit_try_catch", pid 350, jiffies 4294895294 (age 557.028s) >> hex dump (first 32 bytes): >> 88 13 00 00 00 00 00 00 a0 86 01 00 00 00 00 00 ................ >> 00 87 93 03 00 00 00 00 0a 00 00 00 00 00 00 00 ................ >> backtrace: >> [<0000000088e71769>] slab_post_alloc_hook+0xb8/0x368 >> [<0000000073acab3b>] __kmem_cache_alloc_node+0x174/0x290 >> [<00000000b5f89cef>] kmalloc_trace+0x40/0x164 >> [<00000000eb19e83f>] damon_new_ctx+0x28/0xb4 >> [<00000000daf6227b>] damon_test_ops_registration+0x34/0x328 >> [<00000000559c4801>] kunit_try_run_case+0x50/0xac >> [<000000003932ed49>] kunit_generic_run_threadfn_adapter+0x20/0x2c >> [<000000003c3e9211>] kthread+0x124/0x130 >> [<0000000028f85bdd>] ret_from_fork+0x10/0x20 >> unreferenced object 0xffff2b49c1a9cc00 (size 512): >> comm "kunit_try_catch", pid 356, jiffies 4294895306 (age 557.000s) >> hex dump (first 32 bytes): >> 88 13 00 00 00 00 00 00 a0 86 01 00 00 00 00 00 ................ >> 00 00 00 00 00 00 00 00 0a 00 00 00 00 00 00 00 ................ >> backtrace: >> [<0000000088e71769>] slab_post_alloc_hook+0xb8/0x368 >> [<0000000073acab3b>] __kmem_cache_alloc_node+0x174/0x290 >> [<00000000b5f89cef>] kmalloc_trace+0x40/0x164 >> [<00000000eb19e83f>] damon_new_ctx+0x28/0xb4 >> [<00000000058495c4>] damon_test_set_attrs+0x30/0x1a8 >> [<00000000559c4801>] kunit_try_run_case+0x50/0xac >> [<000000003932ed49>] kunit_generic_run_threadfn_adapter+0x20/0x2c >> [<000000003c3e9211>] kthread+0x124/0x130 >> [<0000000028f85bdd>] ret_from_fork+0x10/0x20 > > Same to the comment on the first patch of this patchset, simply letting others > know the name of the tool you used for making this cool output could be > helpful. Could you please add it? > > Also, I prefer adding four spaces indent to quoted command outputs on commit > messages. Could you please add that indentation? > > Also, I cannot 'git am' this patch on top of mm-unstable[1]. Could you please > double check and rebase on latest mm-unstable if I din't miss something? > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/log/?h=mm-unstable Sure. Thank you very much! > >> >> Fixes: d1836a3b2a9a ("mm/damon/core-test: initialise context before test in damon_test_set_attrs()") >> Fixes: 4f540f5ab4f2 ("mm/damon/core-test: add a kunit test case for ops registration") >> Signed-off-by: Jinjie Ruan >> --- >> mm/damon/core-test.h | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/mm/damon/core-test.h b/mm/damon/core-test.h >> index 255f8c925c00..ce86ed30fb47 100644 >> --- a/mm/damon/core-test.h >> +++ b/mm/damon/core-test.h >> @@ -266,6 +266,8 @@ static void damon_test_ops_registration(struct kunit *test) >> >> /* Check double-registration failure again */ >> KUNIT_EXPECT_EQ(test, damon_register_ops(&ops), -EINVAL); >> + >> + damon_destroy_ctx(c); >> } >> >> static void damon_test_set_regions(struct kunit *test) >> @@ -342,6 +344,8 @@ static void damon_test_set_attrs(struct kunit *test) >> invalid_attrs = valid_attrs; >> invalid_attrs.aggr_interval = 4999; >> KUNIT_EXPECT_EQ(test, damon_set_attrs(c, &invalid_attrs), -EINVAL); >> + >> + damon_destroy_ctx(c); >> } >> >> static void damos_test_new_filter(struct kunit *test) > > Other than above comments, changes look good to me. > >> -- >> 2.34.1 >> > > Thanks, > SJ