Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp6108499rdb; Mon, 18 Sep 2023 04:43:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFC6+Nf5ryhkkj5/sTs7ESntkR/ODt2JVE3ITCbm5VDSxN4sECHrq1+ts17AnF6jizPPyD/ X-Received: by 2002:a05:6808:2a81:b0:3a7:ae8:79d9 with SMTP id fc1-20020a0568082a8100b003a70ae879d9mr8719606oib.43.1695037387034; Mon, 18 Sep 2023 04:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695037386; cv=none; d=google.com; s=arc-20160816; b=K3oVPXvDSNrBCv+jEMzfPhmV5VUsevDRtS5njIJc6cD4kP3H+TO17YPEotQCn1RKKN hvsH5aGgurqudgp0OC1mUeMD1u6G3NYBGpY4x5raMKt63IAa/YdFQXyRAioRJhAPrelE VBJMd2TgkJmDR1aaJhdMGibR3fADv4u4/ZTWY30jviMMYsIQshc1XX1WE++IyNQVATvN H9qfGbAFpB6F+YmDjHKwZzV2+/W6go4PEI6HpJb/Sep53q4p2UDPJ6AgFDv+LaJJyM7X hYb2t2AMvQpzFw67E+zmMbXAd2Tw+kZQB6m9ASaZZ+2ZYXSAC9cGp/DkEs4FpcT2gwVU AwnQ== 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=xayNds7XNkHYeFTLg/iCTI3hZD5HT0JnDFPzYYCgfRE=; fh=G5pidaA2Djiogqgn3xcxAlac6SUxKU44/yuuARWOJI4=; b=HPs7zavcM9MqEF9e7L23WXmLaa62abQRnboFj53DmE+SKWoysej+UOVoWm3tPEc9bY IaMR8HYZOZnhqRPofGpjG/phKOU3Kh9zt7LH/aDb0JfB55Cb5m8UG5E679+nWe+yUOKT wrGDa4VnrvtAnkMmL5WF1IDlOPSNQyddXY2eRjrL3gQubOy+cB9RXHN4rmtc0VUJXmt/ VHFCkkAWV3qcAHoTPJyMMQ2AgL9eYkopkrPI3jykyet+ii39qmfc5gzICMjuIRVACbhg XY5SDri0Es+CCUDWOc6zBl93GOt51lbOBldnqGVteA8+kBtzsNkGOuX7fLhyMrzip3dh 8P0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gvNvbnWd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id e66-20020a636945000000b005774c90073asi7660183pgc.320.2023.09.18.04.43.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 04:43:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gvNvbnWd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0731280C056E; Mon, 18 Sep 2023 04:12:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241424AbjIRLL4 (ORCPT + 99 others); Mon, 18 Sep 2023 07:11:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241417AbjIRLLZ (ORCPT ); Mon, 18 Sep 2023 07:11:25 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDE2010A for ; Mon, 18 Sep 2023 04:11:09 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8813C433C7; Mon, 18 Sep 2023 11:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695035469; bh=ex+golzLi755Q7c5GOzK8ML6NZjydWxv20lWvmv3MMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gvNvbnWdRbTuraWZa+yNPIF7xHuuFPk5aPVI1hEQBDTXoB3FPJgE5jOHvHtp+b4Im fRwZTZittY0g8uEXwUV6SovcdsD7alarLUAgyDqGasuPBPlf8oRruwcvscwwcInDbx c64577bBuOABQ4A/s+2HamKLkPaMaBHn+zWWi7CTLtYDlcmefEv0lrfae/ZmdRRYV8 k5uIB2umdbYEWdT2YNQUeJhLprEsZAKqR4CHYNDPUaNOGtXrl1OqZXdUgFyV/0lYY8 TloiNrZAudiKwcEK5RrMfXHCIgMPur5EWHwWFkiHFyLTJ/4YOLhmIDa46PuEwIazOt o8U72h6ghLjqA== From: SeongJae Park To: Huan Yang Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev (open list:DATA ACCESS MONITOR), linux-mm@kvack.org (open list:DATA ACCESS MONITOR), linux-kernel@vger.kernel.org (open list), opensource.kernel@vivo.com Subject: Re: [PATCH] mm/damon/core: remove unnecessary si_meminfo invoke. Date: Mon, 18 Sep 2023 11:11:07 +0000 Message-Id: <20230918111107.85008-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230918094934.18123-1-link@vivo.com> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 18 Sep 2023 04:12:34 -0700 (PDT) Hi Huan, On Mon, 18 Sep 2023 17:49:34 +0800 Huan Yang wrote: > si_meminfo() will read and assign more info not just free/ram pages. Nice catch :) > For just DAMOS_WMARK_FREE_MEM_RATE use, only get free and ram pages > is ok to save cpu. > > Signed-off-by: Huan Yang > --- > mm/damon/core.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/mm/damon/core.c b/mm/damon/core.c > index bcd2bd9d6c10..1cddee9ae73b 100644 > --- a/mm/damon/core.c > +++ b/mm/damon/core.c > @@ -1278,14 +1278,16 @@ static bool kdamond_need_stop(struct damon_ctx *ctx) > return true; > } > > -static unsigned long damos_wmark_metric_value(enum damos_wmark_metric metric) > +static unsigned long __damons_get_wmark_free_mem_rate(void) Nit. s/damons/damos/ would look more consistently, in my opinion? > { > - struct sysinfo i; > + return global_zone_page_state(NR_FREE_PAGES) * 1000 / totalram_pages(); > +} > > +static unsigned long damos_wmark_metric_value(enum damos_wmark_metric metric) > +{ > switch (metric) { > case DAMOS_WMARK_FREE_MEM_RATE: > - si_meminfo(&i); > - return i.freeram * 1000 / i.totalram; > + return __damons_get_wmark_free_mem_rate(); Since __damons_get_wmark_free_mem_rate() is just one line function and damos_wmark_metric_value() is the only user of the code, I think we could just writ the code here? > default: > break; > } > -- > 2.34.1 Thanks, SJ