Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2445877rwi; Tue, 11 Oct 2022 08:52:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM41xHZM1RCilbE6qo9U28Gp483JQ8WcqxZ0WGvtp3GqmWBUZtiHSmkf/LAi37nOXeLuPJQ/ X-Received: by 2002:a17:907:6d9b:b0:78d:ce6a:3300 with SMTP id sb27-20020a1709076d9b00b0078dce6a3300mr5082757ejc.91.1665503557109; Tue, 11 Oct 2022 08:52:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665503557; cv=none; d=google.com; s=arc-20160816; b=b4I597BWosuqu8Syv55Yjchc6AZsJecgmmZIXe76TizDYjyPfS8kB6kTZ0s66gsOqd rFZT75NgF3+PmCOMkq7+CyBfIIJ4JTB+1+xY87L+IUUAfHCHMADwmRuvx8x9XtvbdDbi Tog9ngOWMja2rkDSuCqy4C3/Z6hIZOC09wNeIXAHJXdt4Ki0oAP3aPwNLE2ogVfOBpja j4J475/UUMklXkyjf7aPcEYVxhmQK9pj3RlFfAuh9WcoZVbqaWYzMFv84OT+mbGRWMYD +6ECLCuEaC9jDq6Yhec/wTQdhdWya3A5bCq4Vo8H/j2yQp/hYEQpigaJJ/4ozTbisebA dKuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vB0AXXBtm0Hrdk0bg6YG9HeCQbPU+AcCqyHQMZO7aHU=; b=FMn9bRuCv92g/2F3arQu4OYF+84PJqr8/i8JSRZZvc8UQoNfI53tO1YgnHiuVH1IUF aetu6VELdJGt6iM/3mvuaiWUZcdYYVO/XRAcmj4uz5QdL5ALKG0fjxvO3n+QdE9EcJH4 jYE/YkSrsbggUWjHqRJuOElco4G6NthP+ZsG9/hDNZKTrM6gAjmCmT3mgapX9VtS6NWP VQ+NY3vSrMrddSmDTK0lIz3sEDBPDt2FtbLXBQO57wKj9bRKyineSJPh+G8LdMaOfOHm mAeI9OJJPb0f+1/uEoc0QPvp3fHSL4lJhzKfnvW12TiXtUoEpMKZSDGmCLrzYfpse6GL rpTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=AOyiExVT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs15-20020a1709073e8f00b00783df65ae5esi15469702ejc.683.2022.10.11.08.52.09; Tue, 11 Oct 2022 08:52:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=AOyiExVT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230495AbiJKPrv (ORCPT + 99 others); Tue, 11 Oct 2022 11:47:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230215AbiJKPr2 (ORCPT ); Tue, 11 Oct 2022 11:47:28 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E47DD12606; Tue, 11 Oct 2022 08:39:43 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 205E21F8E0; Tue, 11 Oct 2022 15:39:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1665502782; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vB0AXXBtm0Hrdk0bg6YG9HeCQbPU+AcCqyHQMZO7aHU=; b=AOyiExVT8ICluY29f7EISViuBP4fZfaDGjWt/zgw/wKFtAhm86QAWBAMm3OGNO88yDbw4L dCppJmVuT0D38ZQBGQ4D/GsypMU9r0HpZIlyL+USdsMoBBwX+vizkRdpijHy57HK/3+fS7 wQVsY/OckiDS1Src/EUzygFkKRStZJs= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E9FF813AAC; Tue, 11 Oct 2022 15:39:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6uS9Nj2ORWNyWwAAMHmgww (envelope-from ); Tue, 11 Oct 2022 15:39:41 +0000 Date: Tue, 11 Oct 2022 17:39:41 +0200 From: Michal Hocko To: Waiman Long 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 Subject: Re: [PATCH] mm/memcontrol: Don't increase effective low/min if no protection needed Message-ID: References: <20221011143015.1152968-1-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221011143015.1152968-1-longman@redhat.com> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > 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. > protected = min(usage, setting); > /* > * If all cgroups at this level combined claim and use more > -- > 2.31.1 -- Michal Hocko SUSE Labs