From patchwork Tue Mar 28 22:16:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 76287 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp5849vqo; Tue, 28 Mar 2023 15:20:33 -0700 (PDT) X-Google-Smtp-Source: AKy350Z+rOmr81y9LIiOp0MKPh3u2AXXdlPqKQzqeguM0Vm9NNgingyONY4JS2t+NElLBi1EYBbo X-Received: by 2002:a17:902:d4c6:b0:1a1:cc91:c43c with SMTP id o6-20020a170902d4c600b001a1cc91c43cmr20873241plg.45.1680042033030; Tue, 28 Mar 2023 15:20:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680042033; cv=none; d=google.com; s=arc-20160816; b=Ctn3skdfiur36BNingUcxg5/vs/yQ6ofDX4JAeJsxKAAQN9RqPsZZulL5W+V4TQm6y ZRg2zrMDjtpZNFhMJ4c8nTswQjNc465N6e6vAKI/GbELUy1qpMLp9p8d+9FcEWAifzXg VZAc/W2AUnEGSJtHlyYlUUfpgJeoI7UD3uliSTwvc03MF6uC2xRdGxYBADBMYcsd2CXs 3GDg0reEavL16cWm2rA2QtlzNbGhztQ6JwWQti5YPBSbwHZ8Bdiq6frUxXAkJTGldNPz qYfIpsZNoMWorL44hwRNfEVSfRehFqwLWoQcKiJc3n/kf6X+n2sJMEfOpnSCOZku3+rh hjwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=ZQQVGwjs4PjltBBm07Wln67ACtAz9IV2/pUsgTkN4l8=; b=ymFywUnaP/2viVzR8tPBIyn4sY26lo7ST/VuwGnY/45ac59r6gz3XYDukRyweq8Fqq ij6XDq/7+CRaCcStRikjp8zx4BsPukASICA8xj9X82hQ5y0MkhUwENNbewFF39J++SxL kT/YJznelMRQ4wJVD3i1VxoVy/NHq9edSln4UiXeX8vEkHEvWVMTlY9Q/CgXvXnHyDsn yguFCP0ouAFfvobVe1/7V/NPPAwOgMNZDUaOBZuIxBeJPmOyEStLEjraSVdO3Pp3Y+U1 P4z/O8VxBwJoV8r1zeKlPiVp4WviDJvkRjrk3B7NLzBmw9nUzBl6eZGADPD33SPnPlqp UeIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=BwpN5IEN; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f13-20020a65400d000000b00512fab2e9casi15375684pgp.463.2023.03.28.15.20.20; Tue, 28 Mar 2023 15:20:33 -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=BwpN5IEN; 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 S229618AbjC1WRb (ORCPT + 99 others); Tue, 28 Mar 2023 18:17:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230140AbjC1WRN (ORCPT ); Tue, 28 Mar 2023 18:17:13 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5C112D57 for ; Tue, 28 Mar 2023 15:16:58 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id p12-20020a25420c000000b00b6eb3c67574so13394482yba.11 for ; Tue, 28 Mar 2023 15:16:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680041818; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ZQQVGwjs4PjltBBm07Wln67ACtAz9IV2/pUsgTkN4l8=; b=BwpN5IENfDJAO3k0fvlZBkjsW+/4dRHFvKU3Y61vx7dQ2RtgMRwRfqyo0DTmjCAyVc CnLkW84f17NTLqbLQGhvt1qFEPE3lJHVmINhnviNxj716C70wOSUz3DOzWHSZ0RhU5XN r07qEoT8pGKoQFAOapju4r5aUWkkVs0eQmIgIci7KEjffCx1HyDeGdNPdwdlAJbu1aOk 7WwXMQu8pO8A54UInZRnQw9kbNQZxf/x1jM4losJCUKwsJkxT/8pf/ZH8ftd03KJhEdg XtPwGtxKxPzrVZOjpFL3fFaXSbnVLYOlrmJD9NS/UpXXC6msV74XQ/lannH6QIJ1sQ32 hXEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680041818; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZQQVGwjs4PjltBBm07Wln67ACtAz9IV2/pUsgTkN4l8=; b=DwWY2JM7kDBgV56PkudgqRlITQZCCTVlnsNd4UDja4mbKPnL6V6LI+lza5X0IEqX6W okMrNt9eoiT0fD4qSsXOoOCgg4mP1PVGI0l3LUqF2fX9gHM0ub1Bb05zwy4xMgtgWxIc LcfieuDq+b1hCeEpm54q6nLHxdh+hkE+Uy6YT7PQ6EZdbq9wAslyV3rhaQCc+buhyjqk plY3PPvJVR+dTNDEwobW14zO2LM7O62CugKLVLJVe3ce0hNxPfRDhrpR+OjT3Xaskh02 WEv/MT4eB4flD3MP5x3UMOoBHiKcBP9QEsZ/PgSq7RPQpDQdcgsST209yIlepoOadzb+ e01w== X-Gm-Message-State: AAQBX9d1hgkD99HwtRgC4p4a3JSCbx5TasSyqBoGk11Jl4fUuvOvjowQ zoL8SMogZBB1I8qwj5ZRxJHmYoOqvw9Rodra X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a05:6902:1003:b0:b1d:5061:98e3 with SMTP id w3-20020a056902100300b00b1d506198e3mr11533410ybt.6.1680041818092; Tue, 28 Mar 2023 15:16:58 -0700 (PDT) Date: Tue, 28 Mar 2023 22:16:39 +0000 In-Reply-To: <20230328221644.803272-1-yosryahmed@google.com> Mime-Version: 1.0 References: <20230328221644.803272-1-yosryahmed@google.com> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog Message-ID: <20230328221644.803272-5-yosryahmed@google.com> Subject: [PATCH v2 4/9] cgroup: rstat: add WARN_ON_ONCE() if flushing outside task context From: Yosry Ahmed To: Tejun Heo , Josef Bacik , Jens Axboe , Zefan Li , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , " =?utf-8?q?Michal_Koutn=C3=BD?= " Cc: Vasily Averin , cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org, Yosry Ahmed X-Spam-Status: No, score=-7.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761651754744094323?= X-GMAIL-MSGID: =?utf-8?q?1761651754744094323?= 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. Ideally, we wouldn't flush with irqs disabled either, but we have one context today that does so in mem_cgroup_usage(). Forbid callers from irq context for now, and hopefully we can also forbid callers with irqs disabled in the future when we can get rid of this callsite. Signed-off-by: Yosry Ahmed Reviewed-by: Shakeel Butt --- 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 cgroup *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); for_each_possible_cpu(cpu) {