Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1196739rwb; Thu, 18 Aug 2022 22:03:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR43LkIKXWiQK1MccxBPMdQrc4lpcKag/6cMDpuEa5IsJrBGQtxD+WXG6H8RbORyETNIHpJR X-Received: by 2002:a65:6bce:0:b0:42a:35c9:ce40 with SMTP id e14-20020a656bce000000b0042a35c9ce40mr2276324pgw.430.1660885389629; Thu, 18 Aug 2022 22:03:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660885389; cv=none; d=google.com; s=arc-20160816; b=0BCVzNX+qZwXRp3NgOgNClnqO3Xg3pAul5VzCbnOiF+GKqhjub4bnNzmTuqmS67BfR vDueZgVVqsRK4wwpHUrgSEN/0EGupdyzt2T0Hv9IDmQNYIGBJF9sBYo3yaiV8Mh0mYXs L2lPuMDU81TxP1/ZLdUy38FqMZ1RPHjizFresa1sRoMPCYVR/o4M4seHiqoHFXg5BKaO 2XDd2tzoq8K4kKSuADkRTHIdu0mrJeBAbB9uO7dmg44sV85JNU1IqtQ6DscGA8XMhFzI tzuGa9Fr+ihJHh1VO49B5B/hwzWjQOpuSS24Xx4gxWGjSvspyvgy7l9nXy3bO5rU5SkU Xrlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=4Io4dj3C2E11Jl8WGfnog72XKbtwSqhrHkij01FChPU=; b=ZAgcA2SWaee1FnvGuOAz6CHsj5EvhnEBu5ohbTM3lGWwL8u9Aa+q3TdbPtNv7Vpb4p op5JxRdNnh6vjhT1wCdsEZWeccibj6I8S0svG6JiSxRqWrwZNWPkCdq1Qr2jL5rtBB8w nEA9+s4+vecXhQgKVhgSQZF9hSxx73sSMnhDmeeMXo8L9L+vMh7L3wNFlzdA9V3whqqp psf/yA8PIARPU76nipZNvitv2UPZ02wlwSSGH6gv5TYyaCLtY6XdJXltv2+M2/fiL585 1gpq4B/5MsQj+a5g2/TK4cp5ojxUdaSe1MMHY6PbW/AhzArW3mkrD/O1YmlaNYJpHgVb SJiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=o637CJLb; 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 q1-20020a170903204100b0016d473b903esi2761600pla.274.2022.08.18.22.02.59; Thu, 18 Aug 2022 22:03:09 -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=o637CJLb; 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 S1346240AbiHSEw0 (ORCPT + 99 others); Fri, 19 Aug 2022 00:52:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230077AbiHSEwZ (ORCPT ); Fri, 19 Aug 2022 00:52:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4363C6FC7 for ; Thu, 18 Aug 2022 21:52:23 -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 81903B82569 for ; Fri, 19 Aug 2022 04:52:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFE0FC433D6; Fri, 19 Aug 2022 04:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660884741; bh=pJsR9cSORbtbMymP+m9MvHTaCihfu9PX9SIGrheKZmw=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=o637CJLbB7MYcFkOf3iJtO6JpyRqT6H/5C4jnwxHKJxPdd8ZbddPbFkBo+Owi/yid XwC+pxHsAnOS7lk8zjN3euHYHC8T1TKW7LPAUZ1VzFVNxyvbUZAJX05KUIX0W0YcTe zutCqedwg2t+ZGWH9IsEbLWKOLFpN1rToKXWL/HQnGuaYzniR+aYnDlfZmHCLur+18 A9rskX98zkia9sdqJOJtmTL37CwwpUIM+SvRSc2c/jGT2ltJtUDi7TTj/YphImTOX8 jIOurMsYjVJ+aDtwDBX0ZqunReNK3u1gU4A8bAOyztUXzd72GBHUkzvSLwyU8v/DGR gBxt8Sf1ZFALQ== From: SeongJae Park To: haoxin 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: Thu, 18 Aug 2022 21:52:04 -0700 Message-Id: <20220819045204.21834-1-sj@kernel.org> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 In-Reply-To: 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 On Fri, 19 Aug 2022 10:47:58 +0800 haoxin wrote: > > 在 2022/8/19 上午10:28, SeongJae Park 写道: > > 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. > > Ok, Thank you for your detailed explain, just keep it. but there still > a problem in damon_lru_sort_apply_parameters > > if (!monitor_region_start && !monitor_region_end && > !get_monitoring_region(&monitor_region_start, > &monitor_region_end)) > > if (!monitor_region_start || !monitor_region_end || > !get_monitoring_region(&monitor_region_start, > &monitor_region_end)) > > the '&&' should fix to '||', anyone checks fail, it should return ? No. The code is for setting the monitoring region as the biggest System RAM resource only if the user didn't set both 'monitor_region_start' and 'monitor_region_end'. Thanks, SJ