From patchwork Sun Dec 22 23:12:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13918315 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 CEBFBE7718E for ; Sun, 22 Dec 2024 23:12:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61B506B0082; Sun, 22 Dec 2024 18:12:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5CB286B0083; Sun, 22 Dec 2024 18:12:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 491E76B0088; Sun, 22 Dec 2024 18:12:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2BB786B0082 for ; Sun, 22 Dec 2024 18:12:29 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D1053C086E for ; Sun, 22 Dec 2024 23:12:28 +0000 (UTC) X-FDA: 82924144884.26.433221F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id 1991440009 for ; Sun, 22 Dec 2024 23:11:52 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=W0ggchTu; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734909129; a=rsa-sha256; cv=none; b=qTYmVvndfLSfV/iWvZ1yQ0hm5Xh27e0yb46OGPcw/Dmp/jAeiIC5kVom8sTsN9R2r923xl np8AJF4mGDJowf+MMoBIca8Ntma0vxKBH6z43EVeN7gTwJJ6N8K1ZhOUoRJqVFk0IMiNeg q9uctS+0vciB0zYU6hoyr2LmgnsZ0pk= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=W0ggchTu; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734909129; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jhxMfnOQ7sl2nzCsHRQYC+OB6MWPAHABIHNQ0teeV5U=; b=kTQRQJ08NR4Bzunj1kjeUuAnata9pQKUmBHpHOUwyL/fXILZJ2PVuwo4Laj8RUTj2XXBfv zUYhHPAoC7gktAuQYSKQsb072PJ2jhQUp7FbOTegpvtrKD/IoiZ9p+qV2ZOI/+t1hnRtkg cNjPEVXAFyrgtTqZSKlOYvMcjJMs9UY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4CD915C5446; Sun, 22 Dec 2024 23:11:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE365C4CECD; Sun, 22 Dec 2024 23:12:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734909145; bh=zvpnzpnU6SEsn/lS2CcE/GaMIrv4lRmkiTD51TF9JK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W0ggchTuurFk/4bVT7d6P1pbWuYieEKHqJaICN3aHGVUWNzUSjiNo4BsPlE/RH3XW SQ4lp2SVVQukk9ETBPKbEDXe0C/PCNAJtMKrWn/3/bmx0cKfb69pPjJFDn0XOeM8P+ vfn9XMjpaxNpgVNE46SBYchgHg8Ew1XLDnm5/rsavJfY+rth5hrdKLEEdoZksys22V 3h+SqDrUMFjwElMOKgkBdysVpScq3CiOe10FMBw1mSsNHtoAGIfgFFDeOexYUpGIhk XROXbwrjhj+apd1SrSGKONqcxQXNC6J+92mZ5lF7tu6Yspy0zUuE6lEppy1OI4pYvN zL/84F2RZR10A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/2] mm/damon/core: fix new damon_target objects leaks on damon_commit_targets() Date: Sun, 22 Dec 2024 15:12:21 -0800 Message-Id: <20241222231222.85060-2-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241222231222.85060-1-sj@kernel.org> References: <20241222231222.85060-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 1991440009 X-Stat-Signature: 5bogk43dcrdpaua1w334u49rai4yokj1 X-HE-Tag: 1734909112-728244 X-HE-Meta: U2FsdGVkX19e4KR0CeEezUrsLlZuSKnlWGuUufYm8B9e8COYxn4ONL7MUu/HBaSXvzubQ/D2bHWYebdk6wNm44M13c9G+zInB0088jflrJDhnDCH8ivlds93DYMRKxsAJQb9L75vMENSu9F8EcWvV6W6XI6HxpMEEM/CnYKJo3N3A+6wM7BcED0ilBwcEZIwjdzLkOsNiDzGGWkBtVW4HLk2ugN01cIhiNJ/8VKceCxp6G8vjzmoNkowFGiu8VyHx8PUHMYcFIl42/ayx7lt/gF5uY7+Pc+DGQ7n98mOi6XLENsgum/cTiq9sXTuKmlVTqZVAPpy5IA4ovjwbzH5AqbGy10XLJepd2Ba+i+4V33e+BCqEs77uTEASA7ebAXHpHXEzUjctOHmS4wAKgghuFcJV7A5pA3UIpON60o5u7oEZRl81VNkm49yPyhbZQdtoUij3yj6NW0RjGZ66Y46/zwgyl1Ou+nA/NGY80QEQ0ROXtXUPlnGIociZv3Gm3/MMDfFsKH8Nx3fg9KKfgCzRKikH8C9N4j60jrfsk5OmXDVJHHs3qQMU0lpuKlqeaJa6DNcPGm5C31Zs8l/w+ggqBQEAGr3ry5i9F9KT5HFw6SLxrqvGC6gEXwTJfU3vZ+4hCyJQIHrYJTyNvXA+40cNSo0oZl+SLRe6+kP/OrlK2rEsb257dIh+gaP/3Ex1ac0lQNONynzYSFx03aO+9OQRzk5SwE4SXodl8kc1NEY7BlJ9wrRIBZ2LFkTocWSg8p169OWeAinailZP+0z7JC2zBpjtbS+npbiBYZ6denOSSO9C1TEMMjo3Y2NmTp8zn/ERIDwxysGfWnNcV2WoKAyQJzaye03CJoCjaZ3DLv1Qfx9xZwQUyANndAE5OC6XGMtaIDEm0/TRs5RqBGBxLeWK0sZ+JkKODd3SUy2+eVytg0WKyBRF/Qp9JdpP+ceoczPw1w4vLt0twNRNi1qhSD lVIQqykb QZZQcthLQRjFOQs61FVHMbPh925gJWx6PiZT/bX78dhASqGeHs9LwfxKA78uEgtRn+ulfbrbrcJ1ln2ig6iBV8p9lxSsLHAGZ2OGZdsnOsMswScXu0o/bQ+dv8sYdVFnTqkH+ceJ1gbBUjL8LDuq4S35/DnRps7YY0VgSriY5iBeEuC98P3nLNk51IIsE+isMHWTtDCpZJUduoDg9U4nX9pNoG2r4ULVW6xbXfDCNoKvSrNstyAzxE1nwSsuYK0h7BB5VmKL4LDQaiNh4uxY6Q+FT2Q== 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: List-Subscribe: List-Unsubscribe: When new DAMON targets are added via damon_commit_targets(), the newly created targets are not deallocated when updating the internal data (damon_commit_target()) is failed. Worse yet, even if the setup is successfully done, the new target is not linked to the context. Hence, the new targets are always leaked regardless of the internal data setup failure. Fix the leaks. Fixes: 9cb3d0b9dfce ("mm/damon/core: implement DAMON context commit function") Cc: Signed-off-by: SeongJae Park --- mm/damon/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index a71703e05300..931e8e4b1333 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -961,8 +961,11 @@ static int damon_commit_targets( return -ENOMEM; err = damon_commit_target(new_target, false, src_target, damon_target_has_pid(src)); - if (err) + if (err) { + damon_destroy_target(new_target); return err; + } + damon_add_target(dst, new_target); } return 0; } From patchwork Sun Dec 22 23:12:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13918316 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 269C4E77188 for ; Sun, 22 Dec 2024 23:12:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 865116B0083; Sun, 22 Dec 2024 18:12:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 815586B0089; Sun, 22 Dec 2024 18:12:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6412C6B008A; Sun, 22 Dec 2024 18:12:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 37B036B0083 for ; Sun, 22 Dec 2024 18:12:30 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id DFCFE4555C for ; Sun, 22 Dec 2024 23:12:29 +0000 (UTC) X-FDA: 82924145304.04.BA4FBC7 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id 6C84316000F for ; Sun, 22 Dec 2024 23:12:03 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Jt08AH6I; spf=pass (imf08.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734909130; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zZI+3qzmAg8PjFHyEqye3qcFFrlxX0NFSTrhNMvNmeI=; b=zjp8PgC+7I4gAT+DhMEXghPYSAX4C98KLiSrSSeOyet0FQ4aVwUpq0xDMCkOHsbMLYQLVI /72WuuyZ+QT1M2B0DFRvp2NnVC7CjumtH9BDD4SgqXoYON6P7KSXoVag9ycGXSZhuCB/+r BynF8611uqWzEz2fcRZ70uHK6zRPheo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734909130; a=rsa-sha256; cv=none; b=BmTEtNj+JkpJEbE/duIjMUxnl8mPOQiZ6w9/I0r+ySDi0EN37i4H9LfzpMb/oL6pbmU5uW N+i3o8b3He0t+SmBhi6guiZe4UpccZkTwohgMEEFq55CF0cu+rnkTcd6gAoNz//jY3Vu7l 5lRjHF2H65Jit4BHuHJG7RP7lx8xWCc= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Jt08AH6I; spf=pass (imf08.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 786975C54FE; Sun, 22 Dec 2024 23:11:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD54AC4CEDE; Sun, 22 Dec 2024 23:12:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734909147; bh=VnA1Kpl6cnNCncV299IxvKMXy0LENGhUCK7E8iW560U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jt08AH6I6TbqJCHXd/acPRzbZyWx52z2MmhPoaQ2cyp9RK1qweXBp0RrtA4MOMIBf 07kwOrXbJ9793M3E5h78GCOPP0O+dDF4m3oX0+rmbRpoRZv6PblExjqSOxhtjkhEtG HtPhow9N6iHFBadT8FT42tARcpFEL+zyCJtQi/6RslUp2TDnTx/c7N+LSbxrnYeiKw HqMtwjSUIY7TCZmIDYPGiDDaniR5sBgT3AyBNUkrh4m25SObQZEFuJngEE/DN3eyXy eROFrH+b04IqphTPehy3CDM3Pj7l8t6LQLvPHFQ11Gnv9BkZ2xIUh2Gqv/l75QtwCO +R4AOfkouo0CA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 2/2] mm/damon/core: fix ignored quota goals and filters of newly committed schemes Date: Sun, 22 Dec 2024 15:12:22 -0800 Message-Id: <20241222231222.85060-3-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241222231222.85060-1-sj@kernel.org> References: <20241222231222.85060-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 6C84316000F X-Stat-Signature: fz7sq1fb58g9s8co1jmmd3anbpypq1hb X-Rspam-User: X-HE-Tag: 1734909123-17897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NUmxL6cUWcrkD8VLeEM97oDyJa5KXi6eBKxFnfgRnWEwDAmBsyQ2GHCX407pibqNoaoW968lVZQkRmqnj2KdTh5dACrXPOU0yPjBD2i6MU5+yOen960icb9ADdbjeYaaDYQv6qJUhI3iU3PHmZQB+FZuk= 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: List-Subscribe: List-Unsubscribe: damon_commit_schemes() ignores quota goals and filters of the newly committed schemes. This makes users confused about the behaviors. Correctly handle those inputs. Fixes: 9cb3d0b9dfce ("mm/damon/core: implement DAMON context commit function") Cc: Signed-off-by: SeongJae Park --- mm/damon/core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/damon/core.c b/mm/damon/core.c index 931e8e4b1333..5192ee29f6cf 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -868,6 +868,11 @@ static int damon_commit_schemes(struct damon_ctx *dst, struct damon_ctx *src) NUMA_NO_NODE); if (!new_scheme) return -ENOMEM; + err = damos_commit(new_scheme, src_scheme); + if (err) { + damon_destroy_scheme(new_scheme); + return err; + } damon_add_scheme(dst, new_scheme); } return 0;