Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp7831319rwl; Thu, 23 Mar 2023 09:09:35 -0700 (PDT) X-Google-Smtp-Source: AK7set84X0zUsR/8EZUEtA7tWKAo6MU0xTasA7jQouZkhXE3IWmcROKfQriFBcDPZf226PY6llyA X-Received: by 2002:a17:906:face:b0:92f:a61a:f755 with SMTP id lu14-20020a170906face00b0092fa61af755mr10228665ejb.73.1679587775065; Thu, 23 Mar 2023 09:09:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679587775; cv=none; d=google.com; s=arc-20160816; b=eLPIuj5UA1MFDZR7/D5eIeJ6zwmKyT5m1LnsOpamcvmdYZOg4CmXh9z2augBX3hS+X J7xKg6VT/938Wa69ig0ZzFU+xqcTXpi2u0NyShtk7m8m5DUf+zlqGauIbEttqdW2NGQz bDa4y6MSI1L0aW11SlXOmQbYVZYTlAMWrCDI7mrgArRKrbNa9pZSR5sGe7ZPxXwNtUHj 4IbAxDDPgJq0+86vfDwECDcOKC03wMYQHjWy9wTqPy6+eZatgUKGbhRo9s4jor+5m+th lkLIEvsLxbf6MkJDP+EQetXwGNx29JIUG+kt1sA9XLrdhotGm3CCn9Gf3mDGy59JX1Ye 79hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=0qq4eAJlExkTdfdM7Y2EFZtPczMJ0l3cf4DT7uOI7JI=; b=f1LWRSPuqDy87bwCFQmyYiQTQHqFA3zpdYYnGfR/2G0hlCJUMvIrirRg7WI6stjvBV MEXpTGCLRNpcdj6RgRHUEXENFGT9m7FujQGyRYb316ssuPD7RbVj4XzcQUvl6pGZViYl eFXWhEfywkJ/ya87A3bEpNlJvQ+PXRbrYQNFFAgBp9F8FXYwqwOVfiXKFWOs8asrx5OL nspufBkFe38pvj0hSvbADuvcLuqIN09s0iW58pyVlYZVtUkyA5Cayve+AmbULyxDGuhH J2d7llyGUl1/5/Rf+YvVraQACEi6Mmy4f8RUrQcg2DrZ0gxWuv+Gjo9FNDJceZ+vZVuq xmXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=b2L3krFn; 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 d20-20020a17090694d400b009263490cbeasi16272433ejy.92.2023.03.23.09.09.11; Thu, 23 Mar 2023 09:09:35 -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=b2L3krFn; 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 S230421AbjCWQDM (ORCPT + 99 others); Thu, 23 Mar 2023 12:03:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230302AbjCWQDK (ORCPT ); Thu, 23 Mar 2023 12:03:10 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C004C13D5E for ; Thu, 23 Mar 2023 09:03:03 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id o12so88836693edb.9 for ; Thu, 23 Mar 2023 09:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679587382; 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=0qq4eAJlExkTdfdM7Y2EFZtPczMJ0l3cf4DT7uOI7JI=; b=b2L3krFnhws7f+p6hNHEuWxd6zHS4DqTuXhpP/rStBHvPGchFK0OAE51Mv5Gggdeva 0g+X1gb+kxTGwE7MuENLR+hBwy5CJCvKIeflwI8gTeX7juPYoXVi6mToYkQu2jsd6VVK XkpNk/cz5nwC5XHfmfjMuww1FYcjHs0qPmGVGUo4z9Ghsk7Eb1tXZJTLTmpPar+FodLP ufTGqdkDyfaPIyftUYuOdlRHEhAF00xxGUsvAS7AFhZdslbx6UQqkV+Zc9Xvt9lR/pVo p0D8+Hc5PEtyv37lvNruiMQD1DsZALHgLLaWg+NZbdFcsLcZ3CNgbGpSXxz9y6+ZVaJt NXIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679587382; 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=0qq4eAJlExkTdfdM7Y2EFZtPczMJ0l3cf4DT7uOI7JI=; b=SuZEoZUkHSTOPSnrcCCspM/ofyz2KjdADshJusxXpat8GQltypUI0KKzd70yhXhkpv sXRIZ5bp/NylS37vJ7RAs5DdlwQ6Bc5/orn8bMPU+fW/siM4FC1bv9t+C9FhzigF2sYC l2gXqO4bAMqHUhrVC+BVsOKCUGL8Q/H7syPhZ1tIukVCFbC5/VKfmuVrchff3oCSI28b ut1W77/WFeG3BdbVgk5PTu5iFO389frjTmnVGxMwKuvmHAZtlfGbg+Ol3yA8mlOAkShG 6CMX5BLsn3Dots23S0DceQkUTzC/siY551Qk/DiTJrLqwYEA5qJOIar0hqwPwyzX6R8y qhCA== X-Gm-Message-State: AO0yUKU/x8MCQ2YPcxmg/3MXz4KKuRVUHnHrtWEnMEgWY6ovGaWPb+NG 5BYd4DmJm5+FLgk6iuVwcI4SbdWhTjF3z27FQ4bsbg== X-Received: by 2002:a17:906:34cd:b0:8e5:411d:4d09 with SMTP id h13-20020a17090634cd00b008e5411d4d09mr5207827ejb.15.1679587382152; Thu, 23 Mar 2023 09:03:02 -0700 (PDT) MIME-Version: 1.0 References: <20230323040037.2389095-1-yosryahmed@google.com> <20230323040037.2389095-7-yosryahmed@google.com> <20230323160030.GD739026@cmpxchg.org> In-Reply-To: <20230323160030.GD739026@cmpxchg.org> From: Yosry Ahmed Date: Thu, 23 Mar 2023 09:02:25 -0700 Message-ID: Subject: Re: [RFC PATCH 6/7] workingset: memcg: sleep when flushing stats in workingset_refault() To: Johannes Weiner Cc: Tejun Heo , Josef Bacik , Jens Axboe , Zefan Li , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Vasily Averin , cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-15.7 required=5.0 tests=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,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=unavailable 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, Mar 23, 2023 at 9:00=E2=80=AFAM Johannes Weiner wrote: > > On Thu, Mar 23, 2023 at 04:00:36AM +0000, Yosry Ahmed wrote: > > In workingset_refault(), we call mem_cgroup_flush_stats_delayed() to > > flush stats within an RCU read section and with sleeping disallowed. > > Move the call to mem_cgroup_flush_stats_delayed() above the RCU read > > section and allow sleeping to avoid unnecessarily performing a lot of > > work without sleeping. > > > > Signed-off-by: Yosry Ahmed > > --- > > > > A lot of code paths call into workingset_refault(), so I am not > > generally sure at all whether it's okay to sleep in all contexts or not= . > > Feedback here would be very helpful. > > > > --- > > mm/workingset.c | 5 ++--- > > 1 file changed, 2 insertions(+), 3 deletions(-) > > > > diff --git a/mm/workingset.c b/mm/workingset.c > > index 042eabbb43f6..410bc6684ea7 100644 > > --- a/mm/workingset.c > > +++ b/mm/workingset.c > > @@ -406,6 +406,8 @@ void workingset_refault(struct folio *folio, void *= shadow) > > unpack_shadow(shadow, &memcgid, &pgdat, &eviction, &workingset); > > eviction <<=3D bucket_order; > > > > + /* Flush stats (and potentially sleep) before holding RCU read lo= ck */ > > + mem_cgroup_flush_stats_delayed(true); > > Btw, it might be a good time to rename this while you're in the > area. delayed suggests this is using a delayed_work, but this is > actually sometimes flushing directly from the callsite. > > What it's doing is ratelimited calls. A better name would be: > > mem_cgroup_flush_stats_ratelimited() Agreed. Will do in the next version.