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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2EE6C77B60 for ; Tue, 28 Mar 2023 19:29:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229675AbjC1T3x (ORCPT ); Tue, 28 Mar 2023 15:29:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229631AbjC1T3w (ORCPT ); Tue, 28 Mar 2023 15:29:52 -0400 Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B2AE3A8D for ; Tue, 28 Mar 2023 12:29:50 -0700 (PDT) Received: by mail-yb1-xb36.google.com with SMTP id r187so16560898ybr.6 for ; Tue, 28 Mar 2023 12:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680031789; 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=wVYgMmmcsm1731n1mzQ0oLQHz+Whcq4PF5zJ4lB7lmw=; b=ItnSGLh1jpQN3JVppS9sVCITPiYQS/CkhnmA16xHvlicXGfnhKU7y6aVo7pYYSOzC1 smXX3KHtLdxbsldbWCfIAKlgsZDKQ2ir20UPA1ml5S4/HUI1dBEpV+3dUWTCPRPsvm57 2b7WuH9ClXFJuQLxTKeFBMDEezY55J0GItJuePZmJ4R3w8LEoS3fNdYzGhbDtRiGPIKz sAoyax2niXufDDgUigY3psKXsSXX+cYX05u7XmhcWLyyqXaP3eTmqcVkLvT6ydpZ/wmp nI4N3rbZ+3g/+ulQD9uBM222QzdjqIhU3lkZqCuQs5xDRK1vS1Bs/4f8vpZzqtccTube ZWOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680031789; 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=wVYgMmmcsm1731n1mzQ0oLQHz+Whcq4PF5zJ4lB7lmw=; b=2fYHM65x2E4NZuX2aCt5xflUHO1LJ/VekUR02RgSVVcnMmve0ZeYi0TZo5bRPvqryQ EQAU+JKNYGhCZ4Zt24Rpw84CV8PO7cJVf54DYr0VkTT1JoCsmy6vzRpzBAZ3Fkh3qzTn D9seRMxAMFxXUVBoZ6rRvW057BnmhSE8GJ7sAa5UmFcZcSj5+D0xh0A9qvJ9JxZbnHoY wz/0hVTgbMZCaauKPRIwY9mwKnBoc621B20XjuCDtRXeL/zB1N0DV2OPR2Sjl13ywKOq RDgVezVtagOJubOfaUgo9rKexohYRhCAbAjNb/rRZdUOWnCYjx7fEiEMOx0pddlZnTJG d2jw== X-Gm-Message-State: AAQBX9fHTmK0ebjJqs7YyprzzvaTbUtIA7eDju7aBithOkttK7iz480G 8aBhhGAOqo5CszRZu6HBBGKtSncXpUa9x+DVq4jA+g== X-Google-Smtp-Source: AKy350YU0gY54wvMoHew+J42IOIyRrMc9szJehhhtmBSQris0Dj2bJw+BAstdzChU6VQNK6YKTd1shm29zDJZe+UDxU= X-Received: by 2002:a05:6902:154e:b0:b77:d2db:5f8f with SMTP id r14-20020a056902154e00b00b77d2db5f8fmr10431743ybu.12.1680031789049; Tue, 28 Mar 2023 12:29:49 -0700 (PDT) MIME-Version: 1.0 References: <20230328061638.203420-1-yosryahmed@google.com> <20230328061638.203420-9-yosryahmed@google.com> In-Reply-To: From: Shakeel Butt Date: Tue, 28 Mar 2023 12:29:38 -0700 Message-ID: Subject: Re: [PATCH v1 8/9] vmscan: memcg: sleep when flushing stats during reclaim To: Yosry Ahmed Cc: Tejun Heo , Josef Bacik , Jens Axboe , Zefan Li , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Andrew Morton , =?UTF-8?Q?Michal_Koutn=C3=BD?= , 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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On Tue, Mar 28, 2023 at 12:02=E2=80=AFPM Yosry Ahmed wrote: > > On Tue, Mar 28, 2023 at 8:19=E2=80=AFAM Shakeel Butt wrote: > > > > On Mon, Mar 27, 2023 at 11:16=E2=80=AFPM Yosry Ahmed wrote: > > > > > > Memory reclaim is a sleepable context. Allow sleeping when flushing > > > memcg stats to avoid unnecessarily performing a lot of work without > > > sleeping. This can slow down reclaim code if flushing stats is taking > > > too long, but there is already multiple cond_resched()'s in reclaim > > > code. > > > > > > Signed-off-by: Yosry Ahmed > > > > Acked-by: Shakeel Butt > > > > > --- > > > mm/vmscan.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > > index a9511ccb936f..9c1c5e8b24b8 100644 > > > --- a/mm/vmscan.c > > > +++ b/mm/vmscan.c > > > @@ -2845,7 +2845,7 @@ static void prepare_scan_count(pg_data_t *pgdat= , struct scan_control *sc) > > > * Flush the memory cgroup stats, so that we read accurate pe= r-memcg > > > * lruvec stats for heuristics. > > > */ > > > - mem_cgroup_flush_stats_atomic(); > > > + mem_cgroup_flush_stats(); > > > > I wonder if we should just replace this with > > mem_cgroup_flush_stats_ratelimited(). > > Thanks for taking a look! > > I was hesitant about doing this because the flush call is inside the > retry loop, and it seems like we want to get fresh stats on each > retry. It seems very likely that we end up not flushing between > retries with mem_cgroup_flush_stats_ratelimited(). > > Maybe change it if we observe problems with non-atomic flushing? Yeah, let's leave it for the future if we see the issue. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shakeel Butt Subject: Re: [PATCH v1 8/9] vmscan: memcg: sleep when flushing stats during reclaim Date: Tue, 28 Mar 2023 12:29:38 -0700 Message-ID: References: <20230328061638.203420-1-yosryahmed@google.com> <20230328061638.203420-9-yosryahmed@google.com> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680031789; 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=wVYgMmmcsm1731n1mzQ0oLQHz+Whcq4PF5zJ4lB7lmw=; b=ItnSGLh1jpQN3JVppS9sVCITPiYQS/CkhnmA16xHvlicXGfnhKU7y6aVo7pYYSOzC1 smXX3KHtLdxbsldbWCfIAKlgsZDKQ2ir20UPA1ml5S4/HUI1dBEpV+3dUWTCPRPsvm57 2b7WuH9ClXFJuQLxTKeFBMDEezY55J0GItJuePZmJ4R3w8LEoS3fNdYzGhbDtRiGPIKz sAoyax2niXufDDgUigY3psKXsSXX+cYX05u7XmhcWLyyqXaP3eTmqcVkLvT6ydpZ/wmp nI4N3rbZ+3g/+ulQD9uBM222QzdjqIhU3lkZqCuQs5xDRK1vS1Bs/4f8vpZzqtccTube ZWOw== In-Reply-To: List-ID: Content-Type: text/plain; charset="utf-8" To: Yosry Ahmed Cc: Tejun Heo , Josef Bacik , Jens Axboe , Zefan Li , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Andrew Morton , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Vasily Averin , cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, bpf-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Tue, Mar 28, 2023 at 12:02=E2=80=AFPM Yosry Ahmed wrote: > > On Tue, Mar 28, 2023 at 8:19=E2=80=AFAM Shakeel Butt wrote: > > > > On Mon, Mar 27, 2023 at 11:16=E2=80=AFPM Yosry Ahmed wrote: > > > > > > Memory reclaim is a sleepable context. Allow sleeping when flushing > > > memcg stats to avoid unnecessarily performing a lot of work without > > > sleeping. This can slow down reclaim code if flushing stats is taking > > > too long, but there is already multiple cond_resched()'s in reclaim > > > code. > > > > > > Signed-off-by: Yosry Ahmed > > > > Acked-by: Shakeel Butt > > > > > --- > > > mm/vmscan.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > > index a9511ccb936f..9c1c5e8b24b8 100644 > > > --- a/mm/vmscan.c > > > +++ b/mm/vmscan.c > > > @@ -2845,7 +2845,7 @@ static void prepare_scan_count(pg_data_t *pgdat= , struct scan_control *sc) > > > * Flush the memory cgroup stats, so that we read accurate pe= r-memcg > > > * lruvec stats for heuristics. > > > */ > > > - mem_cgroup_flush_stats_atomic(); > > > + mem_cgroup_flush_stats(); > > > > I wonder if we should just replace this with > > mem_cgroup_flush_stats_ratelimited(). > > Thanks for taking a look! > > I was hesitant about doing this because the flush call is inside the > retry loop, and it seems like we want to get fresh stats on each > retry. It seems very likely that we end up not flushing between > retries with mem_cgroup_flush_stats_ratelimited(). > > Maybe change it if we observe problems with non-atomic flushing? Yeah, let's leave it for the future if we see the issue.