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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3CF0C433F5 for ; Tue, 11 Oct 2022 17:00:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229959AbiJKRAe (ORCPT ); Tue, 11 Oct 2022 13:00:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229638AbiJKRAc (ORCPT ); Tue, 11 Oct 2022 13:00:32 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E96F343AD2 for ; Tue, 11 Oct 2022 10:00:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665507629; 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=D6E5zEoN2COIye4o0bHlVvTc6SUSwDmnq/zA4JD689nUCw1BNmFd5I/02xRXvRr8c3qX3V AQ1G8AuxwuHbeEA0h8QXPUshNkKE/+7TCasouLDZ4LSUVlApO+Q17wkWUlnTQNZ++omkrx Zf/Vs+2C8bd0TtQSTCkod3mpAFqX68o= 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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