Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp37158rwd; Tue, 30 May 2023 15:49:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ585dX1P2dMUL1Y5uxEREJQL/+1A22/ftZvLwbTYjTcwCiAIU9JQqr7NIPb+LfagAcNM2mK X-Received: by 2002:a17:90b:4a83:b0:256:991a:19e with SMTP id lp3-20020a17090b4a8300b00256991a019emr4072867pjb.9.1685486995718; Tue, 30 May 2023 15:49:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685486995; cv=none; d=google.com; s=arc-20160816; b=bUnTwtDT8y3/ZWDgG8PaK2JB3ZT5I09mkcBPfT1MWf+lXscqWGLT3exNUA4vTfMvdM fFyd4+ISdszbP4MTSSdQrT+aStaSx6oEbe6G3WdUqvEV/2UzWkTSAdHTWLpCDpYe8BfG /piLz9FpuwoaGmA+jtlKAYxcDByDthQDY0RX1/2ts4KY4HpG5u/xQZ1FB1Z5GeIOJQGQ T8jfv/a6IdBkHg60O0MFjgFeXW9gaZ7DAF3SflIqJ9TAdkLw7tymu+PyXn2n7hMsa2RP Ei+Os4Typl1km9f77deHWvwWHbww0vfQ6k9ShfTBxAekTFKxLEicbKWlOIm4fcIqxNwI AQpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=S8YsG2kGCzZTcAXVpp257yufysCh3j1FXhrWkfRl/EQ=; b=UEdml1VdWv3esRcKENPv7xCfViNaF3G8Q+7rc+ba4pDmrQnspGWtIr/UZtmiUL5/9K p9muTpyWWnCdKzNZXyqBm10SybksRpbV13nGUgwOjCvBENm2zWU7LsqjkhLTNIEEcUD6 Oc8QOATzHQ6nmCo+mVrPD/LvdvB7kfRHFY6LtCzWSKzMCTpPSbTiUYJR1c5Wl0oU7hqD QljJ32agoNCYjKtHJ3dufwtykVQ3heiEBJ/o1NHr4oERksOh83mjGGiClauecj30yGrs r9Qtmnm9+6nr1dEBlZ1NppCA6hByaiqK0heX3NfB2R3pv1bTqy5EMfIv+s2QgLfKb7IE 9+3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=IwKTc81H; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h5-20020a17090a3d0500b0024e12dc1e4csi7968740pjc.86.2023.05.30.15.49.42; Tue, 30 May 2023 15:49:55 -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=@linux-foundation.org header.s=korg header.b=IwKTc81H; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231668AbjE3WaK (ORCPT + 99 others); Tue, 30 May 2023 18:30:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229946AbjE3WaJ (ORCPT ); Tue, 30 May 2023 18:30:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A786D93 for ; Tue, 30 May 2023 15:30:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 24EA9634AA for ; Tue, 30 May 2023 22:30:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31F46C433D2; Tue, 30 May 2023 22:30:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1685485807; bh=L4WaZnpCGMusMfNexWgFq61vWT+q2ikrfQ3r1nuz2S0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=IwKTc81HJpslhXJQN5IEtsr3d+TJO57tr578zquodCfzAMkk/I/MoBv3tKbfaP/Gy RyO20aVk5oH3P80fJUR9n7XZrnv8lhbsPMnhn4DiffPpoghMmu654t22hbH7BnSSKj 3q74qIvseKB9kf0ndga4hv//j0yIQBcO0VlEdmJA= Date: Tue, 30 May 2023 15:30:06 -0700 From: Andrew Morton To: Nhat Pham Cc: hannes@cmpxchg.org, cerasuolodomenico@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com, yosryahmed@google.com, kernel-team@meta.com Subject: Re: [PATCH] zswap: do not shrink if cgroup may not zswap Message-Id: <20230530153006.8b73c276b1aaf5c3275f0b3f@linux-foundation.org> In-Reply-To: <20230530222440.2777700-1-nphamcs@gmail.com> References: <20230530222440.2777700-1-nphamcs@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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, 30 May 2023 15:24:40 -0700 Nhat Pham wrote: > Before storing a page, zswap first checks if the number of stored pages > exceeds the limit specified by memory.zswap.max, for each cgroup in the > hierarchy. If this limit is reached or exceeded, then zswap shrinking is > triggered and short-circuits the store attempt. > > However, since the zswap's LRU is not memcg-aware, this can create the > following pathological behavior: the cgroup whose zswap limit is > reached will evict pages from other cgroups continually, without > lowering its own zswap usage. This means the shrinking will continue > until the need for swap ceases or the pool becomes empty. > > As a result of this, we observe a disproportionate amount of zswap > writeback and a perpetually small zswap pool in our experiments, even > though the pool limit is never hit. That sounds unpleasant. Do you think the patch should be backported into earlier (-stable) kernels? > This patch fixes the issue by rejecting zswap store attempt without > shrinking the pool when obj_cgroup_may_zswap() returns false.