Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4542864rwl; Tue, 28 Mar 2023 08:13:09 -0700 (PDT) X-Google-Smtp-Source: AKy350aWrFwAjq9aU37crKKRzZRzJ4FaCzdq43kP84B0ucGOgkq2fNn4X2AzEarWV+rpGpSLeHWW X-Received: by 2002:a17:902:d4c7:b0:19e:82d5:634c with SMTP id o7-20020a170902d4c700b0019e82d5634cmr17449745plg.53.1680016389295; Tue, 28 Mar 2023 08:13:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680016389; cv=none; d=google.com; s=arc-20160816; b=vQ4jqqu1a2LtrYCwnzTXckIsRw8htXWaqTnzVXMDxkOj2SQECLJ1PW+Yk6r1cezUfn Y9hu/DLwbUal+qEp1p2upOlKQctafqd2SPwmxEO804x193DlER/xsPML0JqMZ/P6/bGZ h6r/+wwfi1TNEXV+mG3NCCAwh117MSCBl2X17KLhfTSklRSsk9iovuoBqPE9H099jSLK c03NYylxpllTUCwOpy/giSA2Kw1uKS/YibvKvycOc4EZMMVdduFg2CV3cX3RCvkygoL+ p+xP+8GkG/EBnjAJ0D4IvD6nVO1LX314+LY9JwHBy1M6g/egmEXa3RQmzw+GDYApte2j L+ew== 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=g+YmdZ2KifzhfvJEdg7p7f3TJNPgCoNZqPs2Cx2ndxo=; b=Z3Opw8vUk5RrHSsKTF2BxOhEXUSqC+fj/hngY419OBqRVAylGF+J4xbqWi4Wn4w+ZW v4lJlKLx4LI3q2qiDe08JNRxYP5lTdUcUfSYKE8u7npdqa7eavoqoo/GlTeXi6v48jvt qbTwCnRp7Y0WhGwgyhW84wLOCS9vsqqXJw0ELd38yyv0sPAZGKN7wuy/J3M43PP4cB6V YHRLELIYLbvkiV//ky3Th6YstJ2lNuz16C2OL+Sjg/G4UBQaREETqrfXAKXECV5X4zgj jey+AMuQT+3NqNc/29RpCo+63MHeybi59YIw5T87IAQrH2df9Obl8QCel2GhH6wx+jKa 1RqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=QxwODGEr; 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 q21-20020a170902b11500b0019ca54b0f0fsi29133532plr.638.2023.03.28.08.12.57; Tue, 28 Mar 2023 08:13:09 -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=QxwODGEr; 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 S232559AbjC1PMj (ORCPT + 99 others); Tue, 28 Mar 2023 11:12:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231934AbjC1PMd (ORCPT ); Tue, 28 Mar 2023 11:12:33 -0400 Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97EDF1024F for ; Tue, 28 Mar 2023 08:12:05 -0700 (PDT) Received: by mail-yb1-xb34.google.com with SMTP id i7so15514603ybt.0 for ; Tue, 28 Mar 2023 08:12:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680016194; 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=g+YmdZ2KifzhfvJEdg7p7f3TJNPgCoNZqPs2Cx2ndxo=; b=QxwODGEreqDxcIBzupdiBDMaDhVMLLzdv5CfZ77spG0lhFRud2y5nLrWzzAe/C6t7j ZOeI1MwZhgbHKufRmNFroSj3WemqRteMnB4I3zgWlrAqlMt2LkDL2uFa+Q4rzDU1486c dNNfXBmijmlYD705lBNf01BTyrCyDOrSF9RzPetnYAB3AYPpNLJYWV3MaUX8PnUEt/zX ZWmL0MYGGLpvauhUzo75H6kPcjwi3fp70mN3e4rJpmVhTv/25ZngEpNST6bZiJzZmjXl eT2y5J/uzC+53+JC7JZ5kq/eruzL0a+NXlhHEm6lqmXJr8zdho9ORG1Eq0Et9AmoG2T8 Vnpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680016194; 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=g+YmdZ2KifzhfvJEdg7p7f3TJNPgCoNZqPs2Cx2ndxo=; b=xPQa75QfQ6UKTl4migLZKWGnSInzDmMEFt/B++fErY+0DE9NXv2VoPRlALE2SMTVTB fqD/z//wIW0TvLqeLcq6syjI9EvYKuyYgYit8p97j8B38oYXG9F8slQ3iPHMZrc7ykJa HjP70gYtgDiXGw/0S3Ad0oO+PCI0Iw1Xv373IdPbXbZ3mN/zghYW/+Q6rMSqfbwxW4HB TXV77Jk7vmBT9vl7T9CLr19Ih2SHYll3cQZzPIRC0ESHsGFAlJaadUXRG+3S2QGw2j9R bYUL14h17cWqlysMxTAaArHQGXAEcQrq0VnApJw4hGLugK1OzuuNNkhVYOLPaPKb/Btd U4Fg== X-Gm-Message-State: AAQBX9euYVW/ywgrerfJD4byaFUX1L1eykiHx8BhCKwa3ym/9g8mYdGC 7+aE2d0ae8mNQlI1gCBXuwa+WnuPu1vYO2mAyyryjw== X-Received: by 2002:a25:2749:0:b0:a99:de9d:d504 with SMTP id n70-20020a252749000000b00a99de9dd504mr10160590ybn.12.1680016193782; Tue, 28 Mar 2023 08:09:53 -0700 (PDT) MIME-Version: 1.0 References: <20230328061638.203420-1-yosryahmed@google.com> <20230328061638.203420-7-yosryahmed@google.com> In-Reply-To: <20230328061638.203420-7-yosryahmed@google.com> From: Shakeel Butt Date: Tue, 28 Mar 2023 08:09:43 -0700 Message-ID: Subject: Re: [PATCH v1 6/9] memcg: sleep during flushing stats in safe contexts 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 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 Mon, Mar 27, 2023 at 11:16=E2=80=AFPM Yosry Ahmed wrote: > > Currently, all contexts that flush memcg stats do so with sleeping not > allowed. Some of these contexts are perfectly safe to sleep in, such as > reading cgroup files from userspace or the background periodic flusher. > > Refactor the code to make mem_cgroup_flush_stats() non-atomic (aka > sleepable), and provide a separate atomic version. The atomic version is > used in reclaim, refault, writeback, and in mem_cgroup_usage(). All > other code paths are left to use the non-atomic version. This includes > callbacks for userspace reads and the periodic flusher. > > Since refault is the only caller of mem_cgroup_flush_stats_ratelimited(), > this function is changed to call the atomic version of > mem_cgroup_flush_stats(). Reclaim and refault code paths are modified > to do non-atomic flushing in separate later patches -- so > mem_cgroup_flush_stats_ratelimited() will eventually become non-atomic. > > Signed-off-by: Yosry Ahmed Acked-by: Shakeel Butt