From patchwork Tue Oct 11 14:30:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 13004086 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 16149C433FE for ; Tue, 11 Oct 2022 14:31:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 25F826B0071; Tue, 11 Oct 2022 10:31:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 211106B0073; Tue, 11 Oct 2022 10:31:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B0EE6B0074; Tue, 11 Oct 2022 10:31:02 -0400 (EDT) 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 EAD5F6B0071 for ; Tue, 11 Oct 2022 10:31:01 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 6C99CA1350 for ; Tue, 11 Oct 2022 14:31:01 +0000 (UTC) X-FDA: 80008905522.08.5B9E17A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf24.hostedemail.com (Postfix) with ESMTP id C7F70180032 for ; Tue, 11 Oct 2022 14:31:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665498660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=4/tx5Hg2EBXygF2G8xfjAkH7UAOIXn21J5RskYrkmds=; b=RBU1oP7iakA3hIhN+bAu1wdrUZSRgH/3vVtmnN4wCfNrA9Ty8MNukV+B1R5Sl1+5vCQquf upKEN0t6g/hrsZURquKfI+Qsl79RCQUsRLL2bGetUCi4Tp0dloFQffjN6nOqxN1QrDHg6T IdsrbsLKnc+29iduSGBB+AwIgBMqyW4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-275-SvpcsVCvNv6sGp-hOHfwnQ-1; Tue, 11 Oct 2022 10:30:55 -0400 X-MC-Unique: SvpcsVCvNv6sGp-hOHfwnQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0657B382ECCD; Tue, 11 Oct 2022 14:30:55 +0000 (UTC) Received: from llong.com (unknown [10.22.17.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6EA0040E9920; Tue, 11 Oct 2022 14:30:54 +0000 (UTC) From: Waiman Long To: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Tejun Heo , Chris Down , Waiman Long Subject: [PATCH] mm/memcontrol: Don't increase effective low/min if no protection needed Date: Tue, 11 Oct 2022 10:30:15 -0400 Message-Id: <20221011143015.1152968-1-longman@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665498660; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=4/tx5Hg2EBXygF2G8xfjAkH7UAOIXn21J5RskYrkmds=; b=J/N9FskQQ4kmltUopbin+Mo3oRV6ObQ5enyvuA4neNRPR5d9g0xLUDAU8RsXjYgwFu1Uzu lif5IjojnKvZjTBZLmUN0j7jzbzH5EBCV40k9KYOStxcRVwgXQxnry5NwudWvJm7FLlqpE eMUyxbxZ53BOwyspbNIWF5/XQ1hkOb4= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RBU1oP7i; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of longman@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=longman@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665498660; a=rsa-sha256; cv=none; b=0o5W4sd9PsvfN/c5ELybBqARtLsVuaM+sTVMFpCvBPsPR4P5vM8bQ7e5LOucRN8KGR9aEL c7vzHfWHdBUY/zjN+NNQ7/P7eRodp3EAszAx1T94rJIdelCnifmz6t6z+LrvnCfx2qCeai 3N5Qkak9cTUq2BfFi/qMIXv4lOhZDSk= X-Stat-Signature: hfpf43uross5b5cwj8t8kg9n33aewzqu X-Rspamd-Server: rspam09 X-Rspam-User: Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RBU1oP7i; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of longman@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=longman@redhat.com X-Rspamd-Queue-Id: C7F70180032 X-HE-Tag: 1665498660-113594 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: Since commit bc50bcc6e00b ("mm: memcontrol: clean up and document effective low/min calculations"), the effective low/min protections can be non-zero even if the corresponding memory.low/min values are 0. That can surprise users to see MEMCG_LOW events even when the memory.low value is not set. One example is the LTP's memcontrol04 test which fails because it detects some MEMCG_LOW events for a cgroup with a memory.min value of 0. Fix this by updating effective_protection() to not returning a non-zero low/min protection values if the corresponding memory.low/min values or those of its parent are 0. Fixes: bc50bcc6e00b ("mm: memcontrol: clean up and document effective low/min calculations") Signed-off-by: Waiman Long --- mm/memcontrol.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index b69979c9ced5..893d4d5e518a 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6660,6 +6660,9 @@ static unsigned long effective_protection(unsigned long usage, unsigned long protected; unsigned long ep; + if (!setting || !parent_effective) + return 0UL; /* No protection is needed */ + protected = min(usage, setting); /* * If all cgroups at this level combined claim and use more