From patchwork Sat Sep 10 16:55:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: haoxin X-Patchwork-Id: 12972583 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10CE6ECAAD3 for ; Sat, 10 Sep 2022 16:55:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 053DE6B0071; Sat, 10 Sep 2022 12:55:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 002D76B0072; Sat, 10 Sep 2022 12:55:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E342A8D0001; Sat, 10 Sep 2022 12:55:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D15126B0071 for ; Sat, 10 Sep 2022 12:55:46 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9695816022F for ; Sat, 10 Sep 2022 16:55:46 +0000 (UTC) X-FDA: 79896777492.06.2B86179 Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by imf09.hostedemail.com (Postfix) with ESMTP id A3A1E1400A2 for ; Sat, 10 Sep 2022 16:55:44 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VPFllr8_1662828937; Received: from localhost.localdomain(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0VPFllr8_1662828937) by smtp.aliyun-inc.com; Sun, 11 Sep 2022 00:55:39 +0800 From: Xin Hao To: sj@kernel.org Cc: akpm@linux-foundation.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, xhao@linux.alibaba.com Subject: [PATCH] mm/damon: simplify scheme create in damon_lru_sort_apply_parameters Date: Sun, 11 Sep 2022 00:55:36 +0800 Message-Id: <20220910165536.99023-1-xhao@linux.alibaba.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662828946; a=rsa-sha256; cv=none; b=3pXS6LqdaooGq+7BMYDt3GSbS2Q1VLKMVCA5SXIi03qd0HsZZr2mSOBiXxFrHcuVYvyNPp sU5wbwND5/O1S28NOCNRIXmN6C3qZkyNtl3jwz840fz+XGju1P9RFfGpyyDIbuM5wOFFMZ AOPfi81Eo3GYTiU8Do//iEi9yMJtMds= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.42 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662828946; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=8ZUGckuUa+h5j9VOoke3Raff4YIB0CyumbEqUqOYyG0=; b=Fcy31TJnXWoXDWDfsqR1wz6qvUN/a5Q9qFLRWNhPa9/1qKzCGzMU6sta2zUKJKvuWTP6wp 4KLgeHKR4VuEj3+eQMXQCxJNpUmBBEB/6IZY2Oz69N0KbVe3Wp/bIq0uaCdQstUxoohv1u oOcayv3Btd7YdeubEHMx10PHzegzaoI= Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.42 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Rspam-User: X-Stat-Signature: s5ro4wrsju849nd1amqejpfic5f4xg5c X-Rspamd-Queue-Id: A3A1E1400A2 X-Rspamd-Server: rspam01 X-HE-Tag: 1662828944-659266 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In damon_lru_sort_apply_parameters(), we can use damon_set_schemes() to replace the way of creating the first 'scheme' in original code, this makes the code look cleaner. Signed-off-by: Xin Hao Reported-by: kernel test robot --- mm/damon/lru_sort.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) -- 2.31.0 diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index b8ec52739e0f..b581b7b76fb2 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -350,17 +350,15 @@ static int damon_lru_sort_apply_parameters(void) if (err) return err; - /* free previously set schemes */ - damon_for_each_scheme_safe(scheme, next_scheme, ctx) - damon_destroy_scheme(scheme); - /* aggr_interval / sample_interval is the maximum nr_accesses */ hot_thres = aggr_interval / sample_interval * hot_thres_access_freq / 1000; scheme = damon_lru_sort_new_hot_scheme(hot_thres); if (!scheme) return -ENOMEM; - damon_add_scheme(ctx, scheme); + err = damon_set_schemes(ctx, &scheme, 1); + if (err) + return err; cold_thres = cold_min_age / aggr_interval; scheme = damon_lru_sort_new_cold_scheme(cold_thres);