Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7449607rdb; Wed, 3 Jan 2024 17:18:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdYCuDbvpzc9fRGNCdUCDDyJ4EMovDrhq1Thkb20idgulIeStVP6rcHYKQ2QSSzUYXpgZI X-Received: by 2002:a05:6e02:214f:b0:360:2ff:4591 with SMTP id d15-20020a056e02214f00b0036002ff4591mr22192523ilv.98.1704331114266; Wed, 03 Jan 2024 17:18:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704331114; cv=none; d=google.com; s=arc-20160816; b=g2p0x+YPb88rmDq9fVibqxrXCffejsUAOd8auSER+88f2xjBU/wY6Nt+K8EJ2af2JL N1jLhE2QStDhWqRSoiqMeE67zObddg3AnzXWADYYVR+PAOhom4R+G2nO3NJ4mIfg8lzP Vr0JakU5NpCDKMaDPPw0BJmKhcalEh8bJAnBlBcKHvNugvVIgwU2AAl+8POR7fb8Xxsv 2c1T7qA00YZ6ThbSHCfMkH1dUJ0JBiSpEl4hE+zi7JQ9cNDgftXxdTCwOfv2I9viC06v YCiXAyzO1jBaCGgQFJUczZp1/HmmNyDlvd59zDCtsAWCK42gmtcCLwLkk7Z61IwIx1bA vYZg== 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=+eOihVzL+EVjsPhR8JjZLVk3UHy9SeIcu5m/iOFaAv0=; fh=AoC/SSJMQ8qVLTa+UcBDWv5vZiaP/SY3D1gKcvjzTnI=; b=gvCkJ+IcPYw72InNg10oWWpYqaZu3lOsXUPoXi1F64wGUBgbAM+6lWFkUeHfFs8Amr ZI5mu1P+zBPVK8eD3OEuJfwXzWfJcoOVD/0y5Hkt3spMV+/1Le0cPlcMviUcZirM/A5O Wov2IwIm1GhcaWOWnuHkGC8iBD/lNOUvHLU7IXzTcz9KV+8XB/cVfTZo1iMcf5y2OM3N CYLDg3kW/XMdzItgAmzEao2T4D0dAFbIjrrWBlIMHEPh/B+iEvAO7vCrhoQ55t18rlNe 0YpBISdJBvPwhKr1XoII3vbqgUp7eZGnTv5QXXUrAA8tHBn046EKs9pcHOk1qVucPLic GXAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=tLgBSnCT; spf=pass (google.com: domain of linux-kernel+bounces-16175-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16175-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c7-20020a6566c7000000b005ce1968c4cfsi17001175pgw.526.2024.01.03.17.18.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 17:18:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16175-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=tLgBSnCT; spf=pass (google.com: domain of linux-kernel+bounces-16175-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16175-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id EBE11288200 for ; Thu, 4 Jan 2024 01:18:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 32DEE15C8; Thu, 4 Jan 2024 01:18:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tLgBSnCT" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (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 D937EA2A for ; Thu, 4 Jan 2024 01:18:23 +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-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-55679552710so3237a12.1 for ; Wed, 03 Jan 2024 17:18:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704331102; x=1704935902; 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=+eOihVzL+EVjsPhR8JjZLVk3UHy9SeIcu5m/iOFaAv0=; b=tLgBSnCTFWUrfSu+3Z61hCZ3Zesj0TDji1cH007BaCsdaQAgEnLOtGtr3WDEOtacjz oi4F6/ZuXSZ7/aBvcdY4l9P5MLBiS6k9lMy0yXH9r2ygQnczljbQUAOuIcn8nKmgZPvt hHI8hcxfdmoKR4JbW/3wgTYnZckjT4OQHbXqPJrM5Rxefnny8wx+8Z8YAE6pw6tqzUrI vON5y+VA1ozp9TNr2fAeyFzuElKQePxetOizGqFZ6rsYQjgxeIaKbNI8pySckNNX/y8v 793LN79BJQnmTf96iNe9xMhvEsb3UUX4ZOCOrIKIhgrUoJqn/0+oWlnbGJNDtpEBoEsG zP5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704331102; x=1704935902; 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=+eOihVzL+EVjsPhR8JjZLVk3UHy9SeIcu5m/iOFaAv0=; b=wbs17jtMpNkgOpQos1qgWio7Wn4QhpC99gm4wFiXd91RJTV01JlceYU5JU/FLdptBl 8NVGAIM1mrWE/tGlN3tXuo7gH1n9ftcqk4ZaeTJiCJusMj9niZLqIK1k/iZBWOss1CyK ltfUZOGw+VIlAZKR7/FaUJKT/yUQDH1ws/8+Bbt5WnDpdP2sMT3nqqjfmNYALaMoPxfF cMjjVIDtRWg0zET5M9txUxm+TM5EQbvA9MPa9X+MedMAAeYoqJ9utU2DpoG0CWrp7vpJ TSF9Sv62jcNmQFvfE03avvjj6lk9g/QF/k4+bLThKznF+nu3GPrl44Nzon+gilk8DPmV ZcoA== X-Gm-Message-State: AOJu0Yw4M/qg7GaubSHMWcf7AOjoj1NRAB2a3E1YIaJvC3fVaPHvVayt 4bxNe95GqEMGdJ76ejOnZErc5c1TU7K+/0mNp7y/JoiWsKqR X-Received: by 2002:aa7:d412:0:b0:557:15d:b784 with SMTP id z18-20020aa7d412000000b00557015db784mr16278edq.2.1704331102029; Wed, 03 Jan 2024 17:18:22 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240103164841.2800183-1-schatzberg.dan@gmail.com> <20240103164841.2800183-3-schatzberg.dan@gmail.com> In-Reply-To: From: Yu Zhao Date: Wed, 3 Jan 2024 18:17:44 -0700 Message-ID: Subject: Re: [PATCH v6 2/2] mm: add swapiness= arg to memory.reclaim 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jan 3, 2024 at 11:20=E2=80=AFAM 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_swap= piness()! */ > > > + 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/ > > > Also why the #ifdef here? I don't see the point for a small stack > > variable. Otherwise wouldn't we want to do this for sc->proactive as > > well? > > This was Michal's request and it feels similar to your rationale for > naming it proactive_swappiness - it's just restricting the interface > down to the only use-cases. I'd be fine with doing the same in > sc->proactive as a subsequent patch. > > See https://lore.kernel.org/linux-mm/ZZUhBoTNgL3AUK3f@tiehlicka/ Also regarding #ifdef, quoting Documentation/process/4.Coding.rst: "As a general rule, #ifdef use should be confined to header files whenever possible."