Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6025171iog; Thu, 23 Jun 2022 09:48:13 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vl00zCzEhHpT2/1q7xe8yAzK5h2PxS/a2ZXtD1VoAYn9VpJZ1Ey1Ge8auH1Ar4ndpsaqvK X-Received: by 2002:a65:6045:0:b0:399:3a5e:e25a with SMTP id a5-20020a656045000000b003993a5ee25amr8131228pgp.139.1656002893347; Thu, 23 Jun 2022 09:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656002893; cv=none; d=google.com; s=arc-20160816; b=ycVkuYA06AUhEQGWQ2sAak3seVOoLq3t/75Vh7lb9mUmLELmlimp0PSot53/YUG4/1 OHkzwdEW0FZ3/eatbl/kByZ1+yA7+TMYwcQkjW+BUKxmWvCye3YaFB+uvt42RfX1JFAS uSZmTE0M5afI+Wfs813ExeT+awTtZ0Cv2R0w9zQV5a25e3ctCtIYHCAqiV5SEnkQbHLL V+k42q1vwTIUtKBxCa53662hV7tN1YSCPQpmzPA7T8ELvXrMhVBYPRUEvvHTogZKy68p pfMZNE3oJIYNdJQJdnZsL3Ox3gcrrR1ctuGny0gr+4wT9Lx3gu2XlghQ7QalN7gXgWfh Myzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Prnv934r/fiLrvMDb9R4Q9UAwnFSkafyVnLRJO0ekrY=; b=0fv2wGBrJrWr7eUVD3fa2yvceEr8L4fyyZlfD6HCEc53DlBow03Q5SMps50QnYulC6 pW+2kaQB5I7HEzpGAgtt3vjTmwM0WXw7Ogbg3dK9lvIKZjmCtSZIAd0wGflQFKffZPxv w6+ZAjgxfryc3dqn7q86y8N8QKKQa5g8F89eag5TwXANDG6yb2NjgzqS81D7Tos6tKb2 HlgDukCAKNQamj5eQGo656GZs7Dz2DD42epjzWGyx+RlbYVPjcnVt8o7PFrXYKaWkpBo lZrzRTNxb6B85JcgX0BVsa0z1IedIBf8kFzhL8eNXteqJbf/105AvLH9sTEFnGIgaHfs LtLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=LcoScsX3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z15-20020a170902d54f00b001674b0d4e30si33908plf.315.2022.06.23.09.47.58; Thu, 23 Jun 2022 09:48:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=LcoScsX3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232130AbiFWQXP (ORCPT + 99 others); Thu, 23 Jun 2022 12:23:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230338AbiFWQXO (ORCPT ); Thu, 23 Jun 2022 12:23:14 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1F962CDD2 for ; Thu, 23 Jun 2022 09:23:12 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id i10so24923689wrc.0 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=Wq9XmIo613Rg3NT6tKkdWvcwy7jolUip8Gv3SBm7BcBLHMEL1sK1R0P5/gOn/fqG6S lgcnurq+JSpSi1AETkNQKo7DgqdwOqhQVF94roD2RomSeca5SMql2cfF8vsAg1lbLneY /bBIqqMcbVZjwVLKd827nDN6ypKOh3OWVLS0pF7TuqGAdnXx5UBRhi6fcKx3nh87+V/O tggVHYD5lN1t/16NkfD45n4XtuzO60lbPXTyMv9PvwAUbuUaCuB8Mpgn+9M09URIcewK ZNNT6UcBkjxIyN7cZ1NVdgqRUwJUY1DepINKX68Saqd4hvkTDOQTEbc8UobSESqKSDMY k+kQ== X-Gm-Message-State: AJIora8EY9Mi344+qqZDkfaZUjhcY+MuHe0i2w93be1VdyGZ273FVG+E /5TnHPa9blS7aeg5HuZ8NT5bnS/m/lhXdvp9wmZHpA== 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" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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