Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4751462rdh; Wed, 29 Nov 2023 09:36:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IE7yYz+LDkAsmUBwnlUEMRVIybLC6hM/ecyMxhFCd/54TwV4iKzI8Hk0Rn3ATG2x5yfRTqu X-Received: by 2002:a17:903:264f:b0:1cf:6584:4860 with SMTP id je15-20020a170903264f00b001cf65844860mr16220225plb.10.1701279363783; Wed, 29 Nov 2023 09:36:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701279363; cv=none; d=google.com; s=arc-20160816; b=KNKDYOr5oGRtOyYRy8HWgW9hZyP2AgFs3g/aJMZZGQmOXq5c+YIZA2+vzNMdOwxdWm jCK9EzqCqu6hOV6D7eXn9hIdSu20r+q+eDdBgQ/zQzfr5VQL6FQ0m5GZP2rGg8gAKjvV +RfUBrfYW9kdTjh/tfWSMegGOr7UZUwYJi2oSVFgoUQ8eIVZYlbUFBF0LtWSr+39TlZ8 eXMMHrtUjdr0ZOz3wgxveVi6hX4v7yvB7bix8I09i2d2vRpcuEdJGQIuA8CE1oL8NpfX P9u9gKX5fv6pfbLL5T40KiWqqUJKCl+kzT9uW1M+xgQZI6vsa6KojC3+kv8Rk7RcLh1r 5o/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=o5aURXIRpu1BR0yiHfEtpAHoFraXQHCwoLT8rRosZhw=; fh=k08BfxFiCW4sJn9TEcZnbwo/jGe8xJ88msxVZsP4uNY=; b=04FmOOGHVXXkYih+INETQICUojaaXMsOyYlssLXRzkhRwskc6BFIFta1/ZNzNvZ9Fb kmqoKX/dqW8x7S1oFb//lBIZd7U9Kq1fVImne3aDVvCVZP1I1FmO393l8sAYZLJePb+3 jj8gy/GOqLe97cwoT/nVrcszsB4dwigmqA+AMon2YZHEsq+R5P6s0z6GAfbtTlVDQrqC tplmhwqYE9J0oDGUyOrdNUNsDi9u+RrwnH/6Orar1vuW+AlpAlP8bD2IpBgqDh/NU5/k 0pS6wXKtxD1FfU5Niqt2G+91SPgtk3BMJSyPF2NguG89uEXHvAqaJhQg2gVD5b3PzRU2 InBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=UGlogolA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id bj4-20020a170902850400b001cc53dbf53dsi14036038plb.648.2023.11.29.09.36.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 09:36:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=UGlogolA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C3D9F8047560; Wed, 29 Nov 2023 09:36:00 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231623AbjK2Rfj (ORCPT + 99 others); Wed, 29 Nov 2023 12:35:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229799AbjK2Rfh (ORCPT ); Wed, 29 Nov 2023 12:35:37 -0500 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AD1BCA; Wed, 29 Nov 2023 09:35:42 -0800 (PST) Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 191CD100019; Wed, 29 Nov 2023 20:35:41 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 191CD100019 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1701279341; bh=o5aURXIRpu1BR0yiHfEtpAHoFraXQHCwoLT8rRosZhw=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type:From; b=UGlogolADou1QOUgsNC1t11B9ahIDxCTpBFfbrJFu2a1er/NYLPbtkI50EXZLJ1M9 r/lQbeIEtZYstKx8E5vxCHxnVqEBcEbjYRR+rWnXdk8MP33+d7oStH6WVTDSn0WKH9 hX+Twj7gK6pyEQXwafxmFCPiHn+Wuw1upudk64ZeUBXFs60pHabdDaz2h2TezVO1xE ShoLtETH7VYwM3DnM414Qpi1T6JE/VVoVlc2iA8dgZoVbu17DYc8Aooi38yDDx8LKX Ecztmf+OOB4I4nJiXYXlVGfF7N0uoru7CiVSdYo3hyNUEY7POAFPQQbQAgrk0hzLeq egy/qE4FxnC8g== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Wed, 29 Nov 2023 20:35:40 +0300 (MSK) Received: from localhost (100.64.160.123) by p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Wed, 29 Nov 2023 20:35:40 +0300 Date: Wed, 29 Nov 2023 20:35:40 +0300 From: Dmitry Rokosov To: Michal Hocko CC: , , , , , , , , , , , , Subject: Re: [PATCH v3 2/2] mm: memcg: introduce new event to trace shrink_memcg Message-ID: <20231129173540.gl2pufeo6ciubcny@CAB-WSD-L081021> References: <20231123193937.11628-3-ddrokosov@salutedevices.com> <20231127113644.btg2xrcpjhq4cdgu@CAB-WSD-L081021> <20231127161637.5eqxk7xjhhyr5tj4@CAB-WSD-L081021> <20231129152057.x7fhbcvwtsmkbdpb@CAB-WSD-L081021> <20231129165752.7r4o3jylbxrj7inb@CAB-WSD-L081021> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20220415 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 181708 [Nov 29 2023] X-KSMG-AntiSpam-Version: 6.0.0.2 X-KSMG-AntiSpam-Envelope-From: ddrokosov@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 5 0.3.5 98d108ddd984cca1d7e65e595eac546a62b0144b, {Track_E25351}, {Tracking_from_domain_doesnt_match_to}, d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;100.64.160.123:7.1.2;127.0.0.199:7.1.2;p-i-exch-sc-m01.sberdevices.ru:5.0.1,7.1.1;salutedevices.com:7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/11/29 16:31:00 #22572963 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 29 Nov 2023 09:36:01 -0800 (PST) On Wed, Nov 29, 2023 at 06:10:33PM +0100, Michal Hocko wrote: > On Wed 29-11-23 19:57:52, Dmitry Rokosov wrote: > > On Wed, Nov 29, 2023 at 05:06:37PM +0100, Michal Hocko wrote: > > > On Wed 29-11-23 18:20:57, Dmitry Rokosov wrote: > > > > On Tue, Nov 28, 2023 at 10:32:50AM +0100, Michal Hocko wrote: > > > > > On Mon 27-11-23 19:16:37, Dmitry Rokosov wrote: > > > [...] > > > > > > 2) With this approach, we will not have the ability to trace a situation > > > > > > where the kernel is requesting reclaim for a specific memcg, but due to > > > > > > limits issues, we are unable to run it. > > > > > > > > > > I do not follow. Could you be more specific please? > > > > > > > > > > > > > I'm referring to a situation where kswapd() or another kernel mm code > > > > requests some reclaim pages from memcg, but memcg rejects it due to > > > > limits checkers. This occurs in the shrink_node_memcgs() function. > > > > > > Ohh, you mean reclaim protection > > > > > > > === > > > > mem_cgroup_calculate_protection(target_memcg, memcg); > > > > > > > > if (mem_cgroup_below_min(target_memcg, memcg)) { > > > > /* > > > > * Hard protection. > > > > * If there is no reclaimable memory, OOM. > > > > */ > > > > continue; > > > > } else if (mem_cgroup_below_low(target_memcg, memcg)) { > > > > /* > > > > * Soft protection. > > > > * Respect the protection only as long as > > > > * there is an unprotected supply > > > > * of reclaimable memory from other cgroups. > > > > */ > > > > if (!sc->memcg_low_reclaim) { > > > > sc->memcg_low_skipped = 1; > > > > continue; > > > > } > > > > memcg_memory_event(memcg, MEMCG_LOW); > > > > } > > > > === > > > > > > > > With separate shrink begin()/end() tracepoints we can detect such > > > > problem. > > > > > > How? You are only reporting the number of reclaimed pages and no > > > reclaimed pages could be not just because of low/min limits but > > > generally because of other reasons. You would need to report also the > > > number of scanned/isolated pages. > > > > > > > From my perspective, if memory control group (memcg) protection > > restrictions occur, we can identify them by the absence of the end() > > pair of begin(). Other reasons will have both tracepoints raised. > > That is not really great way to detect that TBH. Trace events could be > lost and then you simply do not know what has happened. I see, thank you very much for the detailed review! I will prepare a new patchset with memcg names in the lruvec and slab paths, will back soon. -- Thank you, Dmitry