From patchwork Mon Dec 19 17:18:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13076896 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 6ECF8C10F1B for ; Mon, 19 Dec 2022 17:18:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0E338E0005; Mon, 19 Dec 2022 12:18:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CBE9B8E0001; Mon, 19 Dec 2022 12:18:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B386E8E0005; Mon, 19 Dec 2022 12:18:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id A11FF8E0001 for ; Mon, 19 Dec 2022 12:18:19 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 66E4B120B20 for ; Mon, 19 Dec 2022 17:18:19 +0000 (UTC) X-FDA: 80259714318.27.1DF81A1 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf30.hostedemail.com (Postfix) with ESMTP id 977148000C for ; Mon, 19 Dec 2022 17:18:17 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IOziWT8N; spf=pass (imf30.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1671470297; a=rsa-sha256; cv=none; b=vk1/5BEz2E7b+l7RY65GPJCwDuU0eiYcbt+9nhWWk1mvr4Bp752M6b6YR4MVbj+64FbrL7 pFxwXi6MLGL88ODLLCG8KEX6+Kg/ZXlq016So9LNcgLZXPRZZL1guteySumc0d4sVA9FoY 6ylzeXKNWYRRLN9NEJlv5kROxGMP1Vg= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IOziWT8N; spf=pass (imf30.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671470297; 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=i+Pv9uAqtdoN/1P8MZyuIsAYhEFZfX5nyJz5lTOnO6M=; b=LoTbDeYAyPvwDhSLlT2WE9fJmCd226Y/sao4+Voxh4pBhzDifRkKVS0onByeiDmNFxhE8Z zukU5LSUBsL+haRaZjyqqiQwMJ2v81RJSlvADPGtf6v3caB229j4GARDzIPITTuMxVIl5J 8L1t4BLAJizO3tVlvepKPTUmrP9dunc= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 266BBB80F2B; Mon, 19 Dec 2022 17:18:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC991C433AF; Mon, 19 Dec 2022 17:18:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671470294; bh=DScbhf2qkPduKtfJPNLimXEH2D1WRTFQEhM+/Oib0wg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IOziWT8N2rcIsbd8XCtsN/2zVXLABdKcySmLCpBta5IIK1AbrIdh374l0ZaLtosiG gbnRriNLCXYfshbWV9jQ9HRSRkUHCayl/lrReaGA6EBOuaceR8TUmX33CKAfIyDNup HCMJ/FHq9vg3Ud3o5/2z1kJFMp+lTAGvj+P5FQidAawhTCRFJxaOSLPTDBzJ5ortF3 uYDWENSn9ijdKmTSM2dr1gfcb4YqXtXxWEg0OdbkHVwRbduwofspwvetzMa+K2H//I JeS5Ro7NCgsFRW+6xdPv+cFZ/WG1Bqh9tEMFD+AtcBLxPDJRFOHnPsguWYZsqIYRLS nUO3EeTmg9OWw== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH mm-unstable 2/2] mm/damon/sysfs-schemes: Return an error for filter memcg path id lookup failure Date: Mon, 19 Dec 2022 17:18:07 +0000 Message-Id: <20221219171807.55708-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221219171807.55708-1-sj@kernel.org> References: <20221219171807.55708-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 977148000C X-Rspamd-Server: rspam01 X-Stat-Signature: bbptnbnsihiisd1fybhr5gzpgsuwoixy X-HE-Tag: 1671470297-432722 X-HE-Meta: U2FsdGVkX1/WhZ2/cJYL+ewj2CIn/Eay0DMs8vWMf7AwOK3iy2hUlHYUm3x9DsBJsaPBptOzgTZB+OwP5jQjj+3tyAcM9RPofAyWvdi/qDW5BoqFh9F2s3X79qmDiJH3jH9wUUUqj+AsVYaIeBg5OEQk4A4EpG2M/Wb0YOUHioKVQZf2VlRVICFVZvOPkMYNEXofA5bd7/rlfX/83+eKKc6aHD5WlCLv2I1DPlNyeKQTczzK/g/VzcVSOMrr1Imr+CUUP9O9eFfPAHK/FB7A0D7ke85CGV8QWqm7jILtrKU3FepsLbE+zmRh4fBCNgsqZJdFxFH1bF+2hrpkwIJ8zOQmVDDZdOvvMf7LmBakpDp6+isRz7m1If/HJbF4MTEW8z3NlPYB+TW5yNC43cmAG6N+AnCplvYO5JPpRR7Z46jYg5Dgz6JWrKHGI1NIxN2GI7hIxGLDWxqldgqMyNR0r3xKBnQgmxSSTAwPZdTABpSGBsAtu5seiusk/8llzMn3fwmeRRIPFbSS4jO20im3NRrgyPYhLIDY+6b77BTwl3vTAvE9oYLvlxeSAVKh1G9NW/HtPctwP88zPyc+Wu/KTj7bvFLv7LiJHwiAiIfpBOx7McAar1nqwpdKRt7tC8BxwO41vdZHyU/OzWKxNjHZt0qanAgPZ6HPQ29710PvRLl3RuwoXnhEZp37vmuU8AckCYSQpwBCOYMdBwas08m4NY5wnIVcqpacFAh7Lsrv4l2/g469RNAOF0z+e/BeOkQc26YKkaM71XHdmAmMCYfjjdzJNWtz0feYI8UoARCesCHpLyLjbojD5kxu1xM2iR6lM/VJAW7c5yxW5SgzRZlCC93pjEemCXP/2Z9sMGMd5g5YSqFKBbvzcE6RitBUSbZo95AoBJTU0cLuSOqeSmVKeSsUH/BKOdsSrX3jf3DyskPNtSJiaD6lfnmicWXpqQLtHyDCyQtq1hZ7ICg7/1F L+JUEz6i AaKh7mXr3qPa8fK5LiNx3gJuIrsntTFpsTl1ETQcp1tROPrzS0Gx5lG6zLn9xESi4oeR6 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: Commit f36f860207ef ("mm/damon/sysfs-schemes: implement scheme filters") on mm-unstable introduced damon_sysfs_memcg_path_to_id(), which returns non-error even if it didn't find the memcg of the given path. Caller could check the failure by seeing if the 'id' has really set or not, but it's unnecessarily complicated. Return an error for the case instead. Fixes: f36f860207ef ("mm/damon/sysfs-schemes: implement scheme filters") on mm-unstable Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 5d3ac3107927..f0dabe3e2dc0 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1418,6 +1418,7 @@ static int damon_sysfs_memcg_path_to_id(char *memcg_path, unsigned short *id) { struct mem_cgroup *memcg; char *path; + bool found = false; if (!memcg_path) return -EINVAL; @@ -1433,12 +1434,13 @@ static int damon_sysfs_memcg_path_to_id(char *memcg_path, unsigned short *id) continue; if (damon_sysfs_memcg_path_eq(memcg, path, memcg_path)) { *id = mem_cgroup_id(memcg); + found = true; break; } } kfree(path); - return 0; + return found ? 0 : -EINVAL; } static int damon_sysfs_set_scheme_filters(struct damos *scheme,