Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp274325lqh; Thu, 28 Mar 2024 01:16:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUB8VNqY6KJSrcKauraVZm+P1as4+JWSF/AzW9faQZNDFHbLZkCWjO8ESlqgfj1X6lwpmJKrp41GcmCWVFX/yCX18ZrpQj6/WV6M/Uu2w== X-Google-Smtp-Source: AGHT+IFFcyDkk4I+8/t0DrX5elbSTjR+DZ7gdVwbh7Vjz9vffx8JrsI4BlDf8x3A1S7sCRLBGJgF X-Received: by 2002:a05:622a:178f:b0:430:bd04:ad6 with SMTP id s15-20020a05622a178f00b00430bd040ad6mr2345512qtk.34.1711613780627; Thu, 28 Mar 2024 01:16:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711613780; cv=pass; d=google.com; s=arc-20160816; b=i89ZZqzY2TggEACaXvC/rUp1qRImnCL6IP6OiJlTfXj01YyMsMroW976YXVB5bWpeF 6aiALyh9oooX+/WDtHIyB7S3EKkOTHujH+QTCTrXORZybtTCHT0sM4IQ1NGrYSI+uS39 4f35vQmqpftg84V5MHZDE7XIwDiUHGyeP5kA1Lnsc3i9+koszVRuqttOV1tuSkL/e7Ep KTP4/sjg82knm4QjeNl4/bRZKvdaM5TwB86QVKRa7sMZZASRjvmOd3vMllcSwFLkpMXL ybac6XlGVKh9KqPSyy2zn2VEFL00AAE3bGoRytToi9LoBxXHBKmicWObuvcMPN6U64tz +wNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=5tn2JXPtKgDb/RvnAaA2HxiulPKE1lezZ4kqGlrru2k=; fh=+6tuBzjp2pMpjT9dj+vXx1AyjiCreJh73RbziTYZDRw=; b=jWVGd7OHQXZo6GbBh+618O7EWBVtRMNxkDkFiEgaU2X+KGZCKhVXQ9E0njp1P1GmZp FLKIKSkPJXrC3RHyMgx9TkSN1l/DFD+H/FUv775oGiapO6si0ZlwUSbyW/si7RwDc9+M +EFJsleVk6fI8doIua9zB10DZTYr12uvrYH82z8DvaZpQS+RyDk49ehaE4bZ6QjBbsf4 l0r9x5mYJ10mjsYN9wH84ej+cTRUWGFKPH0AA1yoWnpIZ4odEAb/Ixvy6pHkEN2N6c6A pqOLKyPzHoNVI6vj5BB97ZOXv9jDsuaoaXNJJxSlAjHPddvWocBl9H7JG4wY+Udbm0+j N3Og==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=kOMXbJDC; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-122574-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122574-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v14-20020a05622a188e00b004318e8e160csi869389qtc.647.2024.03.28.01.16.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 01:16:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122574-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=kOMXbJDC; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-122574-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122574-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5BBB91C2C918 for ; Thu, 28 Mar 2024 08:16:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1DCB953E3B; Thu, 28 Mar 2024 08:16:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="kOMXbJDC" Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13DE017BB9 for ; Thu, 28 Mar 2024 08:16:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711613769; cv=none; b=VrxmhjmbXsLKN/KcYa3o5II3qkkhYblW7xBhvNCtYlu7tZt+v4p+Z8DRqdKQIXp2qH3sgqpHK2f0CG3L32s+x6jRAwfSF5AIYF6eCcXo7wyAp5mU+hElmrz0RdtIKHlTEuaJMxM6w+T/Vehtj/pJLMqRej9wbAYXewCBKhnq/sE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711613769; c=relaxed/simple; bh=dlGKVS+WvTf5/rAhT2E+OEMVaU2rjznUwxa7cmPIehw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=nKLUkcThhTqlbAf9e8pVMdSvW//j9TwEiMkHgue/eHLIapiVmoaLTDQrevv9x9AZEhfSaVupNrRef9o5qEB82q9CyfpQSEffs8rNZsOnrEjg0MKYgmCi9Xs4dLN8+SU+3BsqjML5TNgibKWK+fHoVEPXLfmAHrIxw0Yx1o5iRhI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=kOMXbJDC; arc=none smtp.client-ip=95.215.58.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: <160b54f1-b578-40d5-a977-00b71fd22e34@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1711613765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5tn2JXPtKgDb/RvnAaA2HxiulPKE1lezZ4kqGlrru2k=; b=kOMXbJDCyhekg4mdOuMJGuSHoVXwmrSC+tdEiXJm6Th2+sFjCM1dfRMYPcqQXINLd7J/2T xKLX06BUo0aabg+gmiTVW9sr7eMDj9ruk2h/27JDhTMlSusDB24NCxEsTSWmNtxx8adi0x 5n1miXWD9XczovsTmc8kX3cEoqQQ0Ds= Date: Thu, 28 Mar 2024 16:15:49 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [RFC PATCH 8/9] mm: zswap: do not check the global limit for zero-filled pages Content-Language: en-US To: Yosry Ahmed , Andrew Morton Cc: Johannes Weiner , Nhat Pham , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240325235018.2028408-1-yosryahmed@google.com> <20240325235018.2028408-9-yosryahmed@google.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou In-Reply-To: <20240325235018.2028408-9-yosryahmed@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 2024/3/26 07:50, Yosry Ahmed wrote: > When storing zero-filled pages, there is no point of checking the global > zswap limit. These pages do not consume any memory that contributes > toward the limit. Move the limit checking after zero-filled pages are > handled. > > This avoids having zero-filled pages skip zswap and go to disk swap if > the limit is hit. It also avoids queueing the shrink worker, which may > end up being unnecessary if the zswap usage goes down on its own before > another store is attempted. > > Ignoring the memcg limits as well for zero-filled pages is more > controversial. Those limits are more a matter of per-workload policy. > Some workloads disable zswap completely by setting memory.zswap.max = 0, > and those workloads could start observing some zswap activity even after > disabling zswap. Although harmless, this could cause confusion to > userspace. Remain conservative and keep respecting those limits. > > Signed-off-by: Yosry Ahmed Yeah, it looks reasonable to keep the memcg limits check. Reviewed-by: Chengming Zhou Thanks. > --- > mm/zswap.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/mm/zswap.c b/mm/zswap.c > index efc323bab2f22..9357328d940af 100644 > --- a/mm/zswap.c > +++ b/mm/zswap.c > @@ -1460,9 +1460,6 @@ bool zswap_store(struct folio *folio) > mem_cgroup_put(memcg); > } > > - if (!zswap_check_limit()) > - goto reject; > - > if (zswap_is_folio_zero_filled(folio)) { > if (zswap_store_zero_filled(tree, offset, objcg)) > goto reject; > @@ -1472,6 +1469,9 @@ bool zswap_store(struct folio *folio) > if (!zswap_non_zero_filled_pages_enabled) > goto reject; > > + if (!zswap_check_limit()) > + goto reject; > + > entry = zswap_entry_cache_alloc(GFP_KERNEL, folio_nid(folio)); > if (!entry) { > zswap_reject_kmemcache_fail++;