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 A974FC433F5 for ; Fri, 22 Oct 2021 02:43:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 497FE6139F for ; Fri, 22 Oct 2021 02:43:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 497FE6139F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id D7673940009; Thu, 21 Oct 2021 22:43:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D24D2900002; Thu, 21 Oct 2021 22:43:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C3A44940009; Thu, 21 Oct 2021 22:43:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0173.hostedemail.com [216.40.44.173]) by kanga.kvack.org (Postfix) with ESMTP id B5ED8900002 for ; Thu, 21 Oct 2021 22:43:28 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5DE27180AD837 for ; Fri, 22 Oct 2021 02:43:28 +0000 (UTC) X-FDA: 78722527296.05.24D5DC7 Received: from out30-43.freemail.mail.aliyun.com (out30-43.freemail.mail.aliyun.com [115.124.30.43]) by imf15.hostedemail.com (Postfix) with ESMTP id A4EE3D00009A for ; Fri, 22 Oct 2021 02:43:22 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0UtCtr96_1634870602; Received: from B-X3VXMD6M-2058.local(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0UtCtr96_1634870602) by smtp.aliyun-inc.com(127.0.0.1); Fri, 22 Oct 2021 10:43:23 +0800 From: Xin Hao Reply-To: xhao@linux.alibaba.com Subject: Re: [PATCH V2] mm/damon/dbgfs: Optimize target_ids interface write operation To: SeongJae Park Cc: sjpark@amazon.de, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20211021173018.15994-1-sj@kernel.org> Message-ID: Date: Fri, 22 Oct 2021 10:43:22 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20211021173018.15994-1-sj@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed X-Stat-Signature: cxxgfffrny48kygtdyrjbhejqe6aaiqz Authentication-Results: imf15.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf15.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.43 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: A4EE3D00009A X-HE-Tag: 1634870602-216876 Content-Transfer-Encoding: quoted-printable 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: On 2021/10/22 =E4=B8=8A=E5=8D=881:30, SeongJae Park wrote: > Hello Xin, > > On Fri, 22 Oct 2021 00:44:16 +0800 Xin Hao wro= te: > >> 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 overhea= d. > After all, this is not a performance critical path. Thank you for your detailed explanation. I may not describe it clearly,=20 making you think that i am making this modification to improve performance=EF=BC=8CI just want to avoid irreleva= nt code=20 execution, thank you so much. > > 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 =3D 0; i < nr_targets; i++) { >> targets[i] =3D (unsigned long)find_get_pid( >> -- >> 2.31.0 --=20 Best Regards! Xin Hao