Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7445336rdb; Wed, 3 Jan 2024 17:08:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZK7I9WjhcvtQvLjzU1Kq74BWmED3po93DhmKAQBFISD6gtflCNuq5i8SbBabOKpt3BY5Q X-Received: by 2002:a05:622a:1105:b0:428:34c5:491e with SMTP id e5-20020a05622a110500b0042834c5491emr2990520qty.23.1704330480584; Wed, 03 Jan 2024 17:08:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704330480; cv=none; d=google.com; s=arc-20160816; b=PZanqXx+lIXVaMAIU2oRZdwGdmP8jVsnb1kT24U368R5Bt32Y3n5SVdgDdW6hLL21y YWGnzD0zZAYeaDAlU7QI/THy8oRsoysfmmGX9VZyPlidi/jyJpO7gNnum/Jpnumrzt5A ZzffTMuzNtW0vrxnYVqk1+fsWBrKYEHi8HC49tbtV6hSVF3EiajuWWC5OrSoFtSgWbEc ma7l9G9tgn+5OKZjYHs1zp8zWqKqIEz5eQq+KNh6jO0UHKcxNPOSUomQovGyNiB5Brlk MrE30eS7qwSWuucuDkU08venYdj4sZ3fQ6DMEDahnEk2ZkBXjn6PSt4QbglvGBUqd0O1 ehag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7m+H9c4RKS2/XKxU5xixK4qV5pHJenGZp2+iHHRxZ8I=; fh=AoC/SSJMQ8qVLTa+UcBDWv5vZiaP/SY3D1gKcvjzTnI=; b=NBE0B16VIdJOu20WG8h+gtHNqR2u6gWHrRltAujUwmcvXE6zaWlEYnL9BvW2LTaw7n 5OC23ZJGscj2hRHgMOKHuApuRFjQgNPAkVK5RdetTPJ1xKqlCbbxrztgNEV1ZBSsgoqI 00yX6NmFLkpH0ML43a+fjseZeJB/UP4wzVNa4Qq/CUwG/z6NlTChedoHuTX/CEVpdYv5 YqQDcj8codw8zZBdT52tzJDyJEWtG8A7bNXsViXf14j/jJGyxVCjVAUN7XAzK7c7EidD SZ0CsXLUAu5uPsguj8LRNI/Dtb3H0F8omfC6V3eoh/IoN8gDhUOKBjabX0KwhZL0ESAz vzXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=R8BOTk86; spf=pass (google.com: domain of linux-kernel+bounces-16172-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16172-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d13-20020ac85d8d000000b0041092f38eeasi30289656qtx.434.2024.01.03.17.08.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 17:08:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16172-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=R8BOTk86; spf=pass (google.com: domain of linux-kernel+bounces-16172-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16172-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 517631C24A3A for ; Thu, 4 Jan 2024 01:08:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 64F9A4C60; Thu, 4 Jan 2024 01:07:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="R8BOTk86" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41B77442E for ; Thu, 4 Jan 2024 01:07:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-il1-f179.google.com with SMTP id e9e14a558f8ab-35ffc781b3bso24675ab.1 for ; Wed, 03 Jan 2024 17:07:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704330470; x=1704935270; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=7m+H9c4RKS2/XKxU5xixK4qV5pHJenGZp2+iHHRxZ8I=; b=R8BOTk86mUfgzMbzcUmvPBCCI3FOzdXj16BvlPiBHZCbR06gmypwpAa85juK7wdmgE Y4QbYdXP7gUQ6Zbr4ismQqYX4uWEnf2W+1oDnihdIgWPmIOWfT+yjfgQD6QcEs54jSKD 8SedaBQddx6rqtyVDKHegjRuW6q/7NGd/gFmLf9nIlVHvg7g5uI/JE+Z81grJmTLOvqF 1t+YuP0OY98y9I5re6kgPD85Cesw07kDK0WAwtC+a895N0LCEmPZm3LbXTLRLJqCBlae ltpp4NvhVadI8EoJgd9nP8xal/cyudzaBZLcfqM0VJ/V7gAhW7+TGFhy/1FhBAQX6pst qhzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704330470; x=1704935270; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=7m+H9c4RKS2/XKxU5xixK4qV5pHJenGZp2+iHHRxZ8I=; b=A8nt3fYmHl9Nftw6AxiT3rs4LPHBhMMa5jFiY+jpF3PtxNS0yPzws6mGHQn1cEKg2A y75UeTDLiX1L78RyzoMWOhe/fL8NcZjiRxGnFlsZmLZYExi8ViBUzrPJnpmY9vb6W/Fx /mdD8WewmkltzhOc1nnnCJmGZg2GYA3VObNEDXrUeVxRXUMii4t9sGLoEVy6+kEnXG/t JcDqFj1qZu+Bsd+QFA32lOTt0Y7ezpVG806U/appgAsqhzhHQZgGf5tZKmUTIhZqCWbX 4g7PbFcc+uzq5yseIy8ag2BskW5ub4N3aubeUs9dYaG5e/6jvuIYh0nWWT5QSbdMRJtT v9Mg== X-Gm-Message-State: AOJu0YwB+tWRI5ZY9Q+miyOXQTy1hmI9/lBquQHpLtCtiNu+MmVY58Jo cC/BEXepp60njNUzGtc8wuj/Sxea29by X-Received: by 2002:a92:cccf:0:b0:360:495:20e9 with SMTP id u15-20020a92cccf000000b00360049520e9mr302785ilq.8.1704330470029; Wed, 03 Jan 2024 17:07:50 -0800 (PST) Received: from google.com ([100.64.188.49]) by smtp.gmail.com with ESMTPSA id k11-20020a02cccb000000b0046ddbd7b67fsm760485jaq.93.2024.01.03.17.07.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 17:07:49 -0800 (PST) Date: Wed, 3 Jan 2024 18:07:43 -0700 From: Yu Zhao To: Dan Schatzberg Cc: Andrew Morton , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Yosry Ahmed , Michal Hocko , David Rientjes , Chris Li , Tejun Heo , Zefan Li , Johannes Weiner , Jonathan Corbet , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , David Hildenbrand , Matthew Wilcox , Kefeng Wang , Yue Zhao , Hugh Dickins Subject: Re: [PATCH v6 2/2] mm: add swapiness= arg to memory.reclaim Message-ID: References: <20240103164841.2800183-1-schatzberg.dan@gmail.com> <20240103164841.2800183-3-schatzberg.dan@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Jan 03, 2024 at 01:19:59PM -0500, Dan Schatzberg wrote: > On Wed, Jan 03, 2024 at 10:19:40AM -0700, Yu Zhao wrote: > [...] > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > > index d91963e2d47f..394e0dd46b2e 100644 > > > --- a/mm/vmscan.c > > > +++ b/mm/vmscan.c > > > @@ -92,6 +92,11 @@ struct scan_control { > > > unsigned long anon_cost; > > > unsigned long file_cost; > > > > > > +#ifdef CONFIG_MEMCG > > > + /* Swappiness value for proactive reclaim. Always use sc_swappiness()! */ > > > + int *proactive_swappiness; > > > +#endif > > > > Why is proactive_swappiness still a pointer? The whole point of the > > previous conversation is that sc->proactive can tell whether > > sc->swappiness is valid or not, and that's less awkward than using a > > pointer. > > It's the same reason as before - zero initialization ensures that the > pointer is NULL which tells us if it's valid or not. Proactive reclaim > might not set swappiness and you need to distinguish swappiness of 0 > and not-set. See this discussion with Michal: > > https://lore.kernel.org/linux-mm/ZZUizpTWOt3gNeqR@tiehlicka/ static ssize_t memory_reclaim(struct kernfs_open_file *of, char *buf, size_t nbytes, loff_t off) { struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of)); unsigned int nr_retries = MAX_RECLAIM_RETRIES; unsigned long nr_to_reclaim, nr_reclaimed = 0; + int swappiness = -1; ... reclaimed = try_to_free_mem_cgroup_pages(memcg, min(nr_to_reclaim - nr_reclaimed, SWAP_CLUSTER_MAX), - GFP_KERNEL, reclaim_options); + GFP_KERNEL, reclaim_options, + swappiness); ... +static int sc_swappiness(struct scan_control *sc, struct mem_cgroup *memcg) +{ + return sc->proactive && sc->proactive_swappiness > -1 ? + sc->proactive_swappiness : mem_cgroup_swappiness(memcg); +}