Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp128828imw; Tue, 12 Jul 2022 16:06:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u6ftZCHL/Nb/b/7S0tHYF+qxUpOkeWEfSWIoGa2heCsihhtsTTnenLaswzSO16QMErbAGz X-Received: by 2002:a17:902:e804:b0:16c:569:bfda with SMTP id u4-20020a170902e80400b0016c0569bfdamr278780plg.26.1657667174531; Tue, 12 Jul 2022 16:06:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657667174; cv=none; d=google.com; s=arc-20160816; b=oxKaZzdPvMLhCFULbhWalyESiHO42v4FpG2AU/DZZPaK4uUKmC/S6EptO0iMSHUJbu qYHv2u79OLZ0PjfCFMtahqlhdgdXdtES8byopNPtBTcaAhYBsQ6Rd48lBSBb0Cs+7+fE wysBD17Zf54eXFM1Xh6F1WPOiX1C9LCepdk8rvwt21EO+0cZWI7hWu+wSdM5EuQpomDO O8L6aDwyArHf0dUIESc4T4b+xB1p2SF441ou3AJzGor37TqOmAQmERKCcKeuoN6AItQA WvaOK2z3pBAe5XdRWfvgOW+xxQvmqVfSh9SXrYUTubrez37ZEH47CEK/pIRECXjq4EAa /QlQ== 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=htaxsmbLkerK/WzSwDGnn60xtZCz4ZbFlZTWngCZmEo=; b=N3YJaVCRlUsEx6AIDeuvyyCU3DbLXQvfy7qE+65vqKqJFJ6qcDnqr5BLmYwNZFRbX1 UOw6Qxh/fMd7IV0YtyamA1aVUY6lN8GvVvB0ENYID0ibrI5xbWPlUlhyCVgUyPwyVSGh FTGx6y1r5RS3EGcm5U63cz9mT7SRU3yrg/PgwXjWMHGLABfVAMxBkNmUUECy8UVzv6vf eDN7KAFLIQH1AQOy2/5o7/sA1voRWZto5yCe7yOH+6cck55vjZQCLkE+MVjsDJueokDq mCzwEXNeGA/NxjOAnzYWXAercL7dnAJyPELmSrjiRi0AKhy2tGqGoZH4a7+L7nj4TQDf 9/fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="PJvAiv/D"; 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 t5-20020a170902a5c500b0016a1ef12873si14443035plq.76.2022.07.12.16.05.38; Tue, 12 Jul 2022 16:06:14 -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="PJvAiv/D"; 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 S233773AbiGLWwe (ORCPT + 99 others); Tue, 12 Jul 2022 18:52:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbiGLWwc (ORCPT ); Tue, 12 Jul 2022 18:52:32 -0400 Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C44BECAF0F for ; Tue, 12 Jul 2022 15:52:31 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id s128so12334874oie.10 for ; Tue, 12 Jul 2022 15:52:31 -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=htaxsmbLkerK/WzSwDGnn60xtZCz4ZbFlZTWngCZmEo=; b=PJvAiv/DmAKyikrJij5JE66g75DNqz4DHzNmHd/JdP5z0zk7MZqnCrSzDvKAn/vIHL /D1NSeoCJVH6odh+Uj/o+s5cBf7HLPhJcKRVVRRPWXogWz+S1pndViMAUC1Zvw5ESZAP a4uDkbnnM/6ytDcaYwsBLjwLxeO9Rih93Gr+RXKEKTPt1wqx/q0JXbde46/8Bpzm1NLV 78Bw7c0NvdCwXjhEsfKVunNKJ9ihm2+YXJqQWj5UFZzKq30VoqbtCJCBYX34Eh3+yLHx tX5KytQJPfANtkoIvguy1zTKRUksrSmQqW7JiP3kjvDh4jRUVC8MV/aTs5+JNNpJOxnR 3ZKw== 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=htaxsmbLkerK/WzSwDGnn60xtZCz4ZbFlZTWngCZmEo=; b=tNqB8ntCy8z2nlZxLSSYxVZiikTz/qdbNZCbg6O3i6FH6XtbORlyLydyEo/yLGpwY9 BF9ATHMO1wpID/aQ9NKANnYUpjURcecGQgaEr22gpNpG9x2KJbof9MZTIGlLS0gr8JbW 12raqOlxhfiWu/z16OS9x75shDgRHS8nd5CNjk+j2jaP1+nbO6oQ9xzckdnpPU4j07RH v3dOMOVuqewsMxi97n1/l5xa4pyDNPUBpW+Lor2SXZL9xVWYuupA+5XWFCi8SVRDNn98 D1Dpyq5EW6BF8AojSq6ZFru0v5RjjBvs36oSo7VRyEIJZM1IrFS9hh03UOwl7YuVfiaz In2g== X-Gm-Message-State: AJIora8Nv7/AqYra2GSJRjs28tAMWyTfLbELFY+Fo4+wkWL4LtZlTJqC 4wWUdDuFqZ9bir5dgjvHLJu7cukTXieLiZp/Rw/Yew== X-Received: by 2002:a05:6808:1a10:b0:335:9e39:693b with SMTP id bk16-20020a0568081a1000b003359e39693bmr216623oib.165.1657666350921; Tue, 12 Jul 2022 15:52:30 -0700 (PDT) MIME-Version: 1.0 References: <20220630083044.997474-1-yosryahmed@google.com> <20220701160947.e4902e5b0484ed084db5d41f@linux-foundation.org> In-Reply-To: From: Yosry Ahmed Date: Tue, 12 Jul 2022 15:51:54 -0700 Message-ID: Subject: Re: [PATCH v3] mm: vmpressure: don't count proactive reclaim in vmpressure To: Andrew Morton Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , 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 Wed, Jul 6, 2022 at 1:19 PM Yosry Ahmed wrote: > > On Fri, Jul 1, 2022 at 4:09 PM Andrew Morton wrote: > > > > On Thu, 30 Jun 2022 08:30:44 +0000 Yosry Ahmed wrote: > > > > > vmpressure is used in cgroup v1 to notify userspace of reclaim > > > efficiency events, and is also used in both cgroup v1 and v2 as a signal > > > for memory pressure for networking, see > > > mem_cgroup_under_socket_pressure(). > > > > > > Proactive reclaim intends to probe memcgs for cold memory, without > > > affecting their performance. Hence, reclaim caused by writing to > > > memory.reclaim should not trigger vmpressure. > > > > > > ... > > > > > > --- a/mm/memcontrol.c > > > +++ b/mm/memcontrol.c > > > @@ -2319,6 +2319,7 @@ static unsigned long reclaim_high(struct mem_cgroup *memcg, > > > gfp_t gfp_mask) > > > { > > > unsigned long nr_reclaimed = 0; > > > + unsigned int reclaim_options = MEMCG_RECLAIM_MAY_SWAP; > > > > > > do { > > > unsigned long pflags; > > > @@ -2331,7 +2332,8 @@ static unsigned long reclaim_high(struct mem_cgroup *memcg, > > > > > > psi_memstall_enter(&pflags); > > > nr_reclaimed += try_to_free_mem_cgroup_pages(memcg, nr_pages, > > > - gfp_mask, true); > > > + gfp_mask, > > > + reclaim_options); > > > > It's a bit irksome to create all these unneeded local variables. Why > > not simply add the constant arg to the try_to_free_mem_cgroup_pages() > > call? > > > > I was trying to improve readability by trying to have consistent > reclaim_options local variable passed into > try_to_free_mem_cgroup_pages(), and also to avoid nested line-wrapping > in cases where reclaim_options = MEMCG_RECLAIM_MAY_SWAP | > MEMCG_RECLAIM_PROACTIVE (like in memory_reclaim()). Since you found it > irksome, I obviously failed :) > > Will remove the local variables where possible and send a v4. Thanks > for taking a look! > > > > psi_memstall_leave(&pflags); > > > } while ((memcg = parent_mem_cgroup(memcg)) && > > > !mem_cgroup_is_root(memcg)); > > > @@ -2576,7 +2578,7 @@ static int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask, > > > struct page_counter *counter; > > > unsigned long nr_reclaimed; > > > bool passed_oom = false; > > > - bool may_swap = true; > > > + unsigned int reclaim_options = MEMCG_RECLAIM_MAY_SWAP; > > > bool drained = false; > > > unsigned long pflags; > > > > > > @@ -2593,7 +2595,7 @@ static int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask, > > > mem_over_limit = mem_cgroup_from_counter(counter, memory); > > > } else { > > > mem_over_limit = mem_cgroup_from_counter(counter, memsw); > > > - may_swap = false; > > > + reclaim_options &= ~MEMCG_RECLAIM_MAY_SWAP; > > > > reclaim_options = 0 > > > > would be clearer? > > > > I feel like the current code is more clear to the reader and > future-proof. If we can't swap, we want to remove the MAY_SWAP flag, > we don't want to remove all existing flags. In this case it's the > same, but maybe in the future it won't be and someone will miss > updating this line. Anyway, I don't have a strong opinion, let me know > what you prefer for v4. Andrew, any preferences on this before I send v4?