Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3010060lqp; Mon, 25 Mar 2024 16:51:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCULt5ZwXYLnq1nDgqsIYNFp6mjmgRpCUcnGvWC6ktHDWAAjRrrMJYU1VCf0t6RY8SN8ZYr5Z16QSZsQHbeF8OZGh+6WKCmezuqjDlDJ/w== X-Google-Smtp-Source: AGHT+IEwDp7jLU5XqoNHmpjjO/uY0iZqcKcVHvdfT++XzRTFPnWWO78N/mddu5J7MUl2nFJcKs77 X-Received: by 2002:a05:6214:410:b0:690:77b9:a415 with SMTP id z16-20020a056214041000b0069077b9a415mr9054189qvx.50.1711410708130; Mon, 25 Mar 2024 16:51:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711410708; cv=pass; d=google.com; s=arc-20160816; b=aDBU1V3yyVSUCkqDdOqyCycxIFuhUPsfEWx1PuDuyp5DPuoOii32JlcwATPgqNCj+e 2LDkq9euyMuFIuq8F7q9eCyHo04GWfTnA3B7hcOzkamwLX50K6/dhdbTufbhsOqvNutR bC/nIBYQIHMLe6uH+40khFeGg6FgCL5xRh96FNizhZ1M+erAbOs9OY1EJ2eJTqRoTVUZ XDxQda2mk8VHFi5r9/hXduK4IxWqcJZoqzVqq6Ru7678h8fhmfm8bvMuL3ltdnMUBkSq s00XVFIUJCwlvI7wanzPo/JxxoTZ2SBDLJl0uR38/KglZ5eEOvAmy1MsLzmd4qdRkmr+ sCsQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=KO2q76LvMLcDayey/RN5wyIAuuRCIUh2utVXFGvhTms=; fh=zH+ykh5WwcOhlPp7IXltpYgmnnvtNBm/pMjg5vDB/YU=; b=LSY1CpKiXk9zQEDPj/xsHccykvL7v1vpJrlhrE/zZJnicS8Yg0yFc7lwjx3bHKaUxE RhJdOWfnh1zFUYp4Y1rQfB8X9X2U1xWQDo0DLXZaD8r4PbNkSRYThzvA0wBeYt/LfnW7 GwBtd4DedC1MZN8l4eGPoJQ4eM1gWwg5u/DqVmfGVfCoycD9qmtuLPDuclXrA7BI9mBN rpwG36TkQMhSWJDg05YY9eEDM/qyYFvcgOssHl3FDvGtw/xnLW6mWI1JlPLtvAw3+VH/ +CmxjzGMHpngtJ8jyisllnezYTsl/WBPG7s/B6tdA/qxQSFfJ6p3c63mf/fy+1RVZBH0 nM7w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=BdUFuZPc; arc=pass (i=1 spf=pass spfdomain=flex--yosryahmed.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-118191-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118191-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d5-20020a05621421c500b0069671053dd0si7688534qvh.198.2024.03.25.16.51.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 16:51:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118191-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=@google.com header.s=20230601 header.b=BdUFuZPc; arc=pass (i=1 spf=pass spfdomain=flex--yosryahmed.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-118191-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118191-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 C009A1C3AA65 for ; Mon, 25 Mar 2024 23:51:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 216AF128831; Mon, 25 Mar 2024 23:50:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="BdUFuZPc" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A44D684D2D for ; Mon, 25 Mar 2024 23:50:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711410636; cv=none; b=GSJhdTCMevmm7h6jgValq2fhxpqESSTuwAwqc848G2IDz9eZHEdKav5aHcds2bL2AAD7+mWWXgAK6nYYPLHhQbw9PppWRWXeM8obwlfeDmxgG40OBGmYKpezqIGvKX/BUKi0OA562AazR/A3sbBfJUM7pxr9a+o0lXV6cFSCzvw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711410636; c=relaxed/simple; bh=1ETm0Kb/hFLFDlFEAvOSDyN5Z9LPHRKS7vvJJ/LpulI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ozyijLqEOU8THTiz0tOc5++894vIRDIrYMcisz6PF0cuyTkJNqxsSyV8HMx1kOkKLLY/QDw02YTDlxtEOv+h7kAp71Buf4sF2p812685Payjigw8Lbl+V0xqxzJ6RzLLKWP/Dkb+RAtCaV5pijMGbpLbQzo3kyzMAsatC0+9i+Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--yosryahmed.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=BdUFuZPc; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--yosryahmed.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dd944567b6cso6712983276.2 for ; Mon, 25 Mar 2024 16:50:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711410633; x=1712015433; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=KO2q76LvMLcDayey/RN5wyIAuuRCIUh2utVXFGvhTms=; b=BdUFuZPc/DzYe3O+g2m/cdEFg97bSr+3WUmHdMInMEFTF8s49+PqB6fxqH3rfUOwEF ZoDRpD5Dyb2OhvP098bfaKsAHqkfV+blDb0utrkKE5WbpU9WEh3p8VU9WGpUQuLFX5lx WfbF1Xlg7WOTiSu4fJiCSBds6s7TG6ur0FIFEwhQeyJyI1eKTXKlcsJwZzoVygW6Jss2 vNlpuVIyKL+6/1FrtwIu9rcHaQDmxFfNWkbkCYhJqFNJWwNllnAR0gNLWMwDsXdIitOd mqT/G4Zz0f/ijuJ090ZRO2hz7HgZnEkXj+2CNwiPqHh22IW5bNDSokEb61WQGBuS8Se0 2bHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711410633; x=1712015433; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KO2q76LvMLcDayey/RN5wyIAuuRCIUh2utVXFGvhTms=; b=bYqKB522o1NnI3QRzJil2k/Ldp+qylGCSXMiCTsfEQTJdGLqXQJN4iBCLofVECMu0F fDXTadTxQvTPlfrHemtB6krYg2IbWEnCKxuwbNqeLIgd7BJUNnBKotrCr4wnJ5XDcrdV +NIZwDBL7BxgRxRK8iLr+usm5ZK8wy2+38fV6tGq02rkrd+ENl10xB/L4DllEQRP7Gkd GSNR85oFtMnCCluEWfa3mN0FjZ02DKHTy1jUzIaLnjux7UxjnYR8tUDl/jHaescjvEDn Yfz7Ca/E7f9BDx5FqyvFgYBZ9xUMhrcNrEd/ZawPEO8opQqqdsK7LmKlaWdgQlJy8npE 9IDg== X-Forwarded-Encrypted: i=1; AJvYcCUKxsqI9qz1cwnCIy3V4UFZBuO/qKgpjORYr+3wPfEw3K2JwZOoGp5V1r/1PDoV+1s/D1Gz/j2mTpw7t/Ft6xYXMaZZEgOSz4s3US8J X-Gm-Message-State: AOJu0YxD/2GiI/NVDusHxvlbYiI6w+4hafbJkNUwW1A0y6myqCFtJQK4 s37oKjsEK1zXlYx6iXquF7iQzI4ysnr9NpYa1E2/nbsexv3uTzPxsepqi8jFxCLHzLwFLHfE5j+ tAC6CvTD3gPQYZO4q2w== X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:6902:1241:b0:dcc:4785:b51e with SMTP id t1-20020a056902124100b00dcc4785b51emr370308ybu.12.1711410633551; Mon, 25 Mar 2024 16:50:33 -0700 (PDT) Date: Mon, 25 Mar 2024 23:50:16 +0000 In-Reply-To: <20240325235018.2028408-1-yosryahmed@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240325235018.2028408-1-yosryahmed@google.com> X-Mailer: git-send-email 2.44.0.396.g6e790dbe36-goog Message-ID: <20240325235018.2028408-9-yosryahmed@google.com> Subject: [RFC PATCH 8/9] mm: zswap: do not check the global limit for zero-filled pages From: Yosry Ahmed To: Andrew Morton Cc: Johannes Weiner , Nhat Pham , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yosry Ahmed Content-Type: text/plain; charset="UTF-8" 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 --- 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++; -- 2.44.0.396.g6e790dbe36-goog