From patchwork Wed Nov 23 09:21:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13053286 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 0E5BAC4332F for ; Wed, 23 Nov 2022 09:21:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A2D476B0073; Wed, 23 Nov 2022 04:21:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B52C6B0074; Wed, 23 Nov 2022 04:21:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 856FA6B0075; Wed, 23 Nov 2022 04:21:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 71F906B0073 for ; Wed, 23 Nov 2022 04:21:39 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 468C41A11EB for ; Wed, 23 Nov 2022 09:21:39 +0000 (UTC) X-FDA: 80164164318.28.9EC5819 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) by imf28.hostedemail.com (Postfix) with ESMTP id E0EA4C000E for ; Wed, 23 Nov 2022 09:21:38 +0000 (UTC) Received: by mail-pg1-f202.google.com with SMTP id t185-20020a6381c2000000b00477a9bafdb6so1807734pgd.6 for ; Wed, 23 Nov 2022 01:21:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=N8aMTHwZ5WhdNd/taFqhW6oCnMv7Hs8LkFgvgW835eE=; b=nPBStnU0nNvPiCaL5LqZMwaE6rg463N1CT1Nycb/gGZ7X4HbwZ5+sBxndYSF/DhErA Ql1RpffgRhRRHlA0BT/yYdJXGlK1BgLhYaaCw/bZQv4FN5QeYF1wV50muFqo6rfcVQ9t uSHkGFqG+uIQlPXyCQai8gVHrHOUS3wzj+DMkq5zFKrerN7BIizijLnDxa8Pnzpy2baS 29mlSeIqmA07gEXsbUx33rLahVyrc2JcK5EfZzuG9tuvpOSh+pv2P85O+CYa/rfYXW7H Q7nKw5cPTzEZ+EHB9bsc3HkK5GY5oL9QcljnXJRr1c60FM5DnniRIfQiQPtagGEMzmsy 5w5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=N8aMTHwZ5WhdNd/taFqhW6oCnMv7Hs8LkFgvgW835eE=; b=N3H107spJN4pAYFErKkwRXl2Z2wfyiHJDHMllTJB42hAkdi1M6GVtC+xmm6KNjPyr0 2SdjXxO1zi/TXLOJA1U3zJ5m4x4jwS72HjtVSGIQv2we6E9YZXz6KyPg0RdxENh+3FER fXBX2N16w/0CXQkHHUvf7IKnKz422KN43W2WUPyE/lzvau7IQdaV8/KT1Pam9FWGuvX8 GTvCDdz+I7Zq/Ygd0TN8KG03yeZSvlmwGGwGgy30gxmM7xma1J1NjHNOkWsIXVYWNOpu NDO1gQVLIoZkVl32bxNV4YlderIN5YQ7zTsNMj+ltsxxjZyBBK10KEVd1TfuwNZsLvDy DMRg== X-Gm-Message-State: ANoB5plAAu+CeAhthgHC8PM93TKKiylxgKeL3gxnJeDlxIgC0WHjcxVt qXOXwRH05TQolEQ4Z6NrCF6FUkb3VovaoRPl X-Google-Smtp-Source: AA0mqf6eA/SswF6GKB6vAvjx1nUPJ9m0no7zaMHd1/I+pSCtTiat8jOinykDmpe7ezdAH0s9bdjOaYlwOEh5C2Ji X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a17:902:680e:b0:188:d552:fb02 with SMTP id h14-20020a170902680e00b00188d552fb02mr8216533plk.76.1669195297553; Wed, 23 Nov 2022 01:21:37 -0800 (PST) Date: Wed, 23 Nov 2022 09:21:29 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog Message-ID: <20221123092132.2521764-1-yosryahmed@google.com> Subject: [PATCH v2 0/3] mm: memcg: fix protection of reclaim target memcg From: Yosry Ahmed To: Shakeel Butt , Roman Gushchin , Johannes Weiner , Michal Hocko , Yu Zhao , Muchun Song Cc: "Matthew Wilcox (Oracle)" , Vasily Averin , Vlastimil Babka , Chris Down , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Yosry Ahmed ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669195299; a=rsa-sha256; cv=none; b=L0lLtkKGCz+c04B7L+ICPZlTExpmVWK1NiiVpaPt5iIXEQvGGZEQrpoWr3I01TZw5hCmS+ 7RqPS6M7aYUWsxFHRxqONUwXw4h3DgdDVtjomM0Gu27oaxlZyx8qeBBk3jbXSojVoiVBy8 ijM3SacCXar/DraJcfkJz7DpGdMg2J0= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=nPBStnU0; spf=pass (imf28.hostedemail.com: domain of 3IeZ9YwoKCAg6w0z6ipumlowwotm.kwutqv25-uus3iks.wzo@flex--yosryahmed.bounces.google.com designates 209.85.215.202 as permitted sender) smtp.mailfrom=3IeZ9YwoKCAg6w0z6ipumlowwotm.kwutqv25-uus3iks.wzo@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669195299; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=N8aMTHwZ5WhdNd/taFqhW6oCnMv7Hs8LkFgvgW835eE=; b=wPO444DYeFCMecPs+mlv2lnc9x4paR/aS/m0GKjZrRyeCNA2h8AY5oFk5nCU85wGMEC4WQ P3WquTw51uj1WSaayEcsfpU1zzlbSotdntAc4kLnw/XeYhVcW2XhSKT2uhZbB6oBiQRR4k VvFBB5D7uLu7MxYIWhTSpwI1rNTiObg= X-Stat-Signature: xbotey6rwfud71jmus8ddzqh6kxitxp9 X-Rspamd-Queue-Id: E0EA4C000E X-Rspam-User: Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=nPBStnU0; spf=pass (imf28.hostedemail.com: domain of 3IeZ9YwoKCAg6w0z6ipumlowwotm.kwutqv25-uus3iks.wzo@flex--yosryahmed.bounces.google.com designates 209.85.215.202 as permitted sender) smtp.mailfrom=3IeZ9YwoKCAg6w0z6ipumlowwotm.kwutqv25-uus3iks.wzo@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam02 X-HE-Tag: 1669195298-664094 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 series fixes a bug in calculating the protection of the reclaim target memcg where we end up using stale effective protection values from the last reclaim operation, instead of completely ignoring the protection of the reclaim target as intended. More detailed explanation and examples in patch 1, which includes the fix. Patches 2 & 3 introduce a selftest case that catches the bug. v1 -> v2: - Instead of adding a new helper, extended mem_cgroup_supports_protection() to check if the current memcg is the target memcg, renamed to mem_cgroup_unprotected() which is much easier to reason about (suggested by Roman). - Add a selftest case to catch the bug (suggested by Roman). Yosry Ahmed (3): mm: memcg: fix stale protection of reclaim target memcg selftests: cgroup: refactor proactive reclaim code to reclaim_until() selftests: cgroup: make sure reclaim target memcg is unprotected include/linux/memcontrol.h | 31 ++++-- mm/vmscan.c | 11 ++- .../selftests/cgroup/test_memcontrol.c | 96 ++++++++++++------- 3 files changed, 87 insertions(+), 51 deletions(-)