From patchwork Thu Apr 21 23:44:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 12822546 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23C02C433F5 for ; Thu, 21 Apr 2022 23:44:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 95FA06B0071; Thu, 21 Apr 2022 19:44:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 90F386B0073; Thu, 21 Apr 2022 19:44:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7AF0B6B0074; Thu, 21 Apr 2022 19:44:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 6B73F6B0071 for ; Thu, 21 Apr 2022 19:44:42 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3584F229CC for ; Thu, 21 Apr 2022 23:44:42 +0000 (UTC) X-FDA: 79382518404.19.7F22301 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) by imf20.hostedemail.com (Postfix) with ESMTP id 833E81C002D for ; Thu, 21 Apr 2022 23:44:40 +0000 (UTC) Received: by mail-pg1-f201.google.com with SMTP id r201-20020a632bd2000000b003aa58a885d1so3574822pgr.22 for ; Thu, 21 Apr 2022 16:44:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=5O0kxWZmLwFRE//70CU4SnK5FsmrfXu8oMUA9u7C7Og=; b=EEuRmGT5N/AhXYspmngFDGUt6HR2mHaVhu/fczoNdkx1S+Tiw4e5ODeE/h0GtPvaG2 bvqoiL5mnjZ/aduPS9JOdCT/WFHetjHQ/fFxUMLwUz2iHstQGYdLFY9nEc3RGO/pFRId m0WQO8I7VArJ1uX3NbmYYEA88ykvSfC0OpSqsvj5vs/DO49GYszGs0S7tk5R8f4jxym8 I2h1Y/p24TBtaEZqcwGkSWTlCVdJnfbO6lXa5S28c65m4gPlKPQoodGuay5Lob9zUCDG 714Wv7IzMi+PqiG7UTFB2mdWmfKUmZO1+0ChdhKc8za/syH6jJBY1fE/GNCPODAwzk8P Nyvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=5O0kxWZmLwFRE//70CU4SnK5FsmrfXu8oMUA9u7C7Og=; b=dL9LoBN7kROIvCU5FMM+GmHZKWrfrbyxSlJU2srRpITnm0r8EIhLEDVIAp2F05kRYz p5JASBpHL8ixptrebCVl/3upzxVc4I0NtwhWhgfw6PKPuLnRXiy6Q8evOMI2FFNh5gAi LGgpZJ0N0S2H1XTa7zWh/gPxFV8zvWkPTv3lgRKbxV3+ZS1wsy3OhnMsI5ABwo3w3glB wMElf3tqs6TdQWKB0j/QUxR2QWfA6+T7hOUmOtw3M+M9IoXvHvwyKH3lAW6oafTNqzmV s+U4Y7iCS17c4ZbWaYX/kpxRHJT8ShA99ilNpafIYa3WkDP8xgl3xp99cqqVBoialOpM lMLA== X-Gm-Message-State: AOAM530wOkkrgRgFn51bobCBBjuTHrlpMn1KBGX+KchS3HzzG1IMyR42 UikWJXdLv4wO5s/UWSXN9nJgG96j+yGT7jQt X-Google-Smtp-Source: ABdhPJwbrNyYgwlg049kNO7De6jIXhM0txTIQgoR7t77/mZCi0rHv0F4AqswEeup+3MsId9P62g42WOoKu2wvlT1 X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a65:6216:0:b0:39d:5e6c:7578 with SMTP id d22-20020a656216000000b0039d5e6c7578mr1558461pgv.114.1650584680523; Thu, 21 Apr 2022 16:44:40 -0700 (PDT) Date: Thu, 21 Apr 2022 23:44:22 +0000 Message-Id: <20220421234426.3494842-1-yosryahmed@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.0.rc2.479.g8af0fa9b8e-goog Subject: [PATCH v4 0/4] memcg: introduce per-memcg proactive reclaim From: Yosry Ahmed To: Johannes Weiner , Michal Hocko , Shakeel Butt , Andrew Morton , Roman Gushchin Cc: David Rientjes , Tejun Heo , Zefan Li , Jonathan Corbet , Shuah Khan , Yu Zhao , Dave Hansen , Wei Xu , Greg Thelen , Chen Wandun , Vaibhav Jain , " =?utf-8?q?Michal_Koutn=C3=BD?= " , Tim Chen , Dan Schatzberg , cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Yosry Ahmed X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 833E81C002D X-Stat-Signature: jz8n44pq7b5ait9rets3yg8exg4n5n6j Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=EEuRmGT5; spf=pass (imf20.hostedemail.com: domain of 3aOxhYgoKCOEbRVUbDKPHGJRRJOH.FRPOLQXa-PPNYDFN.RUJ@flex--yosryahmed.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=3aOxhYgoKCOEbRVUbDKPHGJRRJOH.FRPOLQXa-PPNYDFN.RUJ@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1650584680-806032 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This patch series adds a memory.reclaim proactive reclaim interface. The rationale behind the interface and how it works are in the first patch. --- Changes in V4: mm/memcontrol.c: - Return -EINTR on signal_pending(). - On the final retry, drain percpu lru caches hoping that it might introduce some evictable pages for reclaim. - Simplified the retry loop as suggested by Dan Schatzberg. selftests: - Always return -errno on failure from cg_write() (whether open() or write() fail), also update cg_read() and read_text() to return -errno as well for consistency. Also make sure to correctly check that the whole buffer was written in cg_write(). - Added a maximum number of retries for the reclaim selftest. Changes in V3: - Fix cg_write() (in patch 2) to properly return -1 if open() fails and not fail if len == errno. - Remove debug printf() in patch 3. Changes in V2: - Add the interface to root as well. - Added a selftest. - Documented the interface as a nested-keyed interface, which makes adding optional arguments in the future easier (see doc updates in the first patch). - Modified the commit message to reflect changes and added a timeout argument as a suggested possible extension - Return -EAGAIN if the kernel fails to reclaim the full requested amount. --- Shakeel Butt (1): memcg: introduce per-memcg reclaim interface Yosry Ahmed (3): selftests: cgroup: return -errno from cg_read()/cg_write() on failure selftests: cgroup: fix alloc_anon_noexit() instantly freeing memory selftests: cgroup: add a selftest for memory.reclaim Documentation/admin-guide/cgroup-v2.rst | 21 +++++ mm/memcontrol.c | 44 +++++++++ tools/testing/selftests/cgroup/cgroup_util.c | 44 ++++----- .../selftests/cgroup/test_memcontrol.c | 94 ++++++++++++++++++- 4 files changed, 176 insertions(+), 27 deletions(-)