Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6627679rwb; Mon, 5 Dec 2022 15:25:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf73wJkwqIaJvpZyLItkoumV2V6ArbW+hV+PfBmKgu9ikKRJZfeMqdz+Y0qx5w3CGugucJPj X-Received: by 2002:a17:906:8547:b0:7b4:ae8f:c61 with SMTP id h7-20020a170906854700b007b4ae8f0c61mr62501697ejy.403.1670282719594; Mon, 05 Dec 2022 15:25:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670282719; cv=none; d=google.com; s=arc-20160816; b=vIXHCF2IeIhe5or7uj1p8b5Ovj+9nVDylkPdFuHNgo7/YUEvbk14lqivJMWcAsxI30 fGfzMSNvcq8bYDHj07k+FS+g2rhWQLRQjaamWWhDWN8P/kYTOzrq01W1sAyE8pVOz1oR kLx/FECwkhL+TN69VSAc2cBQkjvmd6Y6KCHSTJRvRrI0r/X6IDOOvc3Wur8HeRbPc12L 58sOHM5O7P9JzGUj+k6mabYgyDgMychRrl0NFO9D9ztOUGU96kiSF0ZA/SffUM3uFpBm zcXsh0q28fX5D1q1cCLuaeMtBluAavlBAeqJOCYftNEmTA+w/Z4BkrcNvu2nerynHSIS I3Og== 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=BxPh+NpHMUN/HmcXLWL1nAWoKwjEuFMlPI1MpSCeI9xPtxD6naBMqGY7E+dVcAo+SE Sz1Uw5ipHS3gzCAMK9zCuoaCX58yD6rPkGDkSfo/NRzdqscq2h9/s4TGvZT5ymUcMsyu SK96+dvuLugsaIVw6epIk4PjlMSi4jlvYLJXjHpOpMNsjUDbt6mCs8g0FeLl8Nsb2kT3 ek9v/CSJ7AzYj2kLFJRsFfIKs6g3Z74gecOmcqYtC5GQC3Uq55l+IgYMFlaDcrkBctQy p52NVzPHctFDd0zbutq4VUykUCd5RfSISbdMMAhqOSSPwYXTPLSjKk57uWOkByA4ArRb avTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Gkd9ZtOB; 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 ji11-20020a170907980b00b0073d6c0facdcsi13659207ejc.259.2022.12.05.15.25.01; Mon, 05 Dec 2022 15:25:19 -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=Gkd9ZtOB; 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 S232561AbiLEXIq (ORCPT + 79 others); Mon, 5 Dec 2022 18:08:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231694AbiLEXIj (ORCPT ); Mon, 5 Dec 2022 18:08:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2BA15592 for ; Mon, 5 Dec 2022 15:08:38 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 6995C614BF for ; Mon, 5 Dec 2022 23:08:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A9C9C43146; Mon, 5 Dec 2022 23:08:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670281717; bh=grt8f69Dz6AwyetZSMeMbFhewde1iaVMzadAT1LoRZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gkd9ZtOBsrsbXnQFw9/sbyQbOH93AK/MO5lZXVdWN9g0ZWQ8gEIX08NSzEl2o7mnd lEZcmZgk03/Bb1cA8Se81GMDzpz1rpO4pSs3dXeVGR3586qFm0ua28x7yTZUsiP1Jw XohFGfEmlDPWRNb7mRez4As0YcnWL2GTA6oEzH0/r13j4H0S6fl286ORTXbb9xxln0 BylJ/JsgTIFq56cYSPF0JSx3FT2kNU+ZCefodS0dcW3vGVzIo0UWtL/hj1a6NmFXhH jxei4CFDcvbTrIf+gco38m0sYnHgXATXdCmuX5WZyuV+UuBXuFRzw1X90uFhiu8G6H jlVIbQEwM991A== From: SeongJae Park To: Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 03/11] mm/damon/reclaim: add a parameter called skip_anon for avoiding anonymous pages reclamation Date: Mon, 5 Dec 2022 23:08:22 +0000 Message-Id: <20221205230830.144349-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221205230830.144349-1-sj@kernel.org> References: <20221205230830.144349-1-sj@kernel.org> MIME-Version: 1.0 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 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 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, -- 2.25.1