From mboxrd@z Thu Jan 1 00:00:00 1970 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 B1736C433F5 for ; Tue, 11 Oct 2022 17:00:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4D676B0071; Tue, 11 Oct 2022 13:00:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BFDAF6B0073; Tue, 11 Oct 2022 13:00:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA0426B0074; Tue, 11 Oct 2022 13:00:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9A7446B0071 for ; Tue, 11 Oct 2022 13:00:30 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 45041140A88 for ; Tue, 11 Oct 2022 17:00:30 +0000 (UTC) X-FDA: 80009282220.06.49A3BA1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id CFDC280035 for ; Tue, 11 Oct 2022 17:00:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665507628; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+rCyzNiafV5vn9qzVyq2e5KcGK78bTJRE4XDDdx4VjI=; b=Di7cPZJDjuyGcQSi18BWmHKuFSVVYXEukP/i7oTlHIrbp2Dx7DC0uCovTuYml2dubXE3Dh RvCcE/Y4I6g6DONIyXpwNtH7Oyxx++Sb0EJV+qAH43gpRYuUi8LYSm01LTee+Eb/XRFd+d z143Q4tDq2tQPdJMsHmZua+R30Cm3sw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-169-FnjlEY_zMwGOlULVLQmSFg-1; Tue, 11 Oct 2022 13:00:24 -0400 X-MC-Unique: FnjlEY_zMwGOlULVLQmSFg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 197AD801585; Tue, 11 Oct 2022 17:00:23 +0000 (UTC) Received: from [10.22.17.56] (unknown [10.22.17.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7CD35414A809; Tue, 11 Oct 2022 17:00:22 +0000 (UTC) Message-ID: Date: Tue, 11 Oct 2022 13:00:22 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH] mm/memcontrol: Don't increase effective low/min if no protection needed Content-Language: en-US To: Michal Hocko Cc: Johannes Weiner , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Tejun Heo , Chris Down References: <20221011143015.1152968-1-longman@redhat.com> From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Di7cPZJD; spf=pass (imf30.hostedemail.com: domain of longman@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665507628; a=rsa-sha256; cv=none; b=tAKsZzrEVPQTXruJ9770tzVDOT4Che/cPvlvOwa8pHvSbB6ccKIIzMANLtHWaoNYfyWkZ2 n7sTu28Cs4PvoU3BOpn+tFhWKcxNbdreZdILnIxTwgCr8Y1NqjJ5elpA1Zt3qgjO3pKL2E SIPKTyoGzGZNqsUXY5HZeTrY2yx20TI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665507628; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+rCyzNiafV5vn9qzVyq2e5KcGK78bTJRE4XDDdx4VjI=; b=X7qSIsV0Kv2b7gG7CgOekasTl+e31n/JlsNGs9DDurUhpFIzWS6dChXe4n70ds6YYFar38 ybT7ZzuiP4yoae0HtB1UMwKBWGS2rihLmY60jNIT6AshByVhgI5Lk6fpZdNEXMs6OY6784 Cuvx7XKl9j9wFmHh/GoJmiMdA2Ezgxc= X-Rspamd-Queue-Id: CFDC280035 X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Di7cPZJD; spf=pass (imf30.hostedemail.com: domain of longman@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam04 X-Stat-Signature: ekn5qru8a86a97ybbdtr66th9haf57rg X-HE-Tag: 1665507628-132661 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: On 10/11/22 11:39, Michal Hocko wrote: > On Tue 11-10-22 10:30:15, Waiman Long wrote: >> 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. > Is this with memory_recursiveprot mount option? Yes, the memory_recursiveprot mount option is indeed turned on. > >> 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 */ >> + > This will break the above memory_recursiveprot AFAICS. You are right about that. An alternative way to address this issue is to disable memory low event when memory.low isn't set. An user who want to track memory.low event has to set it to a non-zero value. Would that be acceptable? Cheers, Longman