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: 34669 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2525876wrn; Mon, 19 Dec 2022 09:44:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf7555PYmogrtF/yApY+uUbCDl56uhnGU+yK+o5Dq4i3hq7S8uxHvkQoqihhV/6TaNkR3J+D X-Received: by 2002:a17:906:704d:b0:7b9:62ab:dc3f with SMTP id r13-20020a170906704d00b007b962abdc3fmr54188751ejj.1.1671471881547; Mon, 19 Dec 2022 09:44:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671471881; cv=none; d=google.com; s=arc-20160816; b=oZftWbNB/z6r8cjvPXltBVfRZqH4gIvziKZWlNgkGXyf6xp95UscgKGif/yQxhH126 PWH7Pjs4LOjfogiYokd/88WjB9HU2FUeNWxsQozzCEmmNoS+5BgAdqFpa+tRiEH09MJa Ji7CViNIqQC1szSBTX3CHSazDHPOicumpnSV81v2/5T+FPLFg2iJKCfNV2CMhB6bC3h2 rOaV56n+si0oAKwihsbyN1hcL0nbKBr+eWceMa2gn3759Z25eDgMh17jGxwTXNkwqFya WBycjrQnP1VHUcdvFvfpBfYGMWuInSk7HOw1DXfkNEO0W33Jn266/RyQDMxJJ0s48B3u T3fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=i+Pv9uAqtdoN/1P8MZyuIsAYhEFZfX5nyJz5lTOnO6M=; b=cP02r587Dhx9Oqi6QHju+MnfPGHQTx7K85QMQr9YkWWayufJHCMk5c8YCsqtcY4Ab4 Hw64jroJu2DyM3bsuiH45tihcBKTyGKVCjUXfTBTRq9RXG4qOSHGLFr7wj7fdDWr/gC4 v7i+QyBI9yU1FzIAB8l4sle5sB5Q7HffIzcUv8fERuvkWk+Ygbl0IxEIgxNNSWJfi4ms qMiD5y5/TmGX9b+lswwaXgOVrrnAXkNLvFazHxFNYdreJXg0oELfS2CVgW/YSWV4S2Kw uPGkPicWqPmkAjiqK/StihPo+wuHyMG1RDVD6p3e9I429pEQOczBrXxaS/DNCYS4LiU0 slnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IOziWT8N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sd19-20020a1709076e1300b007d8acbd5717si6929056ejc.439.2022.12.19.09.44.18; Mon, 19 Dec 2022 09:44:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IOziWT8N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232349AbiLSRS1 (ORCPT + 99 others); Mon, 19 Dec 2022 12:18:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232311AbiLSRSS (ORCPT ); Mon, 19 Dec 2022 12:18:18 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CD45B499 for ; Mon, 19 Dec 2022 09:18:15 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id ED6806109E for ; Mon, 19 Dec 2022 17:18:14 +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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752665299720601620?= X-GMAIL-MSGID: =?utf-8?q?1752665299720601620?= 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,