Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5842172rdb; Thu, 14 Dec 2023 00:39:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IGLhg8HQRYj9NdJKWBsRCjyyATjD5XeVfTD6vxbnOJNJlg9l1mSi2tq52WkeAuMrvVRWZaN X-Received: by 2002:a92:c8c1:0:b0:35f:75e6:547e with SMTP id c1-20020a92c8c1000000b0035f75e6547emr1830268ilq.65.1702543155064; Thu, 14 Dec 2023 00:39:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702543155; cv=none; d=google.com; s=arc-20160816; b=c8ZmLC8DMYku9uyCgiL/oW9xIMHLRLse7aef3UXHXEQ6uL5mjavCpzlmYH7biZ8lmf UEapV5AWl+Obp4EcQh8ywc3w0RTABjiPhwyIreV45gMuDF7re+U3YSug1ZHAqPz/Uqv5 3n6enyE8CpSqZx2R/js9OiLa+AShqZF7hywOzmguw8BTfgQOEyf++TEyOOQb2KWWhTOE H2MFFTOXDOsI4K3UtzoAmd5FYbOrdmPsoFPjhX0MWJjePC/u8/6AFsIGu6PWdEGN7Gr5 3Na2NUGEYgogmMr2kazgeaTULhv3qXhgyV7oLp/naz5fnRoDWqSTPGuMzeyHDb3ATC1l /6QQ== 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 :dkim-signature; bh=yCAxAN1l9jaJtTvJ6E9N1/DLsGXk6YJuQMAKVwbliB0=; fh=BKPz0Dl3+ln997KOXKHX1vgz5/wV62k9pdMrCecT1zE=; b=msBlI7b2akgqqhzpo/oo8Yu8vdjoBW3xup7lG2XiNIKt0AhS2v+hKTRk6diuuPbZIF jQ/D3n+wnWZrsuxidoQJU7f8Pl8jTijkUm1yrAePhTEBgz4H8qVkjFpORnR1l8GFWdF2 dtZVYerW/jL8m/qNmBXCfciLcA9jAsxGTRLU6Ub9am0umChleghlJOMklCQ3BVpJyxoE gqEbcY2sGHfHbI6B6nWdXMZXNpMp8hqghV5Ow6TbQm8bTW/ZAGCJaulGKSiBXAFNARAS n6Ryu3WnGI8uS+l0p9OptNLkIjrCtlTG3t0mnWN0esTqbx2W3HAI4sGsUVpBzNENNnKa ilfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=jm2D6nlG; dkim=pass header.i=@suse.com header.s=susede1 header.b=jm2D6nlG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id b2-20020a63eb42000000b005c278e32054si10691159pgk.677.2023.12.14.00.39.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 00:39:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=jm2D6nlG; dkim=pass header.i=@suse.com header.s=susede1 header.b=jm2D6nlG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 8736F80278AC; Thu, 14 Dec 2023 00:39:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234438AbjLNIi7 (ORCPT + 99 others); Thu, 14 Dec 2023 03:38:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjLNIi5 (ORCPT ); Thu, 14 Dec 2023 03:38:57 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0148ACF; Thu, 14 Dec 2023 00:39:02 -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 74579221EA; Thu, 14 Dec 2023 08:39:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1702543141; 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=yCAxAN1l9jaJtTvJ6E9N1/DLsGXk6YJuQMAKVwbliB0=; b=jm2D6nlGxrfWaNWs67pvBi/wEynw0hspA2+7z1brnkX0MUXtXojcOa7O8ly/Ift9ccBbpj rpeEQ/B847cdi7Uz5kl0f02DHFgfdsBndRg3fG82R6EXtIEzhEUW6a4VL9ptag7Q1kKrAy nyyCeUXsT6DAipwIa6ny8RE3nmhPNjc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1702543141; 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=yCAxAN1l9jaJtTvJ6E9N1/DLsGXk6YJuQMAKVwbliB0=; b=jm2D6nlGxrfWaNWs67pvBi/wEynw0hspA2+7z1brnkX0MUXtXojcOa7O8ly/Ift9ccBbpj rpeEQ/B847cdi7Uz5kl0f02DHFgfdsBndRg3fG82R6EXtIEzhEUW6a4VL9ptag7Q1kKrAy nyyCeUXsT6DAipwIa6ny8RE3nmhPNjc= 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 5465D137E8; Thu, 14 Dec 2023 08:39:01 +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 rIyuESW/emWAOwAAD6G6ig (envelope-from ); Thu, 14 Dec 2023 08:39:01 +0000 Date: Thu, 14 Dec 2023 09:38:55 +0100 From: Michal Hocko To: Dan Schatzberg Cc: Johannes Weiner , Roman Gushchin , Yosry Ahmed , Huan Yang , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Tejun Heo , Zefan Li , Jonathan Corbet , Shakeel Butt , Muchun Song , Andrew Morton , David Hildenbrand , Matthew Wilcox , Kefeng Wang , Yue Zhao , Hugh Dickins Subject: Re: [PATCH V4 2/2] mm: add swapiness= arg to memory.reclaim Message-ID: References: <20231213013807.897742-1-schatzberg.dan@gmail.com> <20231213013807.897742-3-schatzberg.dan@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231213013807.897742-3-schatzberg.dan@gmail.com> X-Spam-Score: 1.74 X-Spamd-Result: default: False [1.74 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; BAYES_HAM(-0.00)[30.96%]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; R_RATELIMIT(0.00)[to_ip_from(RLhyf994aoi9gdt4d63rk4ux49)]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.16)[-0.806]; RCPT_COUNT_TWELVE(0.00)[19]; FREEMAIL_TO(0.00)[gmail.com]; 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)[cmpxchg.org,linux.dev,google.com,vivo.com,vger.kernel.org,kvack.org,kernel.org,bytedance.com,lwn.net,linux-foundation.org,redhat.com,infradead.org,huawei.com,gmail.com]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] X-Spam-Score: 1.74 Authentication-Results: smtp-out1.suse.de; none 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 agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 14 Dec 2023 00:39:12 -0800 (PST) On Tue 12-12-23 17:38:03, Dan Schatzberg wrote: > Allow proactive reclaimers to submit an additional swappiness= > argument to memory.reclaim. This overrides the global or per-memcg > swappiness setting for that reclaim attempt. You are providing the usecase in the cover letter and Andrew usually appends that to the first patch in the series. I think it would be better to have the usecase described here. [...] > @@ -1304,6 +1297,18 @@ PAGE_SIZE multiple when read back. > This means that the networking layer will not adapt based on > reclaim induced by memory.reclaim. > > +The following nested keys are defined. > + > + ========== ================================ > + swappiness Swappiness value to reclaim with > + ========== ================================ > + > + Specifying a swappiness value instructs the kernel to perform > + the reclaim with that swappiness value. Note that this has the > + same semantics as the vm.swappiness sysctl - it sets the same semantics as vm.swappiness applied to memcg reclaim with all the existing limitations and potential future extensions. > + relative IO cost of reclaiming anon vs file memory but does > + not allow for reclaiming specific amounts of anon or file memory. > + > memory.peak > A read-only single value file which exists on non-root > cgroups. The biggest problem with the implementation I can see, and others have pointed out the same, is how fragile this is. You really have to check the code and _every_ place which defines scan_control to learn that mem_cgroup_shrink_node, reclaim_clean_pages_from_list, reclaim_folio_list, lru_gen_seq_write, try_to_free_pages, balance_pgdat, shrink_all_memory and __node_reclaim. I have only checked couple of them, like direct reclaim and kswapd and none of them really sets up swappiness to the default memcg nor global value. So you effectively end up with swappiness == 0. While the review can point those out it is quite easy to break and you will only learn about that very indirectly. I think it would be easier to review and maintain if you go with a pointer that would fallback to mem_cgroup_swappiness() if NULL which will be the case for every existing reclaimer except memory.reclaim with swappiness value. -- Michal Hocko SUSE Labs