Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp830195iog; Fri, 24 Jun 2022 15:26:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1utAYU83E1awPRTtsW3ejY9R3Ez1zNUo8p+coG+YxINffW8lokzFr9rW2uJy4NF/mIYmthc X-Received: by 2002:a17:902:e952:b0:16a:74b7:57eb with SMTP id b18-20020a170902e95200b0016a74b757ebmr1235293pll.13.1656109560829; Fri, 24 Jun 2022 15:26:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656109560; cv=none; d=google.com; s=arc-20160816; b=aSvTkX+efB0Uv5Ner2OB+1RyWba/ccsDZF9MOH9a9cw7F5UfYsWqP5Q1Szru/5ENId 2dAjHYmVPQYJMPTtQ77vyLaOCbL43vtNcO6vOkdEBLs8jU+sq4IKsJgXmz6S5ZHDlS02 v48/qt+pNo7PdReWXDmuzo8/zmfRNsL3ED0fcrCk2SjpETYI42A3a4Oqkx1/xVnX/1Tf CHOJ4V5po2g9NX0nL5SbtHddx8hdYvNBAxJB+ipYlodTMTalav+FlqgN/Bkou8kl0arc 96wFd2PbrX9hFfi4rInenWdufYplIUBJtUm8YcC9eML/E/BuO1eM91Hax5kAeErxvdDg CL8Q== 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=06tbzvuWnDn/ojvXnYPhb8CvvsnPZweg8Ptkv04ne9A=; b=R2RMYrLXzKDZgFdLFYR1nySEJZb3alkKPdDytPeBfy0og6GZ78LDjVlzqizmG7oHWQ i1orn+KrFeAxM8HEbKQ+hAu/kJeO+rbADKQK92RysTtlwjH8OH+eoVioSUS7emD9Xbuf ZdBFQ6ZqNSE0BTebj1NVKUNEvmc4YWUAVIr9ldh8SdQ2bfyNoNp9aLSo55byn/vd1OUY icUmILuB5dlPstwNbwm6Cv+WYqJNOLh3TN1b1I8oRGPAWHuXE+rSG8u2J511lGKmrP6S rKYHnQA0DK7aeJos3egCbw/ft/f5zLJzASM2BLxZKz5ya2FvzLdNhTPY0n7ZeqZwhKXA BeGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PezAL6Z4; 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 g66-20020a636b45000000b00408871135c5si4248136pgc.559.2022.06.24.15.25.47; Fri, 24 Jun 2022 15:26:00 -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=PezAL6Z4; 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 S231331AbiFXWOg (ORCPT + 99 others); Fri, 24 Jun 2022 18:14:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229873AbiFXWOe (ORCPT ); Fri, 24 Jun 2022 18:14:34 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4341A87D75 for ; Fri, 24 Jun 2022 15:14:33 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id o4so878058wrh.3 for ; Fri, 24 Jun 2022 15:14:33 -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=06tbzvuWnDn/ojvXnYPhb8CvvsnPZweg8Ptkv04ne9A=; b=PezAL6Z4bntjGvU+BMZLwRyhf28/GmBbIJBsejRH4AXcHj0tEMTzn0npOOKoQycFMd MV5n8Vq7cziNpbAUtr4QJNY39+kZjKT8t1BehD2UIH+1L0axymRzGaiDpEv9IvJTVw+I t8UXmTIpQqtGkE2KJZE2kR3ShlyayRxfpdoB2VkfA03l8nnH4vglTRo9xQhV1hkJRA+L fIc4vv119yqNnytJ2q0ixppfhnFNd+uQkDSHguz8oTdBnwdNWfqQcRtg7LzWYL+NNvCa bIRxgK7gpbSOeS0134bGmanM74Wv4BmqsLMWULmsZxPc0k0NVLTUhIYHf9Z1eowOK1xG 6c5g== 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=06tbzvuWnDn/ojvXnYPhb8CvvsnPZweg8Ptkv04ne9A=; b=YWqeDQQmklpFZkuy423Jj8eQDg2BgI1AY1w3NT03zwmBPCFBiQwZYMHSm3iiBYUQWL GB1hOK2emQ+6oF/QclaH9/D7IX15TmANv4KmirS9tDsb+brXqK4megof3dJY0igU6WgC EzmPuWd2BahRD6rtHNfPd8jgvHgNsE8RFBfVbjGS6aJrxh4q4IGF+peRHObEl+LGeGmO Wt+EX0QA33JSq3F4GmA36TP5/i5cm1CHaFQ6BejYtRaF5QhlNoEDf95/0eDknMsQDszi MJiuc5x8rYIP4FyTbKM1c0f90i0u6Pt/JNKXY1q/4gR4yTH2xN0i9ocdqDapoHYeg6nw wwQw== X-Gm-Message-State: AJIora+yU4sQZlsYmGnrH25dOdQbNg8hf0gVrpUO/A7ADCN7sCIdrL1O 2JFDUo7ZZ/L2rZzsku7TDe47HLAM7EaMLxw5rWRNYg== X-Received: by 2002:a5d:6ac4:0:b0:21b:a724:1711 with SMTP id u4-20020a5d6ac4000000b0021ba7241711mr1129245wrw.80.1656108871698; Fri, 24 Jun 2022 15:14:31 -0700 (PDT) MIME-Version: 1.0 References: <20220623000530.1194226-1-yosryahmed@google.com> In-Reply-To: From: Yosry Ahmed Date: Fri, 24 Jun 2022 15:13:55 -0700 Message-ID: Subject: Re: [PATCH] mm: vmpressure: don't count userspace-induced reclaim as memory pressure To: Suren Baghdasaryan Cc: Michal Hocko , Shakeel Butt , Johannes Weiner , Roman Gushchin , Muchun Song , Andrew Morton , Matthew Wilcox , Vlastimil Babka , David Hildenbrand , Miaohe Lin , NeilBrown , Alistair Popple , 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 Fri, Jun 24, 2022 at 3:10 PM Suren Baghdasaryan wrote: > > On Thu, Jun 23, 2022 at 10:26 AM Yosry Ahmed wrote: > > > > On Thu, Jun 23, 2022 at 10:04 AM Michal Hocko wrote: > > > > > > On Thu 23-06-22 09:42:43, Shakeel Butt wrote: > > > > On Thu, Jun 23, 2022 at 9:37 AM Michal Hocko wrote: > > > > > > > > > > On Thu 23-06-22 09:22:35, Yosry Ahmed wrote: > > > > > > On Thu, Jun 23, 2022 at 2:43 AM Michal Hocko wrote: > > > > > > > > > > > > > > On Thu 23-06-22 01:35:59, Yosry Ahmed wrote: > > > > > [...] > > > > > > > > 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. > > > > > > > > > > memory.reclaim is v2 only feature which doesn't have vmpressure > > > > > interface. So I do not see how pre-existing users of the upstream kernel > > > > > can see any breakage. > > > > > > > > > > > > > Please note that vmpressure is still being used in v2 by the > > > > networking layer (see mem_cgroup_under_socket_pressure()) for > > > > detecting memory pressure. > > > > > > I have missed this. It is hidden quite good. I thought that v2 is > > > completely vmpressure free. I have to admit that the effect of > > > mem_cgroup_under_socket_pressure is not really clear to me. Not to > > > mention whether it should or shouldn't be triggered for the user > > > triggered memory reclaim. So this would really need some explanation. > > > > vmpressure was tied into socket pressure by 8e8ae645249b ("mm: > > memcontrol: hook up vmpressure to socket pressure"). A quick look at > > the commit log and the code suggests that this is used all over the > > socket and tcp code to throttles the memory consumption of the > > networking layer if we are under pressure. > > > > However, for proactive reclaim like memory.reclaim, the target is to > > probe the memcg for cold memory. Reclaiming such memory should not > > have a visible effect on the workload performance. I don't think that > > any network throttling side effects are correct here. > > IIUC, this change is fixing two mechanisms during userspace-induced > memory pressure: > 1. psi accounting, which I think is not controversial and makes sense to me; > 2. vmpressure signal, which is a "kinda" obsolete interface and might > be viewed as controversial. > I would suggest splitting the patch into two, first to fix psi > accounting and second to fix vmpressure signal. This way the first one > (probably the bigger of the two) can be reviewed and accepted easily > while debates continue on the second one. This change should be NOP for psi. psi was already fixed by e22c6ed90aa9 ("mm: memcontrol: don't count limit-setting reclaim as memory pressure") by Johannes a while ago. This patch does the same for vmpressure, but in a different way, as the same approach of e22c6ed90aa9 cannot be used. The changes you are seeing in this patch for psi are basically reverting e22c6ed90aa9 and using the newly introduced flag that handles vmpressure to handle psi as well, to avoid having two separate ways to address accounting memory pressure during userspace-induced reclaim. > > > > > > > > > > Though IMO we should deprecate vmpressure altogether. > > > > > > Yes it should be really limited to v1. But as I've said the effect on > > > mem_cgroup_under_socket_pressure is not really clear to me. It really > > > seems the v2 support has been introduced deliberately. > > > > > > -- > > > Michal Hocko > > > SUSE Labs