Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6606964rdb; Tue, 2 Jan 2024 07:22:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IFzSUTLvNY9t1o7TbBkTxBrd4oLkDej7lhAfN8ymZZgGm/87uloRZRaixUpv8VzG+8wQI72 X-Received: by 2002:a05:6512:158f:b0:50e:69f0:3cda with SMTP id bp15-20020a056512158f00b0050e69f03cdamr9252262lfb.20.1704208926299; Tue, 02 Jan 2024 07:22:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704208926; cv=none; d=google.com; s=arc-20160816; b=XKU21AN53gO1TCWxApUlgRTmkTMje6MMdnYYclVrGMAbT1QAXZkt/nfg/Y0TE+UZQh OKO+RRLxDMAfoNk+OKUKNVYhuBOv5skLr7ZS2EQa30utfyDQOnBgXR7zT8CfLJqQ/r/Z wEFAnIvKpixX9s6TeZ9f1ufnwW/fl9PCCbEYmIIQfUEiD0x2/aJd0K44m3LHYXVWIwu2 o65atBtCW1Dl7SLuF5JitqsBV8QGlreE+Vu/vyag6wN+tqZkbbqr9mUQc9HoBD9NowUi Ue4i9g/WNRTCx0JrBhUGfL7Zeo1uw5WniQC8PlaEm2OlJPjkxIUYXfop8ZxRoUEatSjN YoZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8mXfI+Pa+/2538bxiWOCU5JAZ3tBBfS6VdnJQwfuuiQ=; fh=fNk/5JpakfTkhIfd2VJ0yyoQFwpkaEkqJ85kWnCTTtA=; b=gR+yGNgBAyuwdCUddswyN4NdFgKc3Zv7b0k2dCPfPD5M9FvVROmvgkgReg/Vxg4a3e W9avfQLZwgyXXlTGKWD+gFMBo21ch8Vo8yj7rD7ac8/leCMRb9ZJj2k8ajapnQpZ+S3h y8q4AnFKfpIrmaTPXOMsbX0kEJkI6B9If7rXUFR6Dgx8/jzMEZSJ33MAT4nWqxEZ3vF1 n8LSU0TUuFJ8PcTncQFJPo0Qoc/GacHqmW4iYGqh2f5M4odcqyDWfRMsvlMBNDZ4nhWp SRghZy/5xYek3mpN83syJQueVG8ONyYcW04CB6KqO00DlVhcCbHCqf4bb69+PcwP48Av hEbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OWGD1kOA; spf=pass (google.com: domain of linux-kernel+bounces-14556-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14556-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 23-20020a170906301700b00a26a6334a69si10334843ejz.246.2024.01.02.07.22.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 07:22:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14556-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OWGD1kOA; spf=pass (google.com: domain of linux-kernel+bounces-14556-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14556-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 097BD1F22DAE for ; Tue, 2 Jan 2024 15:22:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA51D14F65; Tue, 2 Jan 2024 15:21:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OWGD1kOA" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) (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 A8CCA14A82; Tue, 2 Jan 2024 15:21:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-3bbc648bed4so4365347b6e.3; Tue, 02 Jan 2024 07:21:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704208906; x=1704813706; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=8mXfI+Pa+/2538bxiWOCU5JAZ3tBBfS6VdnJQwfuuiQ=; b=OWGD1kOAup3AS7HYb/6FhsaHVh3Rc6wH7q8FYC5ChOToAKzlVCaxaQA7L8B5uiT2pI 0jKxOEgHKq0VCWg30VL/wCDQQk1y28FYrKNRKiRQNLspdMqdO0YP5xSG4XPit3M9q3fV SlwMtpvwV/w4OsBdGWvtLXlblqcFafpu4B1NfMGSgUAeuUDyDXnCca5/W/6fEeo2J3ve dyhZqxXyAt6BFq7qRZWhT/Npo1ZS9ghhlOUUhFhWzMAjwwjnc/s9nB7/szLknoglWhDs We4SSz7rJvnNvCiZVCCpiHSwLrbMCpe+M3tZk1WaPEHD1DUHYP85UzXL4rFiOkFSZh7Q VJyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704208906; x=1704813706; h=in-reply-to:content-transfer-encoding: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=8mXfI+Pa+/2538bxiWOCU5JAZ3tBBfS6VdnJQwfuuiQ=; b=iah4LG9N8rIO1C5ctV2nhhtm9BiwGTFYqcp+wvpoTjt5HkRaLQkKrRKr411q3djI0G m/lz3M/rXAx0sJOCqnKmc/W8Y554FqEXy4g2wGerOLLN/s3NQEgk26xlPUoY3JMev/dH Un1e9j9bX5lbjQw8Auuvg9RYfWXSrHO3z7nLx5UHk4EPYqZcac+nYZ6LjbfqMCggB8vS cOJUguNvsegpEb38aXrKSF28VH2Ig+wzLeHg3QID6B0wIbk+l4j4Couj1Muymjg6yYSu b8g/DPY6JtNOHKV+f4byeyFxXb4o1gsQwOLoMEtk6udNcG2UwRW8C65NoHie11JFijGW MEhA== X-Gm-Message-State: AOJu0Yyq2/jl+tbIYjMSYMuolJiZuw9du9qJjbQab4qrEidZESghAncW /oj3q4ZOX/LC6rFWEalp5os= X-Received: by 2002:a05:6808:318e:b0:3bb:d768:b776 with SMTP id cd14-20020a056808318e00b003bbd768b776mr11448221oib.109.1704208906563; Tue, 02 Jan 2024 07:21:46 -0800 (PST) Received: from dschatzberg-fedora-PF3DHTBV ([2620:10d:c091:500::7:66d9]) by smtp.gmail.com with ESMTPSA id da7-20020a05621408c700b0067f2c03d4adsm10072029qvb.100.2024.01.02.07.21.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 07:21:46 -0800 (PST) Date: Tue, 2 Jan 2024 10:21:44 -0500 From: Dan Schatzberg To: Yu Zhao 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 Message-ID: References: <20231220152653.3273778-1-schatzberg.dan@gmail.com> <20231220152653.3273778-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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 AM 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-memcg/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/dhhjw4h22q4ngwtxmhuyifv32zjd6z2relrcjgnxsw6zys3mod@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. The fact that the only user currently is proactive reclaim doesn't imply to me that the interface (in scan_control) should be coupled to the use-case. It's easier to reason about a swappiness field that overrides swappiness for all scans that set it regardless of the users.