From patchwork Wed Sep 21 03:19:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1680491 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=G2S43VoG; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MXNv66tkjz1yqM for ; Wed, 21 Sep 2022 13:19:46 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1oaqGu-0000ne-1H; Wed, 21 Sep 2022 03:19:36 +0000 Received: from mail-pj1-f49.google.com ([209.85.216.49]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oaqGs-0000mg-0V for kernel-team@lists.ubuntu.com; Wed, 21 Sep 2022 03:19:34 +0000 Received: by mail-pj1-f49.google.com with SMTP id rt12so2605143pjb.1 for ; Tue, 20 Sep 2022 20:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:from:to:cc:subject:date; bh=/k1XG3PrNi3CK+fWomINX9jnmWvFAXkoJ5rUMbZptiI=; b=G2S43VoG2/A6Z8VlG01qz4bH8On+X1Q0Jor9248vg2tHYgCgpC2wfAoZBhpHDh5hNC zdaU9HN6yIoYqvLRrcVdD2IAFHK7uNTy0DzqBzC53NJRvoAaEH8IovAfSjJ6gwfnCBqx VdPhmKBZt2dsaOO32zGMjSkTbn2jsImI077tdVwFCJwknY5cqGDgisDRQ4C+Xtee++2c m+L+xrNqJsStZ9ryYnW/gDYQQ4BBRLJzTF7nmX8Q4uDWDh+v6OfhaDi7PItzNovOfxbN Rp0m5I+0iA2LjXa0QeuGb9dwjd9OMmlqX4Iu5XzHupooKmWqgUD1GcLv71eHNRIxbo3W jWpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:x-gm-message-state:from:to :cc:subject:date; bh=/k1XG3PrNi3CK+fWomINX9jnmWvFAXkoJ5rUMbZptiI=; b=W9rDcgW9qKxayw9Toq4+3AAUq5UUhBQiZUoh13UmLV70JMZa3dCZvPlt70Ef47BKGx 9hZehLEU9+Mr7WW4HETTR3rwDTIwrtSxVC8GLT4bilnPUdtcy++9N88WSwJwZChVBAJ1 0IiVPak3GSBbWrqnAYLoD48Fb4OSo3D1YcsSMVBs92aDS0m50BK2DJ2CwwBf0CLQOP+k eyuapA5zrVXN9aIpVIFM8axAkQrD7l49cx3VzoSldupLs98hcvFFqarw56thWgTy4JFm AwRlaomUmE57GfZOQSGeS1v4aYCEwPy9AWXGkkRN3ZBk5VK21R3ZDmWWD+EbqUHzTP2P KbEw== X-Gm-Message-State: ACrzQf2Ydpkv+dRcGcyEvlmTCPNeO2LLxwFYpLlh1BWWzF8KGSaG1453 Yi6I3rxDb2pwFZIm7u1Q5sg7z5gXUus= X-Google-Smtp-Source: AMsMyM7m5MLvPENDNa8PciCNtpO3y1UpwVA/vwlGb7Ip8uOrFHZcIMb9EjU7mSeTufHYzUuJcGxQ4A== X-Received: by 2002:a17:90b:3ec7:b0:202:b984:8436 with SMTP id rm7-20020a17090b3ec700b00202b9848436mr7285832pjb.4.1663730372062; Tue, 20 Sep 2022 20:19:32 -0700 (PDT) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id f17-20020a170902ce9100b001786b712bf7sm664398plg.151.2022.09.20.20.19.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 20:19:31 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 3/8][SRU][OEM-5.17] mm/memcg: disable threshold event handlers on PREEMPT_RT Date: Wed, 21 Sep 2022 11:19:19 +0800 Message-Id: <20220921031924.2354693-4-acelan.kao@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220921031924.2354693-1-acelan.kao@canonical.com> References: <20220921031924.2354693-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.216.49; envelope-from=acelan@gmail.com; helo=mail-pj1-f49.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Sebastian Andrzej Siewior BugLink: https://launchpad.net/bugs/1990330 During the integration of PREEMPT_RT support, the code flow around memcg_check_events() resulted in `twisted code'. Moving the code around and avoiding then would then lead to an additional local-irq-save section within memcg_check_events(). While looking better, it adds a local-irq-save section to code flow which is usually within an local-irq-off block on non-PREEMPT_RT configurations. The threshold event handler is a deprecated memcg v1 feature. Instead of trying to get it to work under PREEMPT_RT just disable it. There should be no users on PREEMPT_RT. From that perspective it makes even less sense to get it to work under PREEMPT_RT while having zero users. Make memory.soft_limit_in_bytes and cgroup.event_control return -EOPNOTSUPP on PREEMPT_RT. Make an empty memcg_check_events() and memcg_write_event_control() which return only -EOPNOTSUPP on PREEMPT_RT. Document that the two knobs are disabled on PREEMPT_RT. Link: https://lkml.kernel.org/r/20220226204144.1008339-3-bigeasy@linutronix.de Suggested-by: Michal Hocko Suggested-by: Michal Koutný Signed-off-by: Sebastian Andrzej Siewior Acked-by: Roman Gushchin Acked-by: Johannes Weiner Reviewed-by: Shakeel Butt Acked-by: Michal Hocko Cc: kernel test robot Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Vladimir Davydov Cc: Waiman Long Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds (cherry picked from commit 2343e88d238f5de973d609d861c505890f94f22e) Signed-off-by: Chia-Lin Kao (AceLan) --- Documentation/admin-guide/cgroup-v1/memory.rst | 2 ++ mm/memcontrol.c | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/cgroup-v1/memory.rst b/Documentation/admin-guide/cgroup-v1/memory.rst index faac50149a22..2cc502a75ef6 100644 --- a/Documentation/admin-guide/cgroup-v1/memory.rst +++ b/Documentation/admin-guide/cgroup-v1/memory.rst @@ -64,6 +64,7 @@ Brief summary of control files. threads cgroup.procs show list of processes cgroup.event_control an interface for event_fd() + This knob is not available on CONFIG_PREEMPT_RT systems. memory.usage_in_bytes show current usage for memory (See 5.5 for details) memory.memsw.usage_in_bytes show current usage for memory+Swap @@ -75,6 +76,7 @@ Brief summary of control files. memory.max_usage_in_bytes show max memory usage recorded memory.memsw.max_usage_in_bytes show max memory+Swap usage recorded memory.soft_limit_in_bytes set/show soft limit of memory usage + This knob is not available on CONFIG_PREEMPT_RT systems. memory.stat show various statistics memory.use_hierarchy set/show hierarchical account enabled This knob is deprecated and shouldn't be diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 612f48d10cb4..39b980ae80a7 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -868,6 +868,9 @@ static bool mem_cgroup_event_ratelimit(struct mem_cgroup *memcg, */ static void memcg_check_events(struct mem_cgroup *memcg, int nid) { + if (IS_ENABLED(CONFIG_PREEMPT_RT)) + return; + /* threshold event is triggered in finer grain than soft limit */ if (unlikely(mem_cgroup_event_ratelimit(memcg, MEM_CGROUP_TARGET_THRESH))) { @@ -3749,8 +3752,12 @@ static ssize_t mem_cgroup_write(struct kernfs_open_file *of, } break; case RES_SOFT_LIMIT: - memcg->soft_limit = nr_pages; - ret = 0; + if (IS_ENABLED(CONFIG_PREEMPT_RT)) { + ret = -EOPNOTSUPP; + } else { + memcg->soft_limit = nr_pages; + ret = 0; + } break; } return ret ?: nbytes; @@ -4726,6 +4733,9 @@ static ssize_t memcg_write_event_control(struct kernfs_open_file *of, char *endp; int ret; + if (IS_ENABLED(CONFIG_PREEMPT_RT)) + return -EOPNOTSUPP; + buf = strstrip(buf); efd = simple_strtoul(buf, &endp, 10);