From patchwork Fri Feb 18 10:26:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonghyeon Kim X-Patchwork-Id: 12751279 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 C2959C433F5 for ; Fri, 18 Feb 2022 10:27:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C6446B0078; Fri, 18 Feb 2022 05:27:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 34EA66B007B; Fri, 18 Feb 2022 05:27:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1EF6A6B007D; Fri, 18 Feb 2022 05:27:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 0F66B6B0078 for ; Fri, 18 Feb 2022 05:27:03 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id CC43622C72 for ; Fri, 18 Feb 2022 10:27:02 +0000 (UTC) X-FDA: 79155522684.01.325361E Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by imf22.hostedemail.com (Postfix) with ESMTP id 59C7EC0006 for ; Fri, 18 Feb 2022 10:27:02 +0000 (UTC) Received: by mail-pl1-f176.google.com with SMTP id m11so3249062pls.5 for ; Fri, 18 Feb 2022 02:27:02 -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=SbSe86F/mvz+5DSEor64C0xM/Lps30xwHOa0r4wCYG66wDcOZKvVPPDBusLJrxTR5e UNndFwYQfiaa9LW68lceVK1EoQwHnvWqA7SkMEg9srmxGr2a2/CP8apZDe7JHWq/E5Up QBIPmDEjsEcjWopYNFOyx0hF3vtiBHlEZLX4AHfAIMIKvS5/0/XnxMzygRdi1I5tGMzY biShDA5D1qgONm41x7MiAwNCF8u/2fOWf6E+x6QtPFl/lC2HXA6geVebezBRuyWkI/Kn Wuwb+UAtzqWljhKFfGZ3Vbj2AM4yO5/HKDlHZXy/f1iyOK/9/o5Ke5d7C2haBOQ5L2cz zC4w== X-Gm-Message-State: AOAM533UFlKgamt7lzFJ2BQ+oNkOrmxswvx1D0GnKn2tauEhZZLz61/0 UiUtS+P0L9sUo9Sd5R5SexCcXA== X-Google-Smtp-Source: ABdhPJwmd0fVZO0Edt92aYqkcns0NPA3othJELbRqEVsjcuckc3gLs6OopDmtExBFLlQwLVPribCdw== 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-Rspamd-Queue-Id: 59C7EC0006 X-Stat-Signature: chaobmqw59o7hfrs1axr7pdf9qmkuiza X-Rspam-User: Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=ajou.ac.kr header.s=google header.b=CSBsjQAC; spf=pass (imf22.hostedemail.com: domain of tome01@ajou.ac.kr designates 209.85.214.176 as permitted sender) smtp.mailfrom=tome01@ajou.ac.kr; dmarc=pass (policy=reject) header.from=ajou.ac.kr X-Rspamd-Server: rspam05 X-HE-Tag: 1645180022-393394 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000288, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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