Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5035045rwl; Tue, 28 Mar 2023 15:21:18 -0700 (PDT) X-Google-Smtp-Source: AKy350ZTy3Xwy4pcfpxRB4Li38bnMfx07Ls5XSlG+0b9Zm+DxyEtiD2nKhWcQmIAaawGfcROC9L9 X-Received: by 2002:a17:906:2ecd:b0:931:636e:de5a with SMTP id s13-20020a1709062ecd00b00931636ede5amr17185918eji.31.1680042078012; Tue, 28 Mar 2023 15:21:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680042077; cv=none; d=google.com; s=arc-20160816; b=Z2/oe8TtVEhNLbqxd7QsdVUEPWp54PMeW1cE4RBUbPmMbbkfxA0J7U0Yznd5r+o/cE 10V8uYEZB0GU06VHkRGu+HQqbicEq53blLbI0KfmKvod5rpSVYq4oOHzrMFecGSTbk75 WEr1M1obIQJcHlVayl/oUu8CwVPVfEvvrM1CP0is2p3vW3Hjk8HE2QA4N3e2TABYY+/l wqtkIB1XWVHQ6JlUPmbaXcfODBBWy4286NGGH+3uDBu652sjxNNd6g+MC7T2UawpoiOQ rMAoAt5nAFGMHEJ4DZyt506cZ0JdtnEDfIZWCjHi+T3YDQ3OD0DjZ4mdkh+ie+Ou8Jlh EEKw== 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=wL4GcqYYIvPt1Pi6ck7hlX2oFSHc5TZT9/OZ5kAArQo=; b=Q0cXdRMjKdOjUYWw4AAWBTw3Rj7XEeuW9Z0gaHzV3h4fJrfhRVOB5gNwWqSpORWxSm 7DSzSCkOBTAdcLUJ92C+Z/s0z0BcdIOUCWoIi4+piKVNo2CeBVpInxg8ucXlQISJZ7Mr 7C41BNDJpmznMx0pFCdZXvNf1WxDxCx6+ol8K564YaYp1Ap/xlqAgkdGmXCOEqF5yGST 5N8IHxLeP9akk1+/xYNOg60X9erYlpB8XcvEAEHW8x5PAiqZpm+6Eyf6QZw2kqFpv96+ iQ5+5xTlSC2z4YUaG4q2QjaIm1a2jaGqxwsy4CIqr3FmBZa8JQ+Nl+Jb+iaG+CXP8AmX diAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ZC6EC0DF; 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 nc17-20020a1709071c1100b00944bbbb1798si7339272ejc.678.2023.03.28.15.20.53; Tue, 28 Mar 2023 15:21:17 -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=ZC6EC0DF; 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 S229489AbjC1WU1 (ORCPT + 99 others); Tue, 28 Mar 2023 18:20:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbjC1WU0 (ORCPT ); Tue, 28 Mar 2023 18:20:26 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3767E30D8 for ; Tue, 28 Mar 2023 15:19:55 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id i5so55947359eda.0 for ; Tue, 28 Mar 2023 15:19:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680041945; 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=wL4GcqYYIvPt1Pi6ck7hlX2oFSHc5TZT9/OZ5kAArQo=; b=ZC6EC0DFE1hHUTV2LBaIFnK+dTTA9H/SYOdOb0dhH00vk7KbwRxBEbTfOOdBRB86Rg jg44S7degscRQn7Sr3Wx0ShbNoWLNgtyWVzLTr9J/rMgQ0cWTowD4bfEmQX06+cuuYTr HuVqdAQMIhsByAw/q1S4YbnR52GCVi0abm/WefRvQ/pX3odeyr4l8J7PPCwpfNHEHsUn ZaK2Ex2ZdabfxXoUFAPPmjleoMH3gRvtZCtys7cEv9WMJSFpV2zbljOiJsAo5MHnFGbU ASJUQ6Kq8/VVtikM1hs1wkVX107ltZ305Vjzbe+0lVumZUAQFAFUKuOIpWqYW77w9swX l64w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680041945; 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=wL4GcqYYIvPt1Pi6ck7hlX2oFSHc5TZT9/OZ5kAArQo=; b=eLYf+T0TWq/QObNUt9uJG/7ZFudmvTUEQfvamsPJuh6UzRme+2wD6QLoT5LQtnfdhA ODevZCsCuLeS5jTJZmvUfnYFDMzMPoIDQAYzCslh+vSWZiAqI3KWY3QiLL9EI1Bulfj0 jYFGglIEivgXGgA+RCmLFmlotYZXMfHl57UX1bcz1pngqjpql22ShrUP1kiO8RgDJI7L PB3xsrzorsPNVt4HZfHM2RElKweb96zEhLwkzGf4ovYewqtqiZoO/J1a1Mrvh/tnkYJA Pv/R5EeJiowHyTwNpJl46E5iaE/mCv6B1cexadm5PICuQdB3E0B+wiJQHkh1HkpjOXMX O7XQ== X-Gm-Message-State: AAQBX9cMwdFqD9GCAOVE7ABiQd9MFbsiiELtDkY+6+/UqpA7dns26Z9n d8bD1ICH3vMwnLL+ZbbOXUlUa/pGmf9whGCJIbw5og== X-Received: by 2002:a50:d6d6:0:b0:4fb:9735:f915 with SMTP id l22-20020a50d6d6000000b004fb9735f915mr8284499edj.8.1680041945249; Tue, 28 Mar 2023 15:19:05 -0700 (PDT) MIME-Version: 1.0 References: <20230328061638.203420-1-yosryahmed@google.com> <20230328061638.203420-5-yosryahmed@google.com> In-Reply-To: From: Yosry Ahmed Date: Tue, 28 Mar 2023 15:18:28 -0700 Message-ID: Subject: Re: [PATCH v1 4/9] cgroup: rstat: add WARN_ON_ONCE() if flushing outside task context To: Johannes Weiner Cc: Tejun Heo , Josef Bacik , Jens Axboe , Zefan Li , Michal Hocko , Roman Gushchin , Shakeel Butt , 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 Tue, Mar 28, 2023 at 11:59=E2=80=AFAM Yosry Ahmed wrote: > > On Tue, Mar 28, 2023 at 10:49=E2=80=AFAM Johannes Weiner wrote: > > > > On Tue, Mar 28, 2023 at 06:16:33AM +0000, Yosry Ahmed wrote: > > > rstat flushing is too expensive to perform in irq context. > > > The previous patch removed the only context that may invoke an rstat > > > flush from irq context, add a WARN_ON_ONCE() to detect future > > > violations, or those that we are not aware of. > > > > > > Signed-off-by: Yosry Ahmed > > > --- > > > kernel/cgroup/rstat.c | 2 ++ > > > 1 file changed, 2 insertions(+) > > > > > > diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c > > > index d3252b0416b6..c2571939139f 100644 > > > --- a/kernel/cgroup/rstat.c > > > +++ b/kernel/cgroup/rstat.c > > > @@ -176,6 +176,8 @@ static void cgroup_rstat_flush_locked(struct cgro= up *cgrp, bool may_sleep) > > > { > > > int cpu; > > > > > > + /* rstat flushing is too expensive for irq context */ > > > + WARN_ON_ONCE(!in_task()); > > > lockdep_assert_held(&cgroup_rstat_lock); > > > > This seems a bit arbitrary. Why is an irq caller forbidden, but an > > irq-disabled, non-preemptible section caller is allowed? The latency > > impact on the system would be the same, right? > > Thanks for taking a look. > > So in the first patch series the initial purpose was to make sure > cgroup_rstat_lock was never acquired in an irq context, so that we can > stop disabling irqs while holding it. Tejun disagreed with this > approach though. > > We currently have one caller that calls flushing with irqs disabled > (mem_cgroup_usage()) -- so we cannot forbid such callers (yet), but I > thought we can at least forbid callers from irq context now (or catch > those that we are not aware of), and then maybe forbid irqs_disabled() > contexts as well we can get rid of that callsite. > > WDYT? I added more context in the commit log in the v2 respin [1]. Let me know if you want me to change something else, rephrase the comment, or drop the patch entirely. [1]https://lore.kernel.org/linux-mm/20230328221644.803272-5-yosryahmed@goog= le.com/