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 3A91AC43334 for ; Thu, 23 Jun 2022 16:23:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B432C8E015F; Thu, 23 Jun 2022 12:23:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AEFBA8E0144; Thu, 23 Jun 2022 12:23:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B8968E015F; Thu, 23 Jun 2022 12:23:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 872578E0144 for ; Thu, 23 Jun 2022 12:23:13 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5265420E7A for ; Thu, 23 Jun 2022 16:23:13 +0000 (UTC) X-FDA: 79610020266.21.89327A8 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by imf15.hostedemail.com (Postfix) with ESMTP id DDCA3A00A1 for ; Thu, 23 Jun 2022 16:23:12 +0000 (UTC) Received: by mail-wr1-f49.google.com with SMTP id q9so28690443wrd.8 for ; Thu, 23 Jun 2022 09:23:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Prnv934r/fiLrvMDb9R4Q9UAwnFSkafyVnLRJO0ekrY=; b=LcoScsX3IhV4fd9f8iupQ0Dlh9F4jxJt+pgI6sQwesfY1uulJbPFxxz3e47Y2gN5vK YwtUZOQhD+OdIkZq5h5316VrCYA3zkWya3oWSYp4ktmB127kUkw7jZv3YcpAhKXNZzWo 1CP4PSfO9KCvKOxJTo+viKnOKsiH2EnZ9nV1sMg+EMAMtWPKjMLsiI6Uoq3ZeBAMuudO eTY+3/kHyPgm68smgmjFRHiyd9g+n46HURNhMJpQIzk1BuWIibHuWzfBoKlJCRreeDvr 8DcMZuSyY9c//NpF//WcukCphUzRbNnFTdq7wpzcjzX96KvWRWrKZXgHpYsIq/UCMrL5 mNMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Prnv934r/fiLrvMDb9R4Q9UAwnFSkafyVnLRJO0ekrY=; b=ZJKG+9irG/qpwYvdnQDHG+ykco/Ypkh/42hBYWpUqF55Hw2yoitKt52XFVyND2dJnj J1fCwws1xz9YXiUS9pVaBrYuauHkfqlEA9sUK95JXV7sS2FAgUhmh9+XPb87wb6pqM+O uqzzel7+nbuhxuS6v5UCb0rcKgadOQQiR7oU9UQwzF2zXUoW/pwpd/FGaT3ZbcFyIJ+O 7suGznXByv2klsWHsTeeq8keUql4MHEcTtIl58O4IGcDbYTFH3m+BnPv5++6Ah5mC6W4 UZ5NHC3q0u3lnt40Y5xyGX43aXVIHEsv1/jaCHUH2kTbrLv+2PpFriZ+5q7ErhkUlCw4 tmWg== X-Gm-Message-State: AJIora8c6B4Ag9s8ek39vdQT3P80jCw4NvoGkC/7pczzPY3aMleUhVJF JvGErxP1irYcQmkUvFrppUwpaYaOMsulqgo1bFfRTw== X-Google-Smtp-Source: AGRyM1vTy6IWQuv86qCMMmSYWNfQztKY8n3VeFmwOS7QomTeUz0+bWJzjNiyKFatZ6wC44IktxYiKmcznPAqBBvH7jU= X-Received: by 2002:adf:f146:0:b0:21b:8c7d:7294 with SMTP id y6-20020adff146000000b0021b8c7d7294mr9243960wro.582.1656001391355; Thu, 23 Jun 2022 09:23:11 -0700 (PDT) MIME-Version: 1.0 References: <20220623000530.1194226-1-yosryahmed@google.com> In-Reply-To: From: Yosry Ahmed Date: Thu, 23 Jun 2022 09:22:35 -0700 Message-ID: Subject: Re: [PATCH] mm: vmpressure: don't count userspace-induced reclaim as memory pressure To: Michal Hocko Cc: Johannes Weiner , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Matthew Wilcox , Vlastimil Babka , David Hildenbrand , Miaohe Lin , NeilBrown , Alistair Popple , Suren Baghdasaryan , Peter Xu , Linux Kernel Mailing List , Cgroups , Linux-MM Content-Type: text/plain; charset="UTF-8" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656001393; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Prnv934r/fiLrvMDb9R4Q9UAwnFSkafyVnLRJO0ekrY=; b=bwqJqMF3dkPsCSlidC6GyoS77TmkSjpwH358TG5H+tGgr2VJc0fgZjqO6cGpLUKYs7yzAJ m9bG3q3q1o8ydu/4vHvkzNzgAdqHLwrHuIRCsoEI2CM1byiO7DeBbHzVcHulMKiGh3yMU2 C0LRCz18AuRuPd/Lg7f6zKLlkdUiC74= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=LcoScsX3; spf=pass (imf15.hostedemail.com: domain of yosryahmed@google.com designates 209.85.221.49 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656001393; a=rsa-sha256; cv=none; b=Xlr6/9ZNuOoJLUReGXJX6Wu+ePcHNHi69Jpmd//mb3DMOw59Rey2Y7koYB+EiNO4Xy3lPt hK2811Vdpn3dkyJbypvS1Kubc202guBr5zQ6eygA1+4GcWWdfXxDHqyM971nzx+fIqn6/7 HCLifpYCj6dnA8cyjO1c/9q7ac2/mbk= X-Rspamd-Queue-Id: DDCA3A00A1 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=LcoScsX3; spf=pass (imf15.hostedemail.com: domain of yosryahmed@google.com designates 209.85.221.49 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspam-User: X-Stat-Signature: ui316spnd4idsx11n9hy1ab5ucst67m1 X-Rspamd-Server: rspam04 X-HE-Tag: 1656001392-128186 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: On Thu, Jun 23, 2022 at 2:43 AM Michal Hocko wrote: > > On Thu 23-06-22 01:35:59, Yosry Ahmed wrote: > > On Thu, Jun 23, 2022 at 1:05 AM Michal Hocko wrote: > > > > > > On Thu 23-06-22 00:05:30, Yosry Ahmed wrote: > > > > Commit e22c6ed90aa9 ("mm: memcontrol: don't count limit-setting reclaim > > > > as memory pressure") made sure that memory reclaim that is induced by > > > > userspace (limit-setting, proactive reclaim, ..) is not counted as > > > > memory pressure for the purposes of psi. > > > > > > > > Instead of counting psi inside try_to_free_mem_cgroup_pages(), callers > > > > from try_charge() and reclaim_high() wrap the call to > > > > try_to_free_mem_cgroup_pages() with psi handlers. > > > > > > > > However, vmpressure is still counted in these cases where reclaim is > > > > directly induced by userspace. This patch makes sure vmpressure is not > > > > counted in those operations, in the same way as psi. Since vmpressure > > > > calls need to happen deeper within the reclaim path, the same approach > > > > could not be followed. Hence, a new "controlled" flag is added to struct > > > > scan_control to flag a reclaim operation that is controlled by > > > > userspace. This flag is set by limit-setting and proactive reclaim > > > > operations, and is used to count vmpressure correctly. > > > > > > > > To prevent future divergence of psi and vmpressure, commit e22c6ed90aa9 > > > > ("mm: memcontrol: don't count limit-setting reclaim as memory pressure") > > > > is effectively reverted and the same flag is used to control psi as > > > > well. > > > > > > Why do we need to add this is a legacy interface now? Are there any > > > pre-existing users who realized this is bugging them? Please be more > > > specific about the usecase. > > > > Sorry if I wasn't clear enough. Unfortunately we still have userspace > > workloads at Google that use vmpressure notifications. > > > > In our internal version of memory.reclaim that we recently upstreamed, > > we do not account vmpressure during proactive reclaim (similar to how > > psi is handled upstream). We want to make sure this behavior also > > exists in the upstream version so that consolidating them does not > > break our users who rely on vmpressure and will start seeing increased > > pressure due to proactive reclaim. > > These are good reasons to have this patch in your tree. But why is this > patch benefitial for the upstream kernel? It clearly adds some code and > some special casing which will add a maintenance overhead. It is not just Google, any existing vmpressure users will start seeing false pressure notifications with memory.reclaim. The main goal of the patch is to make sure memory.reclaim does not break pre-existing users of vmpressure, and doing it in a way that is consistent with psi makes sense. > -- > Michal Hocko > SUSE Labs