Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp1217334pxb; Fri, 18 Feb 2022 03:12:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyGFhGSN5cwrCzB/KDQZaYQaX4xJtzTfFExpUz8TlRxxIWJk5G7z3CQ5oBZ/AUrCjwWi24q X-Received: by 2002:a50:fe08:0:b0:40f:932a:47b0 with SMTP id f8-20020a50fe08000000b0040f932a47b0mr7757219edt.64.1645182776490; Fri, 18 Feb 2022 03:12:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645182776; cv=none; d=google.com; s=arc-20160816; b=u0NkzGg8TN7JlrRqPqIo2ubt6VN11pYTfO0hk/iS7d8gsfcbxsOvg2EzF5D/DfZI2a kvASAj1AVzYv+3cmRrUSfY0JvBzlRYxAnT1aNbiN3Ac/R9wjIFedZmhJyxRc05ak8JLz q+tN77TCfWehOFnWU2E8qz8Tju7H2pwKfiW4PAn5wMQBctVgB1Pc65SEUrFz8BnVegqK 4WSGUpddk7SOFqT56kqdUB3rIpR30TzLua54PcRPYm6xOMqZHKAw4CHn777Z8wGXboOE +zkmmRAuXmtv8PeHbnvWndbNVh1QxTtxKjsjLZNqbnW7IL4+btNEtSkSrsO/Coq9V5GD Mngw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=+T3KpWhNKa0tR65ONmcJl30b/m+LmztZvFh+zw/KtCk=; b=DvqAXmA/loK2kaNTaHbRNbVUv3ufRCIQEDFTX4q4YrNCn22aB326bP51xV/bhOrng7 GNU/fJl2J37SD4tg2BchmOM5RGDQANiouj76ET9SVZ3l19IzW6OR4kJdjE7/oksbVnvO yHEmHimVJgGCYEic2nuZHn+rHDnfoWdTcJtN6bMf0ieUMQ88mqi7qOmjQBcDujDUozU6 AOWWgoBM9pVu0viI6aSReQxIq9O/UNwfQnLkaxUTqswAxl+9E/sTtI/eEECcQK4tgiyl ckgt7d7ECy50XrEyRO7oAFkUYcdB1Tr9bALFDIz8Rj7zggP79T6A3ISMhxV+35pKfIbp RG9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ajou.ac.kr header.s=google header.b=CSBsjQAC; 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=REJECT sp=REJECT dis=NONE) header.from=ajou.ac.kr Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p12si3892336ejy.180.2022.02.18.03.12.33; Fri, 18 Feb 2022 03:12:56 -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=@ajou.ac.kr header.s=google header.b=CSBsjQAC; 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=REJECT sp=REJECT dis=NONE) header.from=ajou.ac.kr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233677AbiBRK1X (ORCPT + 99 others); Fri, 18 Feb 2022 05:27:23 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234050AbiBRK1T (ORCPT ); Fri, 18 Feb 2022 05:27:19 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFBF512770 for ; Fri, 18 Feb 2022 02:27:01 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id qe15so8159404pjb.3 for ; Fri, 18 Feb 2022 02:27:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ajou.ac.kr; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+T3KpWhNKa0tR65ONmcJl30b/m+LmztZvFh+zw/KtCk=; b=CSBsjQACvcRO/sFAdwgQWs3JH/MmMWvyiVBNhla3nPtD9bgbk93JwZ2ntMsBUKq32T UIB8q3Ud3Aljxzwv3VHVhqrkqAdydQhA7KNG3IKuxZjpV67WfFmat9sN/omK6iuwGB4C IPB1CVoscYCyZtSboNE8VGsLqW3UjP5cZIHcA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+T3KpWhNKa0tR65ONmcJl30b/m+LmztZvFh+zw/KtCk=; b=0mYEE1d/lv7N1YeGSh2XxEFg3u5DVfgl0HUrf9XfFm41ycCVpnKrWJ+BBIdeFEFZ3c 727MlMY+/am8GUwyAEqrYvzlzILlrWSCBaDCRgGUOFtpGopcB1FPv1UV6Qaz/KoJpoQp 9ni5HMSFBMl57l9cu5WkI8t6rJ7xe6naVo2RLLFZ4vrHpHe0in1NI51OCIKuR+UJ7eoT P7oKFOu7YgC41kUUKbCNyieYTgoRurT/onF09YFFBazGuzcNomy9cl0erCOfsNqSE00h IM4B0PeUgICPRMo/orfSC4XQW9av/akHmKtQ+iAVpW9sOje6mlhEVfoKZ43n4Vkihwch msyw== X-Gm-Message-State: AOAM533c8iMcRYQh+7u78rkoictne6eSaPx/QDj7RzfChziMl/xHiwAs /Wl7NIMRwANMlZFrx8gNdZ5NVQ== X-Received: by 2002:a17:90b:38ce:b0:1b9:e0dd:50ec with SMTP id nn14-20020a17090b38ce00b001b9e0dd50ecmr11885292pjb.163.1645180021147; Fri, 18 Feb 2022 02:27:01 -0800 (PST) Received: from localhost.localdomain ([210.107.197.32]) by smtp.googlemail.com with ESMTPSA id k13sm2767696pfc.176.2022.02.18.02.26.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Feb 2022 02:27:00 -0800 (PST) From: Jonghyeon Kim To: akpm@linux-foundation.org Cc: Jonghyeon Kim , Jonathan.Cameron@Huawei.com, amit@kernel.org, benh@kernel.crashing.org, corbet@lwn.net, david@redhat.com, dwmw@amazon.com, elver@google.com, foersleo@amazon.de, gthelen@google.com, markubo@amazon.de, rientjes@google.com, shakeelb@google.com, shuah@kernel.org, linux-damon@amazon.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v1 2/3] mm/damon/core: Add damon_start_one() Date: Fri, 18 Feb 2022 19:26:10 +0900 Message-Id: <20220218102611.31895-3-tome01@ajou.ac.kr> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220218102611.31895-1-tome01@ajou.ac.kr> References: <20220218102611.31895-1-tome01@ajou.ac.kr> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 damon_start() function is designed to start multiple damon monitoring contexts. But, sometimes we need to start monitoring one context. Although __damon_start() could be considered to start for one monitoring context, it seems reasonable to adopt a new function that does not need to handle 'damon_lock' from the caller. Signed-off-by: Jonghyeon Kim --- include/linux/damon.h | 1 + mm/damon/core.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index c0adf1566603..069577477662 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -511,6 +511,7 @@ int damon_register_ops(struct damon_operations *ops); int damon_select_ops(struct damon_ctx *ctx, enum damon_ops_id id); int damon_start(struct damon_ctx **ctxs, int nr_ctxs); +int damon_start_one(struct damon_ctx *ctx); int damon_stop(struct damon_ctx **ctxs, int nr_ctxs); #endif /* CONFIG_DAMON */ diff --git a/mm/damon/core.c b/mm/damon/core.c index 290c9c0535ee..e43f138a3489 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -466,6 +466,31 @@ int damon_start(struct damon_ctx **ctxs, int nr_ctxs) return err; } +/** + * damon_start_one() - Starts the monitorings for one context. + * @ctx: monitoring context + * + * This function starts one monitoring thread for only one monitoring context + * handling damon_lock. + * + * Return: 0 on success, negative error code otherwise. + */ +int damon_start_one(struct damon_ctx *ctx) +{ + int err = 0; + + mutex_lock(&damon_lock); + err = __damon_start(ctx); + if (err) { + mutex_unlock(&damon_lock); + return err; + } + nr_running_ctxs++; + mutex_unlock(&damon_lock); + + return err; +} + /* * __damon_stop() - Stops monitoring of given context. * @ctx: monitoring context -- 2.17.1