From patchwork Wed Nov 30 20:09:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 27966 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1127926wrr; Wed, 30 Nov 2022 12:10:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Za9sP0q+5IfjUJ6Yyi98eXKknKCFo2RqSTICjMAXZ6EqsWlxoGpY+yg5epBlRel3rAkh8 X-Received: by 2002:a17:90a:9a98:b0:219:2f90:4fb3 with SMTP id e24-20020a17090a9a9800b002192f904fb3mr19105286pjp.109.1669839038957; Wed, 30 Nov 2022 12:10:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669839038; cv=none; d=google.com; s=arc-20160816; b=rYz0IWT+RTLjulDw1s/HPgsuZULfnGQVL+HuN6lUjIGaYyMPAwXaZONlXIno5EgmM4 IwPBDRuXvhY5zEUJI1LESOn1/Io6+Xf/YoAJm40dvZulE/Z5Xnmksrm2FvAZWopF+xQr DVfi1xDtfzjxUC49MKrcIoOTVw7+1YVa+LFHYHNCYUVtsctwtQMIwSw7dN/G3HFXw2s+ qQaJRwgDefqufldTMDiME5QF7n+s+9Gk5c0yt6Z79y5Strg3peApBQ4TqbVHhl6ZiAap k17Ejp1V2M7MP8V70zUbDlKvRPDO0JY0ca5DzQkX9jGG2YjwnuSu1OG9tffwbq1sTd59 MQ1g== 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=r3xyNreIJtEHO9foiiQtvJVmPt1q36n0JQLVr8U6gzI=; b=X7UjrejV1vM/39rDN+Fu89wNGYqLaJ4RvmivQWkbaFeyV+GU8O+bIWM8SeYW4VOUcQ BkPJMQS453RbfPIida4r5zbXXX40K2+pKFQSueuxB6NCCntZbywCoJyn6zdreYIoxHOZ BHhCpktbq/SWRX76g/cE9ANeR4PVlYh/ZkIG7zXonkU8h8AFNlUCLvrvS4lyXPIDTNCz 7a9/q5WU2z1XV03OvLm7B0L9kBMRbJikGCsoyX7xt5D5HFXW1/MTOLu8gD6cliIEE+hf RcdyD6+E/RP8rKTcj//k+nON6HSWl3cWgYXRXnGLDprRHgowdMbrZGzeYpL386Fpr1Lk zuOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WLNVlXze; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o15-20020a170902d4cf00b00186b697ec66si2215149plg.399.2022.11.30.12.10.24; Wed, 30 Nov 2022 12:10:38 -0800 (PST) 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=WLNVlXze; 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 S229876AbiK3UKA (ORCPT + 99 others); Wed, 30 Nov 2022 15:10:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229816AbiK3UJq (ORCPT ); Wed, 30 Nov 2022 15:09:46 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCCD88C6A1 for ; Wed, 30 Nov 2022 12:09:45 -0800 (PST) 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 8681CB81CD9 for ; Wed, 30 Nov 2022 20:09:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4E89C43146; Wed, 30 Nov 2022 20:09:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669838983; bh=grt8f69Dz6AwyetZSMeMbFhewde1iaVMzadAT1LoRZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WLNVlXze66e6bJgKZEGO6XI9qKr/WWkt6nkzk1TBS/Zp1Ly0AijwDHo+ze1hiwAg8 IWldWCPVTjtow7pGt00n5zCRRKElawSyBxP+MSy8AZp7EjmkPhMyQa9tfE9qrQYQ8Y 5ERqWfkAUyirqLxgMNPSQ3kmrgyMEIrq9Qm7aJDQUiXLJQEI52w1/f21B2soeQUYtN OWALqy4zpatDyFmHUrVLOiWSqokxBiwwl0NylXbV4md41gQpUegL7x6yQswbiK2ZtB 8Zw46mBgzM5M42g+RpWukjcjOMYjgsei/DCOxhSOHXGQfogoPE724ciYkfcZladH5+ kdqd1DsjoGUWg== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 03/11] mm/damon/reclaim: add a parameter called skip_anon for avoiding anonymous pages reclamation Date: Wed, 30 Nov 2022 20:09:29 +0000 Message-Id: <20221130200937.118005-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221130200937.118005-1-sj@kernel.org> References: <20221130200937.118005-1-sj@kernel.org> MIME-Version: 1.0 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 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750953139738270093?= X-GMAIL-MSGID: =?utf-8?q?1750953139738270093?= In some cases, for example if users have confidence at anonymous pages management or the swap device is too slow, users would want to avoid DAMON_RECLAIM swapping the anonymous pages out. For such case, add yet another DAMON_RECLAIM parameter, namely 'skip_anon'. When it is set as 'Y', DAMON_RECLAIM will avoid reclaiming anonymous pages using a DAMOS filter. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index e82631f39481..648d2a85523a 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -98,6 +98,15 @@ module_param(monitor_region_start, ulong, 0600); static unsigned long monitor_region_end __read_mostly; module_param(monitor_region_end, ulong, 0600); +/* + * Skip anonymous pages reclamation. + * + * If this parameter is set as ``Y``, DAMON_RECLAIM does not reclaim anonymous + * pages. By default, ``N``. + */ +static bool skip_anon __read_mostly; +module_param(skip_anon, bool, 0600); + /* * PID of the DAMON thread * @@ -142,6 +151,7 @@ static struct damos *damon_reclaim_new_scheme(void) static int damon_reclaim_apply_parameters(void) { struct damos *scheme; + struct damos_filter *filter; int err = 0; err = damon_set_attrs(ctx, &damon_reclaim_mon_attrs); @@ -152,6 +162,15 @@ static int damon_reclaim_apply_parameters(void) scheme = damon_reclaim_new_scheme(); if (!scheme) return -ENOMEM; + if (skip_anon) { + filter = damos_new_filter(DAMOS_FILTER_TYPE_ANON, true); + if (!filter) { + /* Will be freed by next 'damon_set_schemes()' below */ + damon_destroy_scheme(scheme); + return -ENOMEM; + } + damos_add_filter(scheme, filter); + } damon_set_schemes(ctx, &scheme, 1); return damon_set_region_biggest_system_ram_default(target,