Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6852225rdb; Tue, 2 Jan 2024 16:28:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1+nmKjPCvAo8PFaAc+dmwYxk4wUnpPwboYbGRwoap+gEhRc/REg+WjksXtahdzRMySukP X-Received: by 2002:a05:6808:2389:b0:3bc:255e:1fa1 with SMTP id bp9-20020a056808238900b003bc255e1fa1mr232143oib.70.1704241687909; Tue, 02 Jan 2024 16:28:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704241687; cv=none; d=google.com; s=arc-20160816; b=YoD3I/xecVIIxd4edz2pR9EgYO1Y/hOVxyr4tf/bVB2S8y4QgK/3IhiQ4oLC6LCGt/ jYwfGdXggrCw5xOCJFiRGOIuf1zPCWSYzvDBzAyE1J151UN3OBvqbrLDiVmrtREA5NcE WWkL3ThxO5doSzQDY96/ge5CcVDssmIHOgZsTy8z9aT3+w68MxitEqHJDSNGwnnJ09eX fEA++vBRmv76tbkYRuKh/3OxHfjdjsZ7hl2dQQsnyfzAiK0TNam/jtFWOkKT41ZErbFV mjV/wHDiW1FTcGsLuVSgSQMwLgD9GZWTOtswpuK+Moumi0VGJfu4PoQZVJeHMtGdIfFe sVUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=4D/ScSo67diCtOm5/uS067tATdpuyW3M9IteQeNMCkw=; fh=xwUHAcblIzhNTankEvej/3kLZeeLU5LfFrnrmtZZ3+o=; b=OgPlbBcbh4BrTgKKqACazBB0xrkdaVX9UQssfdA7ElRH34OUVjpRHTame5828NK2DN Xux6F0PFb7TWpSl4gvyhb5IZ4scF4rR3mnyRgAXrPl4qG8e50wgVfdhWsc8R7yXPV4Dm Mm2dYYSOBpfJPSRfM/XvifoIpDH0LZ/cDGjMe1CuPWjI9nORFO9s/Bt0fh1t4PSaz/8V bhohHLvNlKLShkqW8HE+cgq9FAs56XFHbp6AHpDXzXhLn34yVjtLeJZ0HQrpejDb4sPi 3rRVMWEVF3kWiQx5NzR26YPDTALFUsqp1l5CkYAud2218CRbCZ7oXavrWUI03zH1vUWs cAkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=JqpSmB3i; spf=pass (google.com: domain of linux-kernel+bounces-14997-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14997-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 l13-20020a37f50d000000b00781e317772asi1190200qkk.344.2024.01.02.16.28.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 16:28:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14997-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=JqpSmB3i; spf=pass (google.com: domain of linux-kernel+bounces-14997-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14997-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 91F191C21A1D for ; Wed, 3 Jan 2024 00:28:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1419F654; Wed, 3 Jan 2024 00:28:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="JqpSmB3i" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 A3385362 for ; Wed, 3 Jan 2024 00:27:57 +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-wm1-f54.google.com with SMTP id 5b1f17b1804b1-40d5097150fso11105e9.1 for ; Tue, 02 Jan 2024 16:27:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704241676; x=1704846476; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=4D/ScSo67diCtOm5/uS067tATdpuyW3M9IteQeNMCkw=; b=JqpSmB3i0ZnEz+ULTVT8IdFiudtV9vFjgJ8aIWrR3anz0xnFIcQHtPVAMQwAomaHPa TCY4wZjvT35xB4UcEhH9ZIhDb+jWpChBHYkEK4jxxF3YfG3qEHxC2Zt1ce8g93Tr7UeL 0duLITVaAnY4Qr87ScwH8gzN447fTR8icJvqUphyUWriaeJfTQyGfw0TcIXMO1JsfRVg iioW2F9+au2bktirWFwNC500zpNy0FBDVcO1f32S6VlSbz0teRC7b42GmxAQ73GVCXl2 xxFT/lXbKPaybU985Y1LgCt+2Z5XroSQQu9JAhE+Oy1m0FZipHySMafdbXZnoToF0Wrr N66A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704241676; x=1704846476; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4D/ScSo67diCtOm5/uS067tATdpuyW3M9IteQeNMCkw=; b=SKOhXSuvq+N0JBa2OgxMeAzHcdaPvXYyPlGXeTcZJZm/tIiHqfcAZ+2S9POsOP+QRV uB8aYE25X8Z280B4kduzCJMamj61V2/NzYH6vpLfa6gIXrrvFAQO5jLWOTWFEqKuK6bw rxpfNAkz83FdHW6EV0b7jL/EMhQHGbuRY/1ESWs0jMfmgJiWKT5UDCvNzn3W693Cjy2q giaticCSEmRz+FR/aY3yvLmPM0i6TnJ05PohFuNLHTaw4cDeptMSgVWpU257EDDnEmtP 2gNgImPf/KS4yZzSl8q57v/iPzqB4OTAbnXFSEppGfgvdIwMR4uUyJtDgYVtyQIYTC99 iouw== X-Gm-Message-State: AOJu0Yz7/UNi05A9aGSPrpYyW4ls4hObxh95lfDquCoCvibArLjmVoq3 ioaBEjSCECSKjnFBRE46NE2ZfyUuQukdDz10fFDrlzerbLSXAGF+ZVMCZZeD8ybPCdg= X-Received: by 2002:a05:600c:354f:b0:40d:87df:92ca with SMTP id i15-20020a05600c354f00b0040d87df92camr17552wmq.3.1704241675743; Tue, 02 Jan 2024 16:27:55 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231220152653.3273778-1-schatzberg.dan@gmail.com> <20231220152653.3273778-3-schatzberg.dan@gmail.com> In-Reply-To: From: Yu Zhao Date: Tue, 2 Jan 2024 17:27:18 -0700 Message-ID: Subject: Re: [PATCH v5 2/2] mm: add swapiness= arg to memory.reclaim 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jan 2, 2024 at 8:21=E2=80=AFAM Dan Schatzberg wrote: > > Hi Yu Zhao, > > Thanks for the feedback, sorry for the delayed response. > > On Thu, Dec 21, 2023 at 10:31:59PM -0700, Yu Zhao wrote: > > On Wed, Dec 20, 2023 at 8:27=E2=80=AFAM Dan Schatzberg wrote: > > > > > > ... > > > > The cover letter says: > > "Previously, this exact interface addition was proposed by Yosry[3]." > > > > So I think it should be acknowledged with a Suggested-by, based on: > > "A Suggested-by: tag indicates that the patch idea is suggested by the > > person named and ensures credit to the person for the idea." > > from > > https://docs.kernel.org/process/submitting-patches.html#using-reported-= by-tested-by-reviewed-by-suggested-by-and-fixes > > Sure, will do. > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > > index d91963e2d47f..aa5666842c49 100644 > > > --- a/mm/vmscan.c > > > +++ b/mm/vmscan.c > > > @@ -92,6 +92,9 @@ struct scan_control { > > > unsigned long anon_cost; > > > unsigned long file_cost; > > > > > > + /* Swappiness value for reclaim. NULL will fall back to per-m= emcg/global value */ > > > + int *swappiness; > > > > Using a pointer to indicate whether the type it points to is > > overridden isn't really a good practice. > > > > A better alternative was suggested during the v2: > > "Perhaps the negative to avoid unnecessary dereferences." > > https://lore.kernel.org/linux-mm/dhhjw4h22q4ngwtxmhuyifv32zjd6z2relrcjg= nxsw6zys3mod@o6dh5dy53ae3/ > > I did have a couple versions with a negative but it creates > initialization issues where every instantiation of scan_control needs > to make sure to initialize swappiness or else it will behave as if > swappiness is 0. That's pretty error prone so using the pointer seemed > the better approach. > > > Since only proactive reclaim can override swappiness, meaning it only > > happens if sc->proactive is true, I think the best way to make it work > > without spending much effort is create a helper as Michal suggest but > > it should look like: > > > > sc_swappiness() > > { > > return sc->proactive ? sc->swappiness : mem_cgroup_swappiness(memcg); > > } > > > > In this patchset, sc->swappiness really means > > sc->proactive_swappiness. So it should be renamed accordingly. > > Helper aside, I disagree with this point about coupling with the > proactive flag. Sure. But I would like to hear a *concrete* counterexample. > The fact that the only user currently is proactive > reclaim Yes, that's a fact, and we should make the decision based on the current known facts. > doesn't imply to me that the interface (in scan_control) > should be coupled to the use-case. Future always has its uncertainty which I would not worry so much about. > It's easier to reason about a > swappiness field that overrides swappiness for all scans that set it > regardless of the users. For example? And how likely would that happen in the next few years?