From patchwork Tue Jun 11 02:45:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13692773 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BADAEC27C4F for ; Tue, 11 Jun 2024 02:45:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 427426B0093; Mon, 10 Jun 2024 22:45:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D77E6B0095; Mon, 10 Jun 2024 22:45:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C7516B0096; Mon, 10 Jun 2024 22:45:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0CCE46B0093 for ; Mon, 10 Jun 2024 22:45:22 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AEB521C1DF7 for ; Tue, 11 Jun 2024 02:45:21 +0000 (UTC) X-FDA: 82217066442.19.A4968D2 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf07.hostedemail.com (Postfix) with ESMTP id 07D5940013 for ; Tue, 11 Jun 2024 02:45:19 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Xbd1LLAb; spf=pass (imf07.hostedemail.com: domain of 3PrpnZgoKCIsD376Dpw1tsv33v0t.r310x29C-11zAprz.36v@flex--yosryahmed.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3PrpnZgoKCIsD376Dpw1tsv33v0t.r310x29C-11zAprz.36v@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718073920; h=from:from:sender: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:in-reply-to: references:dkim-signature; bh=Gw2fVBeEZMK663ax5icKG8q0wolcMNh0B93tTF9ptJo=; b=iQh7oQw6w5S70uiyMwc5AvJsNBCi1S+kDuH0T8lbEvs1Nr6QpdfhZzyzmykWpq5MyhnjY8 ye15QXqAagd3CoOymf8u+q/AnLb0AmcNkSp2XAJa5lPPb2LpvFw/ObkySCeTC/qeT8uGa9 jmGkENhHJqYsnNUOK1qwWZfIrbvH8Zc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718073920; a=rsa-sha256; cv=none; b=eOO6Vi90rNfJz3xN/DZ/KCdVs+R2kT2Xe1p05LNEDHglot9ei+R2SzUkufHeuN4OtDhrDb gZDPydB3jSTMlJFenvYnzJ6WJg2Ucf+fnYyHpH4T8220CKDAoymaAI6GknWtjZN02Jltvg dYjCE9OwZtfwWEnMi4WzcadwhNRqvVs= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Xbd1LLAb; spf=pass (imf07.hostedemail.com: domain of 3PrpnZgoKCIsD376Dpw1tsv33v0t.r310x29C-11zAprz.36v@flex--yosryahmed.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3PrpnZgoKCIsD376Dpw1tsv33v0t.r310x29C-11zAprz.36v@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dfb17fb0fb6so4546480276.1 for ; Mon, 10 Jun 2024 19:45:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718073919; x=1718678719; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=Gw2fVBeEZMK663ax5icKG8q0wolcMNh0B93tTF9ptJo=; b=Xbd1LLAbh+lT1xUBC1sOP67m8v+rb/4+aAMsUZv1DSfPSx7oQ7T2+6U1pywTy2SXSM ESPRFM5Q0Xd79wycOo9Oumra9Cok87j0+OLPtklpBoS5cvlVzzUin0zK8bkLkEJGpB2P fV9zfL+wghfqrNj0Z05aEzRBlh8ObC8rjBZW6ZJlF5EumH4maH6v0V341YyuXYj9Az3W 2LrtKxdLXyu3lmprhVjfZUUpZFB7QlESz0FHxVHwjE/ycyQLu+ojpDBWH97sBPdFcEaM pCbUmTCf2Hm4FL+c7Uf0iTKp8Pn8MtDc9T3wQFJMDHi85n5VI7Ngs6Wg+aoiGZt4CzB3 Gr7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718073919; x=1718678719; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Gw2fVBeEZMK663ax5icKG8q0wolcMNh0B93tTF9ptJo=; b=KR0WT4RC365yBPWB2Ln5DSIBmLpYST46yAxUIiGE4xTrV8Kq06k4cWIRUzGbZ92OZk 0QTeHr17zaFGJWu7VpUZV6pzrB0EIpzaTnr0ZuFPnaxx+kZsBqEbV+CLqR0yVeULA1/g mfEZ8v6Z8qly4Z712FvCVcBiM1orHIlesV3UWeX6ZdAWMVS5AQz62xJZOFCBu+s/ILQV 9MINfIzpSU632vsGOFymEqsROYyqb0S6ol7sEsMiE3JCAGyazI9xdrlCVfZwJ4JR6Ul0 ZVYAVOb1lY+/k1jWjXafPE77C6TOnjqDJhzK9WX27Mc0olOlKQ0W3pGYkxRGnLxDbCyv pGtQ== X-Forwarded-Encrypted: i=1; AJvYcCWwMgio6+P4EvR1pVFA3gb1YlQ3QkVO/u4arMVYTepi7rBbWDeeRR+AbRUuoSfFzOe4r7F5+6cZIM72jICfBBlzNqM= X-Gm-Message-State: AOJu0YwEW3aXVOb96F9bzC2M32pF2si2LWL6os4U9nM60rwl3JBFfxmM 0ymBe4k7il9JAXLgMm/QKlk9s1xjuy/Hz9gn8n9nilgVVbI/7QK1u04LP/IhebcAWKyHrusWnp1 PCCtJ2sV4vG1MWh0loA== X-Google-Smtp-Source: AGHT+IErIy1eYfnrABkOmVD9J5eyfhJx+kNkb/sBrRXlcmpYHfut7tKeNb+mtfB4c//I0/TnhK97XtmSed3uvDPF X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:6902:188f:b0:df7:8c1b:430a with SMTP id 3f1490d57ef6-dfaf64ea35emr3779077276.3.1718073918970; Mon, 10 Jun 2024 19:45:18 -0700 (PDT) Date: Tue, 11 Jun 2024 02:45:14 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog Message-ID: <20240611024516.1375191-1-yosryahmed@google.com> Subject: [PATCH v3 1/3] mm: zswap: rename is_zswap_enabled() to zswap_is_enabled() From: Yosry Ahmed To: Andrew Morton Cc: Johannes Weiner , Nhat Pham , Chengming Zhou , Barry Song <21cnbao@gmail.com>, Chris Li , David Hildenbrand , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yosry Ahmed X-Stat-Signature: b76i3ayt7bx5nbhtbzkojxi93cnktath X-Rspamd-Queue-Id: 07D5940013 X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1718073919-549411 X-HE-Meta: U2FsdGVkX18KPQqYHJeXiJgee2V5mm1IR386qFY3ShVtZ0yXD9Z1Rn+b4p2mcdXTehHDOCygO2w1Q1cGwQ07m5oad2lJ0DLMGpxWxVzj2ZaOKyCU6fkGNUsZgxVw1x/IiVAX85VvDrRbo7nsObWi23BJTrybFrvVc2yfsjr3d8cf/YOidm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Lwezgvpj9C1RUfiCxzKhlFTZ9KTGgEAAhI+o5+n149Q/0qqeuXVp+ZObZukFdMlpe5BPHFG5DNjvaMGe9GVorRpLEexQ6m5k9aD4Frw71zTTi7j9Xt03j44kUMavnYe+WOoQch15ArNfCJqtx31XQtBDOWy1LG1D6iy2Vra5m3+QKfuVEc+jGVqHA0jflrkpZGkOZIw7YZvIsW4S5gkOntEKf8OdN12woN7B6OC3G7/0rt3YPSfTPngzzmCR2HetGp5yYqslgNbYymm3i5Fxzemj8mmOBQle15X++sv/+faV6qfTjMypkESvRatdfDQXjKeb/JQQTPFA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In preparation of introducing a similar function, rename is_zswap_enabled() to use zswap_* prefix like other zswap functions. Signed-off-by: Yosry Ahmed Reviewed-by: Barry Song Reviewed-by: Nhat Pham --- include/linux/zswap.h | 4 ++-- mm/memcontrol.c | 2 +- mm/zswap.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/zswap.h b/include/linux/zswap.h index 2a85b941db975..ce5e7bfe8f1ec 100644 --- a/include/linux/zswap.h +++ b/include/linux/zswap.h @@ -35,7 +35,7 @@ void zswap_swapoff(int type); void zswap_memcg_offline_cleanup(struct mem_cgroup *memcg); void zswap_lruvec_state_init(struct lruvec *lruvec); void zswap_folio_swapin(struct folio *folio); -bool is_zswap_enabled(void); +bool zswap_is_enabled(void); #else struct zswap_lruvec_state {}; @@ -60,7 +60,7 @@ static inline void zswap_memcg_offline_cleanup(struct mem_cgroup *memcg) {} static inline void zswap_lruvec_state_init(struct lruvec *lruvec) {} static inline void zswap_folio_swapin(struct folio *folio) {} -static inline bool is_zswap_enabled(void) +static inline bool zswap_is_enabled(void) { return false; } diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 1303ed01bb5e5..a811dfff10cda 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -8469,7 +8469,7 @@ void obj_cgroup_uncharge_zswap(struct obj_cgroup *objcg, size_t size) bool mem_cgroup_zswap_writeback_enabled(struct mem_cgroup *memcg) { /* if zswap is disabled, do not block pages going to the swapping device */ - return !is_zswap_enabled() || !memcg || READ_ONCE(memcg->zswap_writeback); + return !zswap_is_enabled() || !memcg || READ_ONCE(memcg->zswap_writeback); } static u64 zswap_current_read(struct cgroup_subsys_state *css, diff --git a/mm/zswap.c b/mm/zswap.c index b9b35ef86d9be..a8c8dd8cfe6f5 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -131,7 +131,7 @@ static bool zswap_shrinker_enabled = IS_ENABLED( CONFIG_ZSWAP_SHRINKER_DEFAULT_ON); module_param_named(shrinker_enabled, zswap_shrinker_enabled, bool, 0644); -bool is_zswap_enabled(void) +bool zswap_is_enabled(void) { return zswap_enabled; } From patchwork Tue Jun 11 02:45:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13692774 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D542C27C5F for ; Tue, 11 Jun 2024 02:45:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E650E6B0095; Mon, 10 Jun 2024 22:45:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DEA0D6B0096; Mon, 10 Jun 2024 22:45:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD9386B0098; Mon, 10 Jun 2024 22:45:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id AEFFC6B0095 for ; Mon, 10 Jun 2024 22:45:23 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6C8561C1DAE for ; Tue, 11 Jun 2024 02:45:23 +0000 (UTC) X-FDA: 82217066526.23.F48169F Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf14.hostedemail.com (Postfix) with ESMTP id A1133100010 for ; Tue, 11 Jun 2024 02:45:21 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=I9MmHc30; spf=pass (imf14.hostedemail.com: domain of 3QLpnZgoKCI0F598Fry3vux55x2v.t532z4BE-331Crt1.58x@flex--yosryahmed.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3QLpnZgoKCI0F598Fry3vux55x2v.t532z4BE-331Crt1.58x@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718073921; a=rsa-sha256; cv=none; b=0MYfmMGcAk6udNyACi0jfMtdVndEapx1qNg07+OIuWh6l/HVMLZuW6lRORc5/0KnJUNj9T Vq652sMi52fOxh/ZWenlO0uJfqrGMSVbsW+Be13qG84v6eUzqnu3H/ee1BjsTYVF0bF6BX 34jxroZBoUZaWFiZOo0KjXCkAes1fm8= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=I9MmHc30; spf=pass (imf14.hostedemail.com: domain of 3QLpnZgoKCI0F598Fry3vux55x2v.t532z4BE-331Crt1.58x@flex--yosryahmed.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3QLpnZgoKCI0F598Fry3vux55x2v.t532z4BE-331Crt1.58x@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718073921; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=S76m/1rcjZ7HVm5h/HFj338IB29Gnxtti7cDrtc8pbk=; b=rwnUr9DvfJ8zm/sD8azrIyXZQ3Pi+aPGfLuPzq9Gvd27eEZDgYKKR6fslTJW13hQXNRLOR ZxCaeuCEjFLzhpPFuu/MftMDQIHaEToTqN+9Wxvr4wMjzkFpT+9HdnDzD0r2K2zQa/9BgK b3jWmIb2JW7I4pWVkHj+bZRgS7hbLsg= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-df7a6530373so9547466276.0 for ; Mon, 10 Jun 2024 19:45:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718073921; x=1718678721; darn=kvack.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=S76m/1rcjZ7HVm5h/HFj338IB29Gnxtti7cDrtc8pbk=; b=I9MmHc30MWayGktYkxHmoBVFjUGa1VB2f/cPg0jL1iS/P0FPjAXLEw2kfX34mO6bf2 XEHtyC37rdFx1FUqcUzNQHhh5gFTDiwasNPibK5udEOPPvQwtN4tYEP+A3yEpbYS78Fi 579NB07v05PRZEDcaMSTUlUgLZ8KPub9Qn8x4qoiY/3txN5IIyL6V0W+wpz92285RmYM MlbRu3Pp6/30a6s/XbQlNC+eLgiHVwRJ61wrGKUzku5Yj1M1MTVWe6ap4SVJeByqT0eJ ooSfYL8lt4HDdTOlgsEvE+ow4l/xC58L0aPsq4w7NTtXndyTJCk7gOmQAZTxzkxtU3lh XrlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718073921; x=1718678721; 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=S76m/1rcjZ7HVm5h/HFj338IB29Gnxtti7cDrtc8pbk=; b=fTWOkL2JHECREp1kF2cHSoj5IGWCr7MP3gwhZpLCuonEHGf2Q7l7HdEdyi32+Cg9cC Lzlbgopla2PQeDuXsvTzEWd+tWUfEV9mUdsFszRPbc3F8hdqnMvuBT+zJj/Zr6SxhU6y K2axMuIBK8pJ2c7JEtAkICxDQZjh+MgTW9yM0sSxbx3/5OSK/it8v8qpBGUIwAuR4mat kMS6s6c7g/M/mR5NV0B8e7yVEMID6TjAid0EMF+c/rwBY81KxSIoBc3mKM9lT+N99i4z QEcu26DGKSHltyBWnStxIohs5wVpJ2iheO8XjzovZFXZFg+Nx79/mZo8q8mM1vBmghcj 6HMQ== X-Forwarded-Encrypted: i=1; AJvYcCWzRarXLlRYMxxMXEjfqlj5Riz5FV+sZeh6Rh2jXLmkuRlnbIHJEvrWJ9/BWPuFwRpGcMcUFqP/x+4/IdJQIGawSUU= X-Gm-Message-State: AOJu0YxPGZEdGKZG9E4oTp9aTsTKAzYwkCiqYnXyVY4B5VYOBya3n6Gx W02yzKCY1LpSqB8keo4Sr+GW34JAMUXRq+dseg3zWpfA2YXnh3UdKaSWfmb1d04n1JM8la833Zn U/kMwPNOjCh6bdgeWOg== X-Google-Smtp-Source: AGHT+IH5AQc+Bn7MfrfWCQXqQIKB8mEd8d/y+h/Fxfn5heT9g/iCYqCbw9tsru+N/kEoD61LHDAlNGuosVHNQIrd X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:6902:70a:b0:dfb:230f:6c40 with SMTP id 3f1490d57ef6-dfd9fd42548mr435502276.4.1718073920696; Mon, 10 Jun 2024 19:45:20 -0700 (PDT) Date: Tue, 11 Jun 2024 02:45:15 +0000 In-Reply-To: <20240611024516.1375191-1-yosryahmed@google.com> Mime-Version: 1.0 References: <20240611024516.1375191-1-yosryahmed@google.com> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog Message-ID: <20240611024516.1375191-2-yosryahmed@google.com> Subject: [PATCH v3 2/3] mm: zswap: add zswap_never_enabled() From: Yosry Ahmed To: Andrew Morton Cc: Johannes Weiner , Nhat Pham , Chengming Zhou , Barry Song <21cnbao@gmail.com>, Chris Li , David Hildenbrand , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yosry Ahmed X-Stat-Signature: xhhk7drpm96xedugd6y841e4bgg7j1fy X-Rspamd-Queue-Id: A1133100010 X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1718073921-470317 X-HE-Meta: U2FsdGVkX1+Hj6xbV7si3XCyYydvvmfQQIsDug+rxNoRKY3buiDAWadC4DN2KV0fDqod5wdNu6u9o+8f8s010PV4P96EnOAM3DKAu+1QapBy4c8e5gZd7zNLSP+k1AiC5vA7vLPxVKwHn8EElrieJoLCY/3frEAtllYqhSfYX36buNdpn83+XzgLtff5rkaf6ykK9huAFAt5+Br+Sfo3qPXL/lVcCdL2GGKqRXobOnnus0D3jZNilvPCprVUfB2U0SMKHtucz54KIrWWrnRGhwkOBU95zqQ6lT05Lhty3nSDfP1vWlGI0Npr2t0qRfVn7S4LGEaGkRQL1db843ojY/thgX7N+96WhHEjDTStaGmjuXSsibG3L4V7d8yu0UXBhokZaStljToE88GticgeIMxJFApcgGmnbnRrSu42IPqf+dAgyjpOmhv98cqN3XtTaqGsfk/ZlwDohgXuhm51RZCmacbqyH/u/00iWAim1yo4erz0td9nrnzH0gC8zkn9qb2RPIlkF30k/QuIbTy+K9LhuE72VAtOA0Wjw6jhBBfMo0grDBGd1j2plmdp0JL/JL6qZPdCxWN6rPIpFB87J3bzj/iaoRk5VJEifDaLj3jLXE0nXtvDtt6rOAWFM7WHyj8obGrQXDn/xpphY/eQDHI1OAajlar+FkVcxeV8ZThhKyxrC72qzGZ9LjDh4ANWeOiezMZ77B5JPPoUPClppBmgR+gnkuwPgg7yzgqAyvCaybCDQbNhHhBvoQXopZ27iTVNpYN1LWOTiaq/WsZ8tBPspzXnujbASHpSGZLJ9qawNwJrz7OwqSCRjhM73n0gyk0gdzs2qpYoWGCTpxLzJD4awD/JONEJotlowMpApIkI2o+QCE2oM3kYrs0Kfv1s3ySsG4WspIRIo028tpmLQ9H812o95fj5VlWlJHf1DkR+NFGNkq8nRGFmdDjbbgoslyc/RrtYHDnUFH5TECs tkUqo3ZO Kf99jCPc65Qewom8Q7KGVzJsUWIGTxjenPqauwEKb3yHSzPlDw1KhVucxwSmDtgis2gZJj4+zzHtuvbclEgJZNt3e4uD8VQ7gUJ5+icJliTWA/Yf84sdTvZoKViH+SLa279S+Rewcdpz16tnaxgGaBSb4dZf43KW2BTSwNQnB08KUalMRfHM7pob/3cvxlNX1T8YCs2kBZSwnhNx5YW6h88PuzWIPazN8F4LSmOF+9L/eYKmidIYpgxJCCmJ5JsGUjj0idjuQm8U6JEWJqqbPtWcKO12Sm1VU3ZSQRifvfjyaXc5zlal53iXdsFicgC6rkLHAnEJJkhgzXV76j/UjmZ5ySzxEOM8RcvrBcvjSnR6MJ9QJxkQ+8eKutC6vbjkFaEBbmzX9KG5TiYfeVtZsqdq23yrhX8eSK9f8Dyw/RQfdgui/HGtUfRheI3AR5fN+MIhdACePF9HoqK8LKV/qGVqeHdJpmHqx3VQCaFuB6Dq/s7dwaE/jtWyY760cvMq5CPqwvRxM5IfC0D9NqHFyhpz0u7IDkHqW1FNjRnbGRBqhHBj29SdKN1VtG+L5w7prAAc522LVB9gxCzHAqhCmkBNJew== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add zswap_never_enabled() to skip the xarray lookup in zswap_load() if zswap was never enabled on the system. It is implemented using static branches for efficiency, as enabling zswap should be a rare event. This could shave some cycles off zswap_load() when CONFIG_ZSWAP is used but zswap is never enabled. However, the real motivation behind this patch is two-fold: - Incoming large folio swapin work will need to fallback to order-0 folios if zswap was ever enabled, because any part of the folio could be in zswap, until proper handling of large folios with zswap is added. - A warning and recovery attempt will be added in a following change in case the above was not done incorrectly. Zswap will fail the read if the folio is large and it was ever enabled. Signed-off-by: Yosry Ahmed Reviewed-by: Nhat Pham --- mm/zswap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/zswap.c b/mm/zswap.c index a8c8dd8cfe6f5..7fcd751e847d6 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -83,6 +83,7 @@ static bool zswap_pool_reached_full; static int zswap_setup(void); /* Enable/disable zswap */ +static DEFINE_STATIC_KEY_MAYBE(CONFIG_ZSWAP_DEFAULT_ON, zswap_ever_enabled); static bool zswap_enabled = IS_ENABLED(CONFIG_ZSWAP_DEFAULT_ON); static int zswap_enabled_param_set(const char *, const struct kernel_param *); @@ -136,6 +137,11 @@ bool zswap_is_enabled(void) return zswap_enabled; } +static bool zswap_never_enabled(void) +{ + return !static_branch_maybe(CONFIG_ZSWAP_DEFAULT_ON, &zswap_ever_enabled); +} + /********************************* * data structures **********************************/ @@ -1557,6 +1563,9 @@ bool zswap_load(struct folio *folio) VM_WARN_ON_ONCE(!folio_test_locked(folio)); + if (zswap_never_enabled()) + return false; + /* * When reading into the swapcache, invalidate our entry. The * swapcache can be the authoritative owner of the page and @@ -1735,6 +1744,7 @@ static int zswap_setup(void) zpool_get_type(pool->zpools[0])); list_add(&pool->list, &zswap_pools); zswap_has_pool = true; + static_branch_enable(&zswap_ever_enabled); } else { pr_err("pool creation failed\n"); zswap_enabled = false; From patchwork Tue Jun 11 02:45:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13692775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D78DC27C4F for ; Tue, 11 Jun 2024 02:45:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8208C6B0098; Mon, 10 Jun 2024 22:45:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A8A16B0099; Mon, 10 Jun 2024 22:45:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 55FC56B009A; Mon, 10 Jun 2024 22:45:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2C9766B0098 for ; Mon, 10 Jun 2024 22:45:25 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E0C8814051D for ; Tue, 11 Jun 2024 02:45:24 +0000 (UTC) X-FDA: 82217066568.18.36EE10C Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf12.hostedemail.com (Postfix) with ESMTP id 2AE3F40009 for ; Tue, 11 Jun 2024 02:45:22 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ofOs6E87; spf=pass (imf12.hostedemail.com: domain of 3QrpnZgoKCI8H7BAHt05xwz77z4x.v75416DG-553Etv3.7Az@flex--yosryahmed.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3QrpnZgoKCI8H7BAHt05xwz77z4x.v75416DG-553Etv3.7Az@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718073923; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DJ8+7Sej2fxglO9eGa2Al3jrHJVakXZUpIE0ICxQvWE=; b=kOPtFQP8vgGLEA3CAQDVdxyycgpVcFRK132GqFMZb/4UfP8t6nJ8onH1o71C23dbPgIU9o qj7/VjTtjapZbVsfJWyW/V9LSR3wQR7twZXehWnAdTY5lBDFPySnQIv7ZlPYYImnF9oAXc 8AW+GIPVaiKvWrliDpliO3QunHVsf3A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718073923; a=rsa-sha256; cv=none; b=4guGx/rYrokwFYtkP0M21aMdb2JMUVY7aSoiYjKW1zVj0RK2WAF16awdRPdkJ0zoVqyHdN 9ruOf8B6jdleyQ+5l0I2aDXxcP9epNAYDeNd9B0G3Q2FTuKBMZlJ4QtlaJlB15qVIE+/b6 XAOA/o+nQBTSMbi7CGmtWBM4WDplpOE= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ofOs6E87; spf=pass (imf12.hostedemail.com: domain of 3QrpnZgoKCI8H7BAHt05xwz77z4x.v75416DG-553Etv3.7Az@flex--yosryahmed.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3QrpnZgoKCI8H7BAHt05xwz77z4x.v75416DG-553Etv3.7Az@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-627e7f0ca54so12117147b3.3 for ; Mon, 10 Jun 2024 19:45:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718073922; x=1718678722; darn=kvack.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=DJ8+7Sej2fxglO9eGa2Al3jrHJVakXZUpIE0ICxQvWE=; b=ofOs6E874SUvx8z1aRqDcddyzpLFkXSrPnqQlqNMVr0A6hNeokgZ3Ms6Lj40YLEW0e Pggbk1rlRuk3iYz1VIoNoheWoLK+rdkbkPyDwAOoweXjfpD0UmlAfrwzfoIxnrAVBFdX jQZtD/qQijlE93DtirCp+PwD/KZ5gup8V0/JpfgOMbOolJ1IA7iJfC9rBVYDoDHpUUZO sSgO4C5d/JQaupcHuocfKwe67ac331zu/2FkLCazIgiCSEGU5tyNXXYmP4+u4QnzG1eL Hdv6KC/YPFwN88g4Mrug+tAP89crTmLe77IwU+vzW6JhwKfxD+w42QGm6+jqdWWGsBGW Uzvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718073922; x=1718678722; 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=DJ8+7Sej2fxglO9eGa2Al3jrHJVakXZUpIE0ICxQvWE=; b=AA73Cnlu532GXGXdve7Y0hKjYXj7GnhgOMhAjhStqP6uJLUKTJwKK+asnyfxcCHb62 Pt/rgjq7TxNb/bX0X3OoYjkWPUvBS2ZFRAtn2lv1/qC+5s+0vCjAz5t8AxQdNdY6IQtq V4DWLazXm0h6AGW0pc5apEjMEoA7bfFUEpyrN1oNFYALTGHrtzxucsV3lYr+txJDrfFY kC4EZ6V1L3I8Zq88ghUuN9Xa88xZv3jHO69EZLyk7aAYPuQc2XHSG1lF+xdHOh1S7Fxs 9xKWz58ms2L+YpyB8RNlgEPfnuZc2vO1TiqrByvNNcWDikquyRYs4iNF5aVLUON0oikn f9Ig== X-Forwarded-Encrypted: i=1; AJvYcCVwYVDvhosqemuiBYlRW1wraAquxeiXkC2Ar81r3qWtADDjLkf6dHWabv7LgoVJH9ez4xWTJY87u806QzLqoypselg= X-Gm-Message-State: AOJu0Yx0K/girIDNGFtuUfU0N5s2u08ANSPZJX7J1WdhLNmK107ZmxA8 X+5dsuKLecUKJF6mvkCmn3d1l5d99GpC5SnVNW8Fs1Za+zt8I4Nd/HbeV1ZejOsuc3k3xqKrGG0 jIOE7FLHdQv3k4YXrQQ== X-Google-Smtp-Source: AGHT+IHtYmI8LX2B/xV/AC9td52B03t1CfMg6KtVozISqQ0BN5dfCT/e0kwwihIlshNhQ0RkMgS6l3jwEeA+wlLO X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:690c:10:b0:61d:4701:5e66 with SMTP id 00721157ae682-62cd5570599mr43233527b3.2.1718073922123; Mon, 10 Jun 2024 19:45:22 -0700 (PDT) Date: Tue, 11 Jun 2024 02:45:16 +0000 In-Reply-To: <20240611024516.1375191-1-yosryahmed@google.com> Mime-Version: 1.0 References: <20240611024516.1375191-1-yosryahmed@google.com> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog Message-ID: <20240611024516.1375191-3-yosryahmed@google.com> Subject: [PATCH v3 3/3] mm: zswap: handle incorrect attempts to load large folios From: Yosry Ahmed To: Andrew Morton Cc: Johannes Weiner , Nhat Pham , Chengming Zhou , Barry Song <21cnbao@gmail.com>, Chris Li , David Hildenbrand , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yosry Ahmed X-Rspamd-Server: rspam03 X-Stat-Signature: ayrzbjgjt59gcr58nhgzred98i6k1chg X-Rspamd-Queue-Id: 2AE3F40009 X-Rspam-User: X-HE-Tag: 1718073922-787523 X-HE-Meta: U2FsdGVkX189Zneqyya3MeKziHrSdGENtBn8FwdRnbi+IZQHCbTZXIdIsL6FZqviU0/puE78cYBfA6E59vUo2hNkmQe0ZGlBTQCUMrRpqcHmgH60GTznAqqMvWduXj2N3aYCuF+qBvxB73B7LmlXwkAWdvJkGAus70OYUZblqTjPjM1LqhwzAHPuUGQolF5F7D8WIiMsHRqS6gOq0cefSc4StkduS2cImDufqfnPq8+Oikfmu4bUwjpK84FpvZZ0ORlLf0AULhvoUMeseuLUbq/zpOk5b3neWhgD0O1zBhBmbqTGkcDi+MFVD+wB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X/JbsZc6dAKgzgV0hrEflvc7sNWiXnqtY+gRhcLd6jMOw+iL1OFWg9YWweCRZ3Ou51LVZgf2r2qOGfmWSCjvMrM/I43V2mlz0VtLMl4srrP+xMMWUMfiDRkA5J0e7m2+Nk2Pj2yEMD+o0GiqoVvWNxm4Tk/uuw1c9RHKCL/SFmm5bJdsfRzU16ofZgq/qQmSogxGjh0Q8hpoMGsfkys7Ef/xo2/3dsMbheUdB5ZzuEu+6DrqyObd X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Zswap does not support storing or loading large folios. Until proper support is added, attempts to load large folios from zswap are a bug. For example, if a swapin fault observes that contiguous PTEs are pointing to contiguous swap entries and tries to swap them in as a large folio, swap_read_folio() will pass in a large folio to zswap_load(), but zswap_load() will only effectively load the first page in the folio. If the first page is not in zswap, the folio will be read from disk, even though other pages may be in zswap. In both cases, this will lead to silent data corruption. Proper support needs to be added before large folio swapins and zswap can work together. Looking at callers of swap_read_folio(), it seems like they are either allocated from __read_swap_cache_async() or do_swap_page() in the SWP_SYNCHRONOUS_IO path. Both of which allocate order-0 folios, so everything is fine for now. However, there is ongoing work to add to support large folio swapins [1]. To make sure new development does not break zswap (or get broken by zswap), add minimal handling of incorrect loads of large folios to zswap. First, move the call folio_mark_uptodate() inside zswap_load(). If a large folio load is attempted, and zswap was ever enabled on the system, return 'true' without calling folio_mark_uptodate(). This will prevent the folio from being read from disk, and will emit an IO error because the folio is not uptodate (e.g. do_swap_fault() will return VM_FAULT_SIGBUS). It may not be reliable recovery in all cases, but it is better than nothing. This was tested by hacking the allocation in __read_swap_cache_async() to use order 2 and __GFP_COMP. In the future, to handle this correctly, the swapin code should: (a) Fallback to order-0 swapins if zswap was ever used on the machine, because compressed pages remain in zswap after it is disabled. (b) Add proper support to swapin large folios from zswap (fully or partially). Probably start with (a) then followup with (b). [1]https://lore.kernel.org/linux-mm/20240304081348.197341-6-21cnbao@gmail.com/ Signed-off-by: Yosry Ahmed Acked-by: Barry Song --- mm/page_io.c | 1 - mm/zswap.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/mm/page_io.c b/mm/page_io.c index f1a9cfab6e748..8f441dd8e109f 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -517,7 +517,6 @@ void swap_read_folio(struct folio *folio, struct swap_iocb **plug) delayacct_swapin_start(); if (zswap_load(folio)) { - folio_mark_uptodate(folio); folio_unlock(folio); } else if (data_race(sis->flags & SWP_FS_OPS)) { swap_read_folio_fs(folio, plug); diff --git a/mm/zswap.c b/mm/zswap.c index 7fcd751e847d6..505f4b9812891 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1566,6 +1566,17 @@ bool zswap_load(struct folio *folio) if (zswap_never_enabled()) return false; + /* + * Large folios should not be swapped in while zswap is being used, as + * they are not properly handled. Zswap does not properly load large + * folios, and a large folio may only be partially in zswap. + * + * Return true without marking the folio uptodate so that an IO error is + * emitted (e.g. do_swap_page() will sigbus). + */ + if (WARN_ON_ONCE(folio_test_large(folio))) + return true; + /* * When reading into the swapcache, invalidate our entry. The * swapcache can be the authoritative owner of the page and @@ -1600,6 +1611,7 @@ bool zswap_load(struct folio *folio) folio_mark_dirty(folio); } + folio_mark_uptodate(folio); return true; }