From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CACEC433EF for ; Thu, 21 Oct 2021 17:30:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 061E6619EC for ; Thu, 21 Oct 2021 17:30:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 061E6619EC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 5D2FE900002; Thu, 21 Oct 2021 13:30:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 55AE36B0071; Thu, 21 Oct 2021 13:30:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42298900002; Thu, 21 Oct 2021 13:30:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0055.hostedemail.com [216.40.44.55]) by kanga.kvack.org (Postfix) with ESMTP id 2D28C6B006C for ; Thu, 21 Oct 2021 13:30:26 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C75AD2FE14 for ; Thu, 21 Oct 2021 17:30:25 +0000 (UTC) X-FDA: 78721133610.38.802AA46 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf17.hostedemail.com (Postfix) with ESMTP id 5212EF000136 for ; Thu, 21 Oct 2021 17:30:25 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 01D61619E8; Thu, 21 Oct 2021 17:30:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634837424; bh=Rw1sUa7yPrJ6jT4uN3r6flB0/5Xc0XmX8HOGGrPrPLk=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=SbyQFe08b594LDqPdBXhuhse2RGndFBFY6bY5mBe0luSs2efqt8V7JlyE/VF2a5nN 5rbpe3FG2ZKQUgxOI6TtrOOHkPAo8AeQAzP4wPb1mxwhzXGKMn+s6JavKH/vZqmMol NJhh1P8oYFBanpnILpE0ZK35ik1aRK/unP4zOCfNQ5NkdVzDm+hlSsQXD8zhtYCztq wrP8Jzg8l5XZslvJjHWteKCZsutJSSbTRi5buTV2SWLXU9vnzZlxl/OoUV3CMYt845 iZyw+UUFA9L+GjS3M5SeQ5UcaHziNfl5xwgc8W1kNBPmUtRAqXFNn8IL55wGhgiJ53 Cg8QW5m70RYtQ== From: SeongJae Park To: Xin Hao Cc: sjpark@amazon.de, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V2] mm/damon/dbgfs: Optimize target_ids interface write operation Date: Thu, 21 Oct 2021 17:30:18 +0000 Message-Id: <20211021173018.15994-1-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: X-Stat-Signature: bx68dhb1zfumj1zxj1ujyz5w315kyg5q Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SbyQFe08; spf=pass (imf17.hostedemail.com: domain of sj@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 5212EF000136 X-HE-Tag: 1634837425-744321 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: Hello Xin, On Fri, 22 Oct 2021 00:44:16 +0800 Xin Hao wrote: > When we want to clear previously set target ids, > For example, it works as below now: > # echo 42 > target_ids > # cat target_ids > 42 > # echo > target_ids > # cat target_ids > > But in 'dbgfs_target_ids_write', there is no need to > execute other codes, except call 'damon_set_targets' > to clear previously set target ids. So there adds > the 'nr_targets' judgment, if the value is 0, just > call 'damon_set_targets', and then return. It's true that it executes some unnecessary code. However, I unsure if that is a problem, as the code that will be additionally executed in this case are quite simple ones, and therefore not supposed to incur viewable overhead. After all, this is not a performance critical path. Thanks, SJ > > Signed-off-by: Xin Hao > --- > mm/damon/dbgfs.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c > index a02cf6bee8e8..1d83f4138fad 100644 > --- a/mm/damon/dbgfs.c > +++ b/mm/damon/dbgfs.c > @@ -362,6 +362,12 @@ static ssize_t dbgfs_target_ids_write(struct file *file, > goto out; > } > > + if (!nr_targets) { > + /* remove targets with previously-set primitive */ > + damon_set_targets(ctx, NULL, 0); > + goto free_targets_out; > + } > + > if (id_is_pid) { > for (i = 0; i < nr_targets; i++) { > targets[i] = (unsigned long)find_get_pid( > -- > 2.31.0