From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 B14A079E4 for ; Fri, 22 Dec 2023 04:38:42 +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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Y5U4iH1T" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1d3a9b9634dso94015ad.0 for ; Thu, 21 Dec 2023 20:38:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1703219922; x=1703824722; darn=vger.kernel.org; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=GyedNlCjbE+Q4bYx68krhasQrfrx8EhiaTfO6LvPL04=; b=Y5U4iH1THZn/kJmXH69IG8NL7xbHR+tOnRv5VqNnIA3pw1RYtpGq7pQzj8+bn0W7G6 AyZDcRfWC2Xg1KYFnb+MpgtEAwaGOvi6L1Db0CMc84n7gTRJXu6VYu3R494hAJKgV3qC 7F9aYM0nrvdSO8aMWIc3rTGq1XjDYroi5/DGpozG7Gu91CIWTksLE6XF38S3I5n1zFbm 7KtvLhAayfQMrV/KsRIEGDovY3RUoDPfa/eMYBSSghxom6rPROmccyO7DJkXBzRCswoX NlcIK3ObGdlcbC2j7p4ki8oMTzE3y17PZSyk0mNl2oN/MCc5XaqvB1HNQxT2ZGsdkarP ZEjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703219922; x=1703824722; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GyedNlCjbE+Q4bYx68krhasQrfrx8EhiaTfO6LvPL04=; b=pVnmK64fs5jXImvU3cDiwNJhJTJkRrwW+89jyDbtPy1XTCiMVU7yw8xXsZSTgrgbUe f5GzN70ptCyVUExrj+Fmw0a9iUT9v/30mu/koTi4nXihjmf1Z4xFdwgjg2U5ADSF3lpH VKw6fgOzrVoyRIw3Doqbu/ey7CRa96jbMlxxT8lqXV2vHWfvdD/NPnoLQAFqREtF787g OZ6ERsjMlP9wdXs3Qzo2aKMgpiz+QdF/d4s5TwE4SbIHnppoRA19fntf3D6oKJoKXDec bYD5p8sahfGl4dBvG1xQ+2PUbCnR0o8qJ1Ss5A+QDbCSiRxVhsPEDMLXinpffhPxCJ6G 8ejw== X-Gm-Message-State: AOJu0YxOYL1uI89UZhf1AjEOH7lS4Tl3gu8spzbsrak98cJ+Tn9a+OD7 F7jQTUhc4Ttqp8IKjBNCLYBUZY2eg0yr X-Google-Smtp-Source: AGHT+IGi06u5ImNRJFBga9p7VnAPha1sQjY12WynAwodGPZhh60I1bpfyFTprcdcFoDzb89iYeB4Vw== X-Received: by 2002:a17:903:18c:b0:1d4:1430:139f with SMTP id z12-20020a170903018c00b001d41430139fmr58061plg.25.1703219921743; Thu, 21 Dec 2023 20:38:41 -0800 (PST) Received: from [2620:0:1008:15:184:1476:510:6ea1] ([2620:0:1008:15:184:1476:510:6ea1]) by smtp.gmail.com with ESMTPSA id ei8-20020a17090ae54800b0028bd9f88576sm2626083pjb.26.2023.12.21.20.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 20:38:41 -0800 (PST) Date: Thu, 21 Dec 2023 20:38:40 -0800 (PST) From: David Rientjes To: Dan Schatzberg cc: Johannes Weiner , Roman Gushchin , Yosry Ahmed , Huan Yang , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Tejun Heo , Zefan Li , Jonathan Corbet , Michal Hocko , Shakeel Butt , Muchun Song , Andrew Morton , Kefeng Wang , SeongJae Park , "Vishal Moola (Oracle)" , Nhat Pham , Yue Zhao Subject: Re: [PATCH v5 2/2] mm: add swapiness= arg to memory.reclaim In-Reply-To: <20231220152653.3273778-3-schatzberg.dan@gmail.com> Message-ID: References: <20231220152653.3273778-1-schatzberg.dan@gmail.com> <20231220152653.3273778-3-schatzberg.dan@gmail.com> Precedence: bulk X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII On Wed, 20 Dec 2023, Dan Schatzberg wrote: > Allow proactive reclaimers to submit an additional swappiness= > argument to memory.reclaim. This overrides the global or per-memcg > swappiness setting for that reclaim attempt. > > For example: > > echo "2M swappiness=0" > /sys/fs/cgroup/memory.reclaim > > will perform reclaim on the rootcg with a swappiness setting of 0 (no > swap) regardless of the vm.swappiness sysctl setting. > > Userspace proactive reclaimers use the memory.reclaim interface to > trigger reclaim. The memory.reclaim interface does not allow for any way > to effect the balance of file vs anon during proactive reclaim. The only > approach is to adjust the vm.swappiness setting. However, there are a > few reasons we look to control the balance of file vs anon during > proactive reclaim, separately from reactive reclaim: > > * Swapout should be limited to manage SSD write endurance. In near-OOM > situations we are fine with lots of swap-out to avoid OOMs. As these are > typically rare events, they have relatively little impact on write > endurance. However, proactive reclaim runs continuously and so its > impact on SSD write endurance is more significant. Therefore it is > desireable to control swap-out for proactive reclaim separately from > reactive reclaim > > * Some userspace OOM killers like systemd-oomd[1] support OOM killing on > swap exhaustion. This makes sense if the swap exhaustion is triggered > due to reactive reclaim but less so if it is triggered due to proactive > reclaim (e.g. one could see OOMs when free memory is ample but anon is > just particularly cold). Therefore, it's desireable to have proactive > reclaim reduce or stop swap-out before the threshold at which OOM > killing occurs. > > In the case of Meta's Senpai proactive reclaimer, we adjust > vm.swappiness before writes to memory.reclaim[2]. This has been in > production for nearly two years and has addressed our needs to control > proactive vs reactive reclaim behavior but is still not ideal for a > number of reasons: > > * vm.swappiness is a global setting, adjusting it can race/interfere > with other system administration that wishes to control vm.swappiness. > In our case, we need to disable Senpai before adjusting vm.swappiness. > > * vm.swappiness is stateful - so a crash or restart of Senpai can leave > a misconfigured setting. This requires some additional management to > record the "desired" setting and ensure Senpai always adjusts to it. > > With this patch, we avoid these downsides of adjusting vm.swappiness > globally. > > [1]https://www.freedesktop.org/software/systemd/man/latest/systemd-oomd.service.html > [2]https://github.com/facebookincubator/oomd/blob/main/src/oomd/plugins/Senpai.cpp#L585-L598 > > Signed-off-by: Dan Schatzberg Acked-by: David Rientjes