Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4735057rdh; Wed, 29 Nov 2023 09:10:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IE2GpUM2SjEqrh7naw3BkmXUs9CQidxwubvezrDGavH+7InaG/dpFSKtOzhAAbxXdfmF0VR X-Received: by 2002:a05:6a00:1745:b0:6be:287d:46d6 with SMTP id j5-20020a056a00174500b006be287d46d6mr18058887pfc.33.1701277856749; Wed, 29 Nov 2023 09:10:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701277856; cv=none; d=google.com; s=arc-20160816; b=ttz0qROI3Hl2yDQ+kCvsfUjWdvUH0K3xI9q/1IKGfWxDq4AIwnOUJ9ykL9XlYR6fmJ 0rSFcHdKlCrVGYxFN6gG8hQ3PsmuZHrJXWNP6dvgtcCepniIkYTfYqiRIXaipHIE+JLw GR4/Q112Ia1eYgckUI2GBwwtMD9q0gBeToWT+C0VAMBA9tPKDNc50nAW8Y6nHWeS14iR qAH/i1mGCHvjZCOcVwB8rer5gavy4RLVXGP2IjOzdD3CNVD0FRakDwvJ0JFJZ3C9Ak8+ 1EgKM692aLThxAJpEx4fYOsUGqiWRnRqZ1U/oe5FDCKIpTI0ft8sASqXazQDROmHIaEY cthQ== 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=vzwYMvZH+lLs7nIcf9848QxwWYfgK9k6V/VFPR/CPRo=; fh=gXwBCAfqwtQwPbHML2V1ZWWtAuq4MX30r9nBqko7j4E=; b=Tx+etgj+oKaPWW4lY+opuumpCykTEBOA467GW96EQJVdMQ5usiiu0FedEoJ+KV5Y1s AyiB9ZfM1B7guY2s+XUMnvuzpX8TJ1U0oEJlpCCLMwFCj4P81v4HN+34SKS9f0bj3FNx ANT/sm+M4uF5WFjVvxjEiCw2dggEF/+e0wttGlV6+CmcV398W7YZBFYQbvmuYy7BfRHN z129lM5W5whFLfRWoRqmKbh1NCsQR9EunKKMQiBn+N6ByJidTNleqbkGUrTxoL4PT8HQ qQsLY13gZKDAWUAeEQIlIIEtHgHW6+CuC1mE6mGoIOIRorbJOn4iv3mIqnMQitKPJALT QY9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=c5lp+V55; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id f17-20020a056a00229100b006cd82b4d0c4si9069154pfe.89.2023.11.29.09.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 09:10:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=c5lp+V55; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 6C4AF805DEC2; Wed, 29 Nov 2023 09:10:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230437AbjK2RKb (ORCPT + 99 others); Wed, 29 Nov 2023 12:10:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbjK2RKa (ORCPT ); Wed, 29 Nov 2023 12:10:30 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9D27BC; Wed, 29 Nov 2023 09:10:35 -0800 (PST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 486F7219B5; Wed, 29 Nov 2023 17:10:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1701277834; 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=vzwYMvZH+lLs7nIcf9848QxwWYfgK9k6V/VFPR/CPRo=; b=c5lp+V55CaoT+Xdq7Wwd+8OE9dGrFAn2IzXhIrl90H2aFxKRO6Ii6NJEzhC7kZQmNiA1RG cd9t4hK0Yg4/h5Z+6oIfZSu4CPnTItNmi9PW9op1hC60azk4mNv3lNiAKZZPZP4eAAUZ8j NputPfcch4/rlsKJdpGm3lxHYX0cirI= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1B94213637; Wed, 29 Nov 2023 17:10:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id AycXA4pwZ2V1DgAAD6G6ig (envelope-from ); Wed, 29 Nov 2023 17:10:34 +0000 Date: Wed, 29 Nov 2023 18:10:33 +0100 From: Michal Hocko To: Dmitry Rokosov Cc: akpm@linux-foundation.org, rostedt@goodmis.org, mhiramat@kernel.org, hannes@cmpxchg.org, roman.gushchin@linux.dev, shakeelb@google.com, muchun.song@linux.dev, kernel@sberdevices.ru, rockosov@gmail.com, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH v3 2/2] mm: memcg: introduce new event to trace shrink_memcg Message-ID: References: <20231123193937.11628-1-ddrokosov@salutedevices.com> <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: <20231129165752.7r4o3jylbxrj7inb@CAB-WSD-L081021> Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spamd-Result: default: False [-3.80 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-0.993]; RCPT_COUNT_TWELVE(0.00)[14]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_NOT_FQDN(0.50)[]; FREEMAIL_CC(0.00)[linux-foundation.org,goodmis.org,kernel.org,cmpxchg.org,linux.dev,google.com,sberdevices.ru,gmail.com,vger.kernel.org,kvack.org]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: -3.80 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 pete.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 (pete.vger.email [0.0.0.0]); Wed, 29 Nov 2023 09:10:51 -0800 (PST) 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. -- Michal Hocko SUSE Labs