Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1122147rwb; Thu, 18 Aug 2022 19:55:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR5dOUswpd3Btnr6AwA0yzuoCVi64ZvvhBUeybfA3tLFyhyfGC8ZzhWghN8VYANoC2wGTDYT X-Received: by 2002:a05:6402:248a:b0:440:9709:df09 with SMTP id q10-20020a056402248a00b004409709df09mr4380559eda.42.1660877733256; Thu, 18 Aug 2022 19:55:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660877733; cv=none; d=google.com; s=arc-20160816; b=s1Q2DIYaaze5USNT3i6dgJZsJTVNAD0OEXyyOVCEVAQAKtEcc7PjX7Iq1twafRO3ic zCbM8ThJUKIGEfImC52hwbtMORsmNvPn/3yRIebvaay4P0o0ZwcgPAO7+hdoSiUvgbmQ tGJ2F+lk8IdhkqORymQEuWhTEYlMRIDnm/KACcpBXLxUS1w1GVCawehVioX9zNIfFYZ/ HONqMtwfqpHJAoF9dTXJC1+Jf2eoNmvohS0gqy4qWNdDDT4aM/j/cVDKH6PyKjRXdH4r SlUYx4VZ5Jpqzz01FFwtJ6E9P1tWDfyQ0Ctjsb0G6Qh3SIkS3BjN0pNGdXK+kvS2GLus xIjA== 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=d3Ql8liW8qjQ/G0ayzt93p2uF8XE56LqzCrUMcPwTZ8=; b=zOlNsTIc/hdny1bMXoUyPWkRKmhHyN2d6r5GMz4GakPzUFZYA9PBVz+VmCcUft9KUg Q+jRyavCNEWbGYZ0BfTFurbqn5/AcDLQUMh35lSTW5TuxgUFBrvTb8OmKyrRIpPkJYPE FHwWhHc8pHRBAmCY8kmtkHGwaG96yLRyKP9Fwl3hnV2h4fkRbBMxV1kBeDd5cSIUBtN2 sjJxrflhJHioUz1Sf05ZAVNhu4MRKGrlBImgqNZwDlf4SkoRXzRkAUHkfbFTS8sYnKWQ BRdHFzzsE3PdFd5/oWG78on5WAUTb1mGm6PZokqcGEvHrwiow6HuYEn4HfjWQPSTnR9H OwoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Yjo4zowx; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw40-20020a1709066a2800b00711f55a31casi2570239ejc.775.2022.08.18.19.55.07; Thu, 18 Aug 2022 19:55:33 -0700 (PDT) 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=Yjo4zowx; 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 S240650AbiHSC3L (ORCPT + 99 others); Thu, 18 Aug 2022 22:29:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241306AbiHSC24 (ORCPT ); Thu, 18 Aug 2022 22:28:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5D41A2214 for ; Thu, 18 Aug 2022 19:28:55 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 971CAB8255B for ; Fri, 19 Aug 2022 02:28:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D861FC433D6; Fri, 19 Aug 2022 02:28:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660876133; bh=hlzfkU+1Cauv3f2NrQO+riFDY79o2Wb/uGUduVuAY/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yjo4zowxmdjgkvQnUobmcF0qq6ZHfoWfro2F+gk0qdsPU2NHlMWoEhEVvcIZTIwI6 KbycYs+9f4m0S+0h89mtUtOk3QnELuayoie+6fzss1zM/H8w6yslRJkv7gOw8tCO9B ncBTKScfc5rNG+3F8tyBYN3R1AxvF3pad2xbMh7ry9QDfEm8PIrgf80chxBv4BzFjk 73Cc6OIWiwQ1rrou6JCWsKfL7ohkyRWGInSE/VHoCyzgfI4MTBer4YHTE9dJln0fUI +L4MRrWSEtaRI7++wBzA5jQEfJJIJv6wTzJsSspO86LLTl3ojIOR7ou7NaXNyWJM1Z 0eh2t5vXOnEdw== From: SeongJae Park To: xhao@linux.alibaba.com Cc: SeongJae Park , akpm@linux-foundation.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V2 1/2] mm/damon/lru_sort: Move target memory region check to head of func Date: Fri, 19 Aug 2022 02:28:50 +0000 Message-Id: <20220819022850.52236-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <5c1c4b01-5ada-5c25-7181-a6f6c2c1f6ed@linux.alibaba.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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,T_SCC_BODY_TEXT_LINE 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 Hi Xin, > > 在 2022/8/19 上午1:11, SeongJae Park 写道: > > Hi Xin, > > > > > > On Thu, 18 Aug 2022 18:57:31 +0800 Xin Hao wrote: > > > >> In damon_lru_sort_apply_parameters(), if "monitor_region_start" > >> and "monitor_region_end" is not a valid physical address range, > >> There no need to run the remainder codes in it. > > The function, 'damon_lru_sort_apply_parameters()', checks validity of > > parameters and construct the DAMON context one by one. For example, > > 'damon_set_attrs()' returns an error if the parameters are invalid. So the > > intended flow is, > > > > 1. check DAMON attributes parameters, > > 2. apply DAMON attributes parameters, > > 3. check scheme parameters, > > 4. apply scheme parameters, > > 5. check target region parameters, and > > 6. apply target region parameters. > > > > Therefore what this patch does is making the target regions validity check to > > be done earlier than validity checks of other parameters. There is no special > > reason to check the region earlier than others. Also, this change makes the > > flow of the function a little bit weird in my humble opinion, as the flow will > > be > > > > 1. check target region parameters, > > 2. check DAMON attributes parameters, > > 3. apply DAMON attributes parameters, > > 4. check scheme parameters, > > 5. apply scheme parameters, and > > 6. apply target region parameters. > > Ok, understand what you mean, my fix looks ugly, buy any apply above > are not not necessary if one of them checks failed, why not check all > fisrt and then apply them, like this: > > 1. check target region parameters, > > 2. check DAMON attributes parameters, > > 3. check scheme parameters, The parameter values could be changed by users after the check, so we should cache those somewhere anyway. In other words, we cache those in the DAMON context. Therefore I think the above works were not totally waste of the time. Also, because the parameters applying functions like 'damon_set_attrs()' does the check and applying of the parameters together, I feel like current flow is natural. If I'm missing something, please let me know. Thanks, SJ > > > > > So I'd argue this patch seems not really needed, sorry. > > > > > > Thanks, > > SJ > > > > [...] >