From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66C45C4332F for ; Thu, 14 Dec 2023 18:28:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF7286B011B; Thu, 14 Dec 2023 13:28:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E82048D00DC; Thu, 14 Dec 2023 13:28:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C83E98D00C7; Thu, 14 Dec 2023 13:28:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B86B56B011B for ; Thu, 14 Dec 2023 13:28:40 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7427E140CE2 for ; Thu, 14 Dec 2023 18:28:40 +0000 (UTC) X-FDA: 81566259600.20.86B31F5 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by imf25.hostedemail.com (Postfix) with ESMTP id 958BFA0027 for ; Thu, 14 Dec 2023 18:28:38 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=fRJtuzrM; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf25.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.48 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702578518; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lH4CLT11soXgvi/oQe5hBTiRESQ8UWLQkTtFerePfus=; b=Sbwvj0z8wNPg108+ZdNVx8AQjtJtK8dO3QwVLBXELKOMc6Zcc9+L/V7YhQydCb7N4QweCu gPoy4Xh54lHR3pCxtZxklm6Dz4YNZg2K1mbfyqrdnX7NmX/rLtZd4zLN2hY+/M4ZUSxuJ0 cyNrMPQyYcN0GW4p1kb3vPUQoRdbI5A= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=fRJtuzrM; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf25.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.48 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702578518; a=rsa-sha256; cv=none; b=wfAchlWN6IexWLRomFs/TqbUvTDoZ27MlVbj1dHehGPKXBESYzvso8PvzVdcS15hzN9hN0 Zc8uc1z52YkpG3qMjspUFYoIAkISZf3hOzS6rxtwZYZQ13IEYb+eshJ88xDfp+9sJfu8Pz sqsfvEt+lwPOfIWnO21o0g+vo9CiHAs= Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a1c7d8f89a5so1117556666b.2 for ; Thu, 14 Dec 2023 10:28:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702578517; x=1703183317; darn=kvack.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=lH4CLT11soXgvi/oQe5hBTiRESQ8UWLQkTtFerePfus=; b=fRJtuzrMcAdZ4PHL1DguZOf/HETiOfEI36Fw3k4z8TCHFjeX9iHRhj/4H9gD58Xg2/ BWzwtskAMIaRtBlHfoXoKozB2t87aOXF34/z+CcbRAS1uhycbUENRVl82bzurPXh7WoK 4KibFMVQhYO9cx28ZHUh/vmF5Oi463nYRUbrrs6s2Pw3PQlgcjhSDu4wRFUc9WhWizav lHLjisI2Tq91ITbQUuxLwfDFf5DG88x+eaLQO1XRbFe+TYSTuppROeHGhNVNBhwzKGLB 3UVaHe9eL9Zx1FMytIkjup/B+0dolS8rRM+ZDs6qaVzESgbXeXW9LFk7Ay+Fq+WNR2/o QWUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702578517; x=1703183317; 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=lH4CLT11soXgvi/oQe5hBTiRESQ8UWLQkTtFerePfus=; b=imQTf4m4xYx5G4ucOxopVvUmoVmB3WHt3gWIMy0JsqSQLJqSXCcHud7IRW/Uxp7eSK j7jID9hX3fwUTwVwNYy3Yh3sOxZQ4yGyGiHaTIGQ4xnHQkyUmKQ/XPEyVFiJhxpHWx0j 7+UIHG33W19nzZmzYmjexy9LrzQnoi8QAW3brAp8SnX9ogfzQQywWZ2PfrNjOzJZN7cE p2MNcC7CTxfwTUza82sNHGxuyfpKH0IEc+nYsyp7HeMnLeBsTLGGeokshkUO7pdPu3ee D46WHcQd6US/+aSC/7DSerRaCbPvIK18NnzNHXfYmpZ1srcTfALg3o0b5kFV6iZcxzx/ pqwg== X-Gm-Message-State: AOJu0YyEZfPGjZta6fDnfOLUgS08ggjlvuVcy8yiaLpEI9b57mU1QXc1 rVPcntcQPJkSk7WP3/KlxrjMPfHguAIVdiG35yMsAw== X-Google-Smtp-Source: AGHT+IHRwu9vWZ1HNkcpck/GZz1PmTPXDUEpaeLXHi9jKbPJ12eb2WfPX3ltH5XMfAwVgTTcxoc64P3ITxj2/N55KrE= X-Received: by 2002:a17:907:962a:b0:a1d:53d8:427e with SMTP id gb42-20020a170907962a00b00a1d53d8427emr6349710ejc.119.1702578517047; Thu, 14 Dec 2023 10:28:37 -0800 (PST) MIME-Version: 1.0 References: <20231213013807.897742-1-schatzberg.dan@gmail.com> <20231213013807.897742-3-schatzberg.dan@gmail.com> In-Reply-To: From: Yosry Ahmed Date: Thu, 14 Dec 2023 10:28:01 -0800 Message-ID: Subject: Re: [PATCH V4 2/2] mm: add swapiness= arg to memory.reclaim To: Dan Schatzberg Cc: Michal Hocko , Johannes Weiner , Roman Gushchin , Huan Yang , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Tejun Heo , Zefan Li , Jonathan Corbet , Shakeel Butt , Muchun Song , Andrew Morton , David Hildenbrand , Matthew Wilcox , Kefeng Wang , Yue Zhao , Hugh Dickins Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 958BFA0027 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: dku8f47ajooenoo1qphpgtywfjtfan1t X-HE-Tag: 1702578518-780853 X-HE-Meta: U2FsdGVkX18msy6MS3xjYldExgHNqIKIZF3te73plq/nOPBFh1MG4Njc4hZLloo3UKka5sK9v+WRW5iYgN/hjTiw5cZWY1i9e+m1ppPF2vSzF3srxP9sopipq1g3Ah/RWzzYbc9DfHepuSaAjxhzzSmWjUVVOqeoFRh2kgy2e70RebQSAtItT/V7SUo+XwtliSjZQQ0UQDoUcXFhpdUJtbbUp6/Oo7DQbdmQwlYWZV0KdbgG1h3A8FRr4W3NOEEw7aCZ2C0IxhKHzJlY+N1v7aLrk56JxvVaKWL6nbvpOKtadVIbcnHeTfUgfAtG7PB0RJ+jmuMDs4r59jl1tJyot23oqxw1sMU67H1hjSzJUbGNdKlTi+Z9f5nv4BY7k6PMXjThvg2Fw8RtLwDyDilE7mff4kWnRRnZXk6MbAb8kcdkQEKmA4zc5wfhKLvqNFiyYlQGBS9Xy8nTn01Plg/f7S+37ic7JGmDhaOY85QRd+ULsmUn2QUvj5F+kLZyhAV8CQxysqXe/BjhIoVPYiuF3q1DN9UJk70yKUoI2tCF7HyWVEUiUMvgz6TO7qda3vybWLdb79gi2d6HmxIR40gaBa6uGRuueg3theXhXhtqVbHtdNbPimHF+yuTDXUNQigoFv5sWs/jzavzZf4W2gXNGpNYiPx1fdvdXJgVCaP5qpYgwjH6prp3YTgIbXpLlUvir2BBt2KzgGAY9srBR0dPR803m2I4Eldn/OLLENLKrNkoKM48umzlENJPkwW31YhfeUe28TPHJ77loAzcImp5DHqBAm1q9o1fjQ+IsyFQM4+JkFfK+J5dPIXO1NTtil/bl2FkarEdHMN8CX6PQkzY9TRDDhy4Z3sCJtxvoNEcZ4PnLYCGazbec/KDpdoeKrqSCph5zLSjplsC7yabPZPQI4GVVi9lBIgySrRM3HAvSpDH8P0StAd7ZBfqOv13v7DwImNCDEdXcArldYl+JCj lGetuEpE nprCvE0XextVp5zkBJP7Gof2wbN97a61vsES068ZBEwhKw7x6kTAbr4W9aGerCNIpYbdzjxplD6WC+MwsiivYMJqLQva0S599zT3Nif6obhFnkQ1VUYYIp1PyR5EE6qW415NkP3VMTBC4pZ8KhaZz/2VfJswsg12vg03ntZbVWIXCvVYCDyNccRDuqmS1lWKfTfCeSHQdCJ3Z68XMGGwif1zwMWxpJLi+t/mSWq6ZtcFqHgQlIgGbvpCPu/I/UrcvmjclvWYYKc4dSY6NkU92I2fuNfhsHQIFkWwIbN4QHY1/t7yLST/QewbbSjaytYuESDWH X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Dec 14, 2023 at 10:22=E2=80=AFAM Dan Schatzberg wrote: > > On Thu, Dec 14, 2023 at 09:38:55AM +0100, Michal Hocko wrote: > > On Tue 12-12-23 17:38:03, Dan Schatzberg wrote: > > > Allow proactive reclaimers to submit an additional swappiness=3D > > > argument to memory.reclaim. This overrides the global or per-memcg > > > swappiness setting for that reclaim attempt. > > > > You are providing the usecase in the cover letter and Andrew usually > > appends that to the first patch in the series. I think it would be > > better to have the usecase described here. > > > > [...] > > > @@ -1304,6 +1297,18 @@ PAGE_SIZE multiple when read back. > > > This means that the networking layer will not adapt based on > > > reclaim induced by memory.reclaim. > > > > > > +The following nested keys are defined. > > > + > > > + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > + swappiness Swappiness value to reclaim with > > > + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > + > > > + Specifying a swappiness value instructs the kernel to perform > > > + the reclaim with that swappiness value. Note that this has the > > > + same semantics as the vm.swappiness sysctl - it sets the > > > > same semantics as vm.swappiness applied to memcg reclaim with all the > > existing limitations and potential future extensions. > > Thanks, will make this change. > > > > > > + relative IO cost of reclaiming anon vs file memory but does > > > + not allow for reclaiming specific amounts of anon or file memory. > > > + > > > memory.peak > > > A read-only single value file which exists on non-root > > > cgroups. > > > > The biggest problem with the implementation I can see, and others have > > pointed out the same, is how fragile this is. You really have to check > > the code and _every_ place which defines scan_control to learn that > > mem_cgroup_shrink_node, reclaim_clean_pages_from_list, > > reclaim_folio_list, lru_gen_seq_write, try_to_free_pages, balance_pgdat= , > > shrink_all_memory and __node_reclaim. I have only checked couple of > > them, like direct reclaim and kswapd and none of them really sets up > > swappiness to the default memcg nor global value. So you effectively en= d > > up with swappiness =3D=3D 0. > > > > While the review can point those out it is quite easy to break and you > > will only learn about that very indirectly. I think it would be easier > > to review and maintain if you go with a pointer that would fallback to > > mem_cgroup_swappiness() if NULL which will be the case for every > > existing reclaimer except memory.reclaim with swappiness value. > > I agree. My initial implementation used a pointer for this > reason. I'll switch this back. Just to be clear - I still need to > initialize scan_control.swappiness in all these other places right? It > appears to mostly be stack-initialized which means it has > indeterminate value, not necessarily zero. My understanding is that in a partially initialized struct, uninitialized members default to 0, but I am not a C expert :)