From patchwork Fri May 24 03:38: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: 13672649 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 5C900C25B7D for ; Fri, 24 May 2024 03:38:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E12EA6B0095; Thu, 23 May 2024 23:38:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D73A26B0096; Thu, 23 May 2024 23:38:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC6A56B0098; Thu, 23 May 2024 23:38:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 97F7E6B0095 for ; Thu, 23 May 2024 23:38:26 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 511FEA1233 for ; Fri, 24 May 2024 03:38:26 +0000 (UTC) X-FDA: 82151881812.09.4D8A85E Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf01.hostedemail.com (Postfix) with ESMTP id 890AA40013 for ; Fri, 24 May 2024 03:38:24 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=V+tpol+9; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf01.hostedemail.com: domain of 3rwtQZgoKCEA0qut0cjogfiqqing.eqonkpwz-oomxcem.qti@flex--yosryahmed.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3rwtQZgoKCEA0qut0cjogfiqqing.eqonkpwz-oomxcem.qti@flex--yosryahmed.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716521904; 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=BKVO8Lg92AmjXALe4s9SIU0KV7xHA1puZ574BkfEyc8=; b=APs57SICHq/NCnDPId6jZAfFvQ1yy2CDi/hO96t4e0NYm5/uV0yGXhSy3gQUOvGc1JJWDW 20jT3ZcwIR2tP4l0zhWF/lOZyMv5Gxj3nX5cIjZgqYauXkVm6vSILXsjuNIj6aV+WPmRTc i7JYKggSq6hxI5RykYkb8n7ruB4S1KA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716521904; a=rsa-sha256; cv=none; b=i7r8rPslzMcZetSioPNG+VQkNAjSKAM2WhaWfjLoSIHkjoU1R1HJtrVy1thCwd+31jvThJ 63WF6RPvMCb41qn+MUcKiWNq62hWX6f+hVDnfiAp1dfcKxlmirkAOspeujeFyNFZ1twyul i899J0WcYlgHHxgJX3jhgLdt8hN0MAI= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=V+tpol+9; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf01.hostedemail.com: domain of 3rwtQZgoKCEA0qut0cjogfiqqing.eqonkpwz-oomxcem.qti@flex--yosryahmed.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3rwtQZgoKCEA0qut0cjogfiqqing.eqonkpwz-oomxcem.qti@flex--yosryahmed.bounces.google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-62a0827391aso8863097b3.1 for ; Thu, 23 May 2024 20:38:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716521903; x=1717126703; 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=BKVO8Lg92AmjXALe4s9SIU0KV7xHA1puZ574BkfEyc8=; b=V+tpol+9BcEhW5o1wFhSDkhjb0mNzRfO4lG+HnI4VzI6L7WtC+ot6SHDYPRWNnkfBu tZRwowy7i6IcYoxQf75TSmZe8gq0DVzFepv3oPUgzFLbTirTAw8yECYDZv2amKCevII6 72GWddcGMOTbKChpOL3x/7it/hRvs+3oze0SkBT1zPnlZEAKlGZH/tXxjMdbzbbrPplG jCeO/Ug1v/g6ZpqN3CqOJ7VxjGp1RIPt6tUHT94AwFr+WSKpRXLkwTXK7IwJ4QkDrZWD /O4i1kiSixzptT0H1YLyUY3oeOqU6GN+wWReETMuS/y14HFl47XwUR8lv2PxpSSpYoh6 RyPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716521903; x=1717126703; 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=BKVO8Lg92AmjXALe4s9SIU0KV7xHA1puZ574BkfEyc8=; b=dvXCHgSs1fpb+wC264OSKMkyGiYNFFyqVmv5vhNJrweNXLWPwVO5SBIrn/coiP5fpr W9h0O+vXnHCap+ak/b3NoJVojUpZPXPs5f77CECtt7VMBKiiXRz9TzdqLpVMs9ygADYd ZldhGRGOQWwpGAzUHnK9k89ArUyX6sUkyfrTBXoz0S5nSYBy+HfsnSmSCQErwlz9S6GR aL4tSGVyRO8gESELX4ZqkwfKUXlzQM3w9u/x8RpAtOESom5eLZNYQqdIR5YGOjOqcjhR ut8/DfB/RrEt3qeKrtRJf2tu5d99S9o+nfzmf3A46IHHtsNUG72KHs+0/gRmCmnaxQPV vs5A== X-Forwarded-Encrypted: i=1; AJvYcCW//NHEYxfozNFbWi7kxFWsaAlKM7pwcwd6BYYWuSvohN0PgFEKXXLl4pvLtSzNW3pKYc/ZOORGxr5jk0sJHA4hoyw= X-Gm-Message-State: AOJu0YyEsH/HfRoXk8uzIDW8JQepuJuUn25Gnub+c5673G5VUvHAWZdh R0dkA1XKDqpvWuORSsQx6SnnIjX1rfI7VVjF+Kbb1tsA4HuBxvvfh/vQutvIoWPqkJ57DptLifQ qD67k13Bk2BQYNqI8Ug== X-Google-Smtp-Source: AGHT+IHhQTjQkcadv7LLw0o2LYVFVoSUew57m4WVVk3eNvQWrYHyn6s4HbwcRHjmBZKSrfn/K2ulbWyVZYjxfkro X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:690c:281:b0:627:e226:8ce3 with SMTP id 00721157ae682-62a08f828cbmr2774657b3.8.1716521903699; Thu, 23 May 2024 20:38:23 -0700 (PDT) Date: Fri, 24 May 2024 03:38:16 +0000 In-Reply-To: <20240524033819.1953587-1-yosryahmed@google.com> Mime-Version: 1.0 References: <20240524033819.1953587-1-yosryahmed@google.com> X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1-goog Message-ID: <20240524033819.1953587-2-yosryahmed@google.com> Subject: [PATCH 1/3] mm: zswap: use sg_set_folio() in zswap_{compress/decompress}() From: Yosry Ahmed To: Andrew Morton Cc: Johannes Weiner , Nhat Pham , Chengming Zhou , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yosry Ahmed X-Stat-Signature: 6jkke61xceq4bdwy3i1tbpd47rods7jb X-Rspamd-Queue-Id: 890AA40013 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1716521904-153988 X-HE-Meta: U2FsdGVkX19PevHHMgpMvXpaIrutPPEK+wT7JVIL4HmEA0IpyGgw2/6Xbhvxk1peXJ9c9mobK8UNxtoeaMzUf5xswZmciUfbK4ZtctJr+4bw88NBWRvoO0JTX+PHai2yVHFzXYjbIVRqS8MsocXS88RMRfHdeMJVXSHNMFnV8AZjfG/IIieaS42JBjbQFlBXQ+md4/wKo4GEbKqi6njX9pKbIeHpu/Z8Q3UL1aVYvIGUMEqfMrhbz8GrNmvie1f6W82WRuyc79hKVkmbHdYGWUK0VVWvGml4ms6B56dryDliZLmqE5W4SwIPFoNDNGHYo+NDsg+oid/34W1VcfwrervFaTwEgnbObsQ7fOEt1PYouLg6ETpwKA2FrhvVv2Rlm0FIoR4g9uUvdSOoODYTT+ySJyDz7DtWmFmw/GOjpbi6a+h0wAqCdnrGibdtS3uWBv9aO55b+NM6GscgQF1o9xHtkTaF8GCEsXlucX4h/xpXgxRqQGhY4sYdUxPnPUU7Avzp/n1qv+l9Sm38ra9kRIIlfxoW9iTSYHCpim2bsB9zPfZmYBNVEabAudrciCkKMk3XO1oXfgnDfJAM7LoOfLzCAV70JXel9XH6dSSBCm/cfoMRw8n3lgMwIV0AQrvsWmtDRiQlSqZOjQst/LkHlHjuQqNOg93gl2YZy2C1aTZinXt82FOHu+S4Bc1PUweQcmbenZtRao0ST7mkNLFAx5KzDkvaojVEHcSiAfQfkHHYQA31SBFf7AGqg5UhFq44m14NXhx9Qgn+E00zeaMhJH9xeD2KwJwsF9+Xuot2IFAp0dSgWOzMu+PrcV4KGkk14wcbiX/PC/EXKdBTGZSGYr3jVxgMECIhk7JHHU7Sf0XIxGrS/No2aRyL7lHc3pC9ODLXlH1U5Tbs1ahe32cweLB8HFkE/K++jruNJG3RyEaacgG/6rCvt2pPSE0E3fdoz5eWMqs1V/SEBvZE45I mzpURhZk 4if3HktqaySU/yLGpX4iNDsa5atv3eallik7yEi3CQGenqPX1+zV0FJzJHHO8bqJQALo9nreL92LKxEPbbVQcZJmjPXMyGT4OMJFlovLmJxE/Kw1TZULIG/uh+Ib8QF3f769jT27vPfKHEId2TbfTJ2TVL59anJU8ph1u5OupblmeQsDcPKMQaqB+PBgpLkPjOArv6pD3l9i5ioKThkQ4B23Xn6HNOOKog9xfPWJWeeW2MG+BI0AeTXQnHZpjtlRhyA2bviVaxN614im8xsTE/ZFnObwdYSnFo0L6QE3/bhA/szEsD2rvqQJKFYnSrQwEvzWuw4nNASOopwYjoQr+859ro/SfosnnaWvdEwuM8U92ND0g9LvE+8nmpzbprHwp4e+SmPUrsB/lzr8yGmyhkhAbWPMECjR6ToE8+Xyv2x0Dj+V8v+e6bVl6pYl8kDuQWT4Tm6ETOV0690Bv1tMvr+LVzuh0bB98zxh7DyCqtD4ZequnwQSam15C3EkTXuD3Zz6ZXVz6FtgGTles7TcNLmg401BzpTt3uT+ZO4klyCg+ic+WImdUQOFbZ/KIDwsrPwlmNjx43DIkZZQVMsA8HPemKF8VowYbWYFGB/cBllyigFWSMs8WbXGSnwIl7WrHcqcL0NtCnoYQlkbybqTToqTvviO6pEE8EizMdA2SW/txTM+xYe1mTMwIVA== 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: sg_set_folio() is equivalent to sg_set_page() for order-0 folios, which are the only ones supported by zswap. Now zswap_decompress() can take in a folio directly. Signed-off-by: Yosry Ahmed Reviewed-by: Chengming Zhou --- mm/zswap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index a50e2986cd2fa..3693df96c81fe 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -917,7 +917,7 @@ static bool zswap_compress(struct folio *folio, struct zswap_entry *entry) dst = acomp_ctx->buffer; sg_init_table(&input, 1); - sg_set_page(&input, &folio->page, PAGE_SIZE, 0); + sg_set_folio(&input, folio, PAGE_SIZE, 0); /* * We need PAGE_SIZE * 2 here since there maybe over-compression case, @@ -971,7 +971,7 @@ static bool zswap_compress(struct folio *folio, struct zswap_entry *entry) return comp_ret == 0 && alloc_ret == 0; } -static void zswap_decompress(struct zswap_entry *entry, struct page *page) +static void zswap_decompress(struct zswap_entry *entry, struct folio *folio) { struct zpool *zpool = zswap_find_zpool(entry); struct scatterlist input, output; @@ -1000,7 +1000,7 @@ static void zswap_decompress(struct zswap_entry *entry, struct page *page) sg_init_one(&input, src, entry->length); sg_init_table(&output, 1); - sg_set_page(&output, page, PAGE_SIZE, 0); + sg_set_folio(&output, folio, PAGE_SIZE, 0); acomp_request_set_params(acomp_ctx->req, &input, &output, entry->length, PAGE_SIZE); BUG_ON(crypto_wait_req(crypto_acomp_decompress(acomp_ctx->req), &acomp_ctx->wait)); BUG_ON(acomp_ctx->req->dlen != PAGE_SIZE); @@ -1073,7 +1073,7 @@ static int zswap_writeback_entry(struct zswap_entry *entry, return -ENOMEM; } - zswap_decompress(entry, &folio->page); + zswap_decompress(entry, folio); count_vm_event(ZSWPWB); if (entry->objcg) @@ -1580,7 +1580,7 @@ bool zswap_load(struct folio *folio) return false; if (entry->length) - zswap_decompress(entry, page); + zswap_decompress(entry, folio); else { dst = kmap_local_page(page); zswap_fill_page(dst, entry->value); From patchwork Fri May 24 03:38:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13672650 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 671D0C25B74 for ; Fri, 24 May 2024 03:38:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A1A6C6B0098; Thu, 23 May 2024 23:38:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A3866B0099; Thu, 23 May 2024 23:38:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A7046B009A; Thu, 23 May 2024 23:38:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 5A0466B0098 for ; Thu, 23 May 2024 23:38:28 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C57D51406CF for ; Fri, 24 May 2024 03:38:27 +0000 (UTC) X-FDA: 82151881854.01.0DC2354 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf20.hostedemail.com (Postfix) with ESMTP id 09A2F1C000F for ; Fri, 24 May 2024 03:38:25 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=sLp4trXd; spf=pass (imf20.hostedemail.com: domain of 3sQtQZgoKCEI2swv2elqihksskpi.gsqpmry1-qqozego.svk@flex--yosryahmed.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3sQtQZgoKCEI2swv2elqihksskpi.gsqpmry1-qqozego.svk@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716521906; a=rsa-sha256; cv=none; b=g+Fw223wz09MYOcMTGJZiC714btoGx5qTmRIeQMpQ0MSgWoo94PA+oRcgO+48KtQXuKGOb Svn7bOF+rl6g1lN1nusBnuTqy+/dCGqBtLExVGc9UXshbVH8hkRJVMzyiOc7WvXWCSch36 5bfK/5DbEnBhqd/2hsXUarTBqR9zZhI= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=sLp4trXd; spf=pass (imf20.hostedemail.com: domain of 3sQtQZgoKCEI2swv2elqihksskpi.gsqpmry1-qqozego.svk@flex--yosryahmed.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3sQtQZgoKCEI2swv2elqihksskpi.gsqpmry1-qqozego.svk@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=1716521906; 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=UZUibxVL0p5mU+STizIl+rgA3qpvNVqFQOc0JP+qiMU=; b=S+se6VQkzc0mD5TKWICSvpSqpWUDiqOyFcC8wDNwNd/TBGwzEJoEr1j7+76mAG5O58EfVV 0P3Iw5YJU+cKCZhgKuh4nK3GJqldlOfTak00GdYLLWh/4b7UYH0jbsbMkGFJ+uMtoEPzGX IMgr+/3b8w83Sopl+hF/xDCsSp8aM0I= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-62a084a0571so7706877b3.2 for ; Thu, 23 May 2024 20:38:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716521905; x=1717126705; 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=UZUibxVL0p5mU+STizIl+rgA3qpvNVqFQOc0JP+qiMU=; b=sLp4trXdIaAdWzoLnsFMjlVeCK+kG8PJnV4leuIUpAWj7vMf9NSu1vkhqTYvoK5hGK l+hY886kna1XuySlbDA7zGVUcOajEyJYMq9YuGyFEXhwKCXugEworHl3LBHwzhaLeog8 td16UsmN07wwAXdZMx0Lo2LCEQowEe1V627OFR070fCJp/CeNqY2mb09jGoRPZH5WIkQ qTkGdD7XIF/GVab6g1HOOR9OswR6dy4QMU8fogxrrm7g5vAlNdYFPC0G+twnqgm/4mU/ ghp/abUxp4zm51wDI4awS8rAWv/OO45c6YFN/ctUntw4IrVS/+kZTMFS8sf68mTmEBfU lWvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716521905; x=1717126705; 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=UZUibxVL0p5mU+STizIl+rgA3qpvNVqFQOc0JP+qiMU=; b=bcWEKr9Ke/lXwg50PnpNDJrnFL7idzfD0zUXnp7nagsQckGD2ttGfQ8JUixVCOBJ2T oL8XXVJKhXCwwVXiA5E5EhfSHCCnew2DSzDhqgMauwamMDW8sA3zFrOSPHLng0MxEJNF d1blPLOZ1lrHrxZdsqBXFxBgQbNXMuTI8LGRb7gYQtmo97sHZe/0BBtSl7zW5V/Zg3Vq /AXWOO3UfrCyguPHDJ1BWowH7MCCb+Rf8Cgq7WWo6AgiF0lcJVT1ks9xcj8heM+AWZSr FvWiA434bGGegC3e2wxOyrU6f2bV0eUwaD5grr+s5pf5PoZRYMQiDodyjmWqflkd8DiB 1a4A== X-Forwarded-Encrypted: i=1; AJvYcCUwCb59/4eaiXU8vcTBU/FmMI6PHiza1B6RgAfH7qXFT2kgvEcBcriLmhLjbMFWbXhL4MbGioC0voyR4maKhzO0KZw= X-Gm-Message-State: AOJu0YzakhdgLnaMpWr+AB05fJTMTSPUCiC5gK4QaimJVD278nr38/1v 5xdSWeNr1o+RimkSylAoZRe0/N/1hytU9fm99GwVyo7nfWkj4DHyq9kwUtB2YyLmVwCNvWlC8M3 GwvQEUkKAvkYhFs1sAA== X-Google-Smtp-Source: AGHT+IGWEmQAlnhdEPzZ6uPO7aNv6DYve/yJL32x0ERZjFBY1Aa9d8TiVJtvgVdN3KsvGrSvISEQ8eqaozyd47PG X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:690c:368d:b0:61b:ebab:ce9b with SMTP id 00721157ae682-62a08e60886mr2541307b3.3.1716521905191; Thu, 23 May 2024 20:38:25 -0700 (PDT) Date: Fri, 24 May 2024 03:38:17 +0000 In-Reply-To: <20240524033819.1953587-1-yosryahmed@google.com> Mime-Version: 1.0 References: <20240524033819.1953587-1-yosryahmed@google.com> X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1-goog Message-ID: <20240524033819.1953587-3-yosryahmed@google.com> Subject: [PATCH 2/3] mm :zswap: use kmap_local_folio() in zswap_load() From: Yosry Ahmed To: Andrew Morton Cc: Johannes Weiner , Nhat Pham , Chengming Zhou , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yosry Ahmed X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 09A2F1C000F X-Stat-Signature: g7jqiq676zfrie7pxz657hbokfci6dyo X-HE-Tag: 1716521905-536284 X-HE-Meta: U2FsdGVkX188/ZbHzrLGZHKhcbESOcANJ+odHgry2NNrltFvN5FEjmfVuempl7vYhkIz6P6xq0h/8hli2oeRxGxu/O6tIWYMTEhaziq4yJG7X7AYprhL8rDjp9fW0AHWJDebzcgAuUlAlb8FeXt+JvbZBqitCS5mshGJ7O3sQL+ETZdkSgShAQYmY2PW11sblZT1owoGFqhlPkBZ5lW5nEFck0gDxKbfJRjXK/ZZQx85ci5JBe71TQ08jg0zO05sy3L+93xu4Nw/adbHcCzgwWYQZRUYKtTV2iqpG9httB7ESVM7Z9Ifz6ix6UtWN/Mm4B38zh044YQTOZAKjAGhp8sFZWSD9nBLwVS5V7qUgyt7BxLBQrs57Go1CnwsRnmMMKE3O55p7CTsKoAALVaumOCzTLg7kS9/XCejwZJzSuho4iA/cBPUcXzo/vw3z+sdLeiszSgt0lzP3E/TDZHB84hz+5mM+oxksx0aTT2VxnMiC7ykD77s5VAHgZ9VgePzKMdL38rgNA0BW41RVX/HZv7uapWcBEWoI5y6MnX50ks7oAXBwufq5dWJ+0anm/iGEHNowASm114pxxEmUF/Oge8QzDYW4TNGsvoNFDvcL8yYgj1i6skarX1kY93NgW8aBV8L1fMcKsd8kx/VdtQTaJjVBgZlxttMbidUvA/PkOHq0UDdeBarLluzbjS5u1bUAS0UGD1bwum0yuJ6HVa+Lc6xubZJufdaZ63eGGQ2FCzaflWdkkDdTpzo4E8/wO4PvWyWv3Wdf00uooQjc8Hu5gau21qDYywC9vaeYUeNwVu5LKlvizLOLe6LjAVuDMQFwd0HxrVsx/oDsTrXh2cx4w5wMhiB0gs+G1Wq30jCkIyzS6AnGJvuTgVmdyLSdZaEjajO0C08xtmF+AlFK0tzmNsTwdOIGoAAQiiP9mp+Q9NINLhiz5WIpBj2vet96TXsQOxMPE7dlcqu1nQ+gqZ 5HOgsO5m c/XyPnMQsU1/z+8r5sKn0fLQvHjjOzOAHzK3/8WYZhCoquuhlwU2gFVQjxGk/lQ2xV5eDR2pOU1tIyGMyHILxyJlsLWDJV9lPaADigfbLATsDU0ZI3CUxBkTpaB9oHQ5SfmGEWXxOPqzEj6ftlYCurg2Kdn1ohoEGIW+PkNoZMwz077PxGoW4P8iftVGnAn/5zDRj8LgOgMWvs7UwHu7iI0FUHgKY4zX8rkC56icpN8n97z4NZ+MOomy7vxup7fq2p/KlybirLuuAbC7FexgrmF5oEEhyDJVG5nh0NWiHfbuZ5eJHs4O0xEAJ01zpRIASwnz9W+RuHpAFYlF4KyHAHLw6J4dkKNDiA/x8vMmghrXCKYFSiMvswjbe2xl8ePz9Qzjh/XJQxiSb19skSBRfXz3Osw/Ql/uQIkyImKp1D12LVKBQX/fn3qfpgHR01MJbVH0h6+fs0oGzszELnU0yjb6e3wcI8bzlXq1eHJhrKrWQJ6LbdcGlLMKUw5HCDV/zanNsbI+B+ZoFxMKAm0SUlzGUYct4W3mHRUJX+xcLNNerRuOtRIRLxB3NTdwYiOSs7trjCMkkJBGjDE45BUCkyNNFruGQANnaE2JNyLiz1pql9csx1mtChKQPdS/4V6l23D/yUE8v5l9qgOnyeG1X2xx6T6Ka8RqaT9Kogi34LskEGnyFDet9UFVgaA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Eliminate the last explicit 'struct page' reference in mm/zswap.c. Signed-off-by: Yosry Ahmed Reviewed-by: Nhat Pham Reviewed-by: Chengming Zhou --- mm/zswap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index 3693df96c81fe..bac66991fb14e 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1551,7 +1551,6 @@ bool zswap_load(struct folio *folio) { swp_entry_t swp = folio->swap; pgoff_t offset = swp_offset(swp); - struct page *page = &folio->page; bool swapcache = folio_test_swapcache(folio); struct xarray *tree = swap_zswap_tree(swp); struct zswap_entry *entry; @@ -1582,7 +1581,7 @@ bool zswap_load(struct folio *folio) if (entry->length) zswap_decompress(entry, folio); else { - dst = kmap_local_page(page); + dst = kmap_local_folio(folio, 0); zswap_fill_page(dst, entry->value); kunmap_local(dst); } From patchwork Fri May 24 03:38:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13672651 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 E95FDC25B74 for ; Fri, 24 May 2024 03:38:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5114B6B0099; Thu, 23 May 2024 23:38:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 49BBD6B009A; Thu, 23 May 2024 23:38:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3181E6B009B; Thu, 23 May 2024 23:38:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 0DED36B0099 for ; Thu, 23 May 2024 23:38:30 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B5BF91604EF for ; Fri, 24 May 2024 03:38:29 +0000 (UTC) X-FDA: 82151881938.25.9A5737B Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf23.hostedemail.com (Postfix) with ESMTP id E140414000A for ; Fri, 24 May 2024 03:38:27 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ffeiHbzZ; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf23.hostedemail.com: domain of 3swtQZgoKCEQ4uyx4gnskjmuumrk.iusrot03-ssq1giq.uxm@flex--yosryahmed.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3swtQZgoKCEQ4uyx4gnskjmuumrk.iusrot03-ssq1giq.uxm@flex--yosryahmed.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716521907; 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=4rjLaqux6n3a7+R/7FlUB+W5AeNaAqDsKuPO95aKmjo=; b=YIkaxepI21TZtD2AnDkZvONOjiEuUPhle25k3HIOSPVQVLNTkTMzVOnuRYaj2sLZbb0J5l wjmePKIWuDkCfNjBe21EJC8t8H+t7l2rYpcaB15F53EvaI5VS/+ex8TUGFjPUiyuMV122h wpfkIdAGDOigXJi6tyzpLdNCNNLhfwM= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ffeiHbzZ; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf23.hostedemail.com: domain of 3swtQZgoKCEQ4uyx4gnskjmuumrk.iusrot03-ssq1giq.uxm@flex--yosryahmed.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3swtQZgoKCEQ4uyx4gnskjmuumrk.iusrot03-ssq1giq.uxm@flex--yosryahmed.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716521907; a=rsa-sha256; cv=none; b=HAMRt/9ZE0srjuV8X7a/msbMkT4aF229Fp6mx72jKsVz4cGkosPD79+Ann1Miy2VDQSBqs ewJRjiFLkfvQFFrPZvcnZjAePmoBItXm4cQrRpm2Uf8p7+h++Nfa74adj7cdWPaYBhvqRy mpc0PgkTyvcANwtsQjS/Ql0WSMr9Bks= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-62a083e617aso9164047b3.2 for ; Thu, 23 May 2024 20:38:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716521907; x=1717126707; 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=4rjLaqux6n3a7+R/7FlUB+W5AeNaAqDsKuPO95aKmjo=; b=ffeiHbzZxUML24uMio0v/rcTFqX8u0oaVMFYGbpA3onzbJJSQ8rWYERlXPmtiC67RX o3nVHhnJ3dp1y8IGvUmNUixCmW3Fe1ZEbUNI5cTXN/Xe0txS1JB4Figv9CKJbWrEdchE WVDycEfgKtxJNNo2PFySdZUV1+NRwF9Yg+JJCRq7bpChUXz2qf9UccwBiRyRZQZ1hwk5 lGKtslO+JLnqQz126NdVzjjKq4W1sKYdb/INZZRJ7jxex/hkN3blEwPyiufSK3ZvDhoc nFnEUriWSbn3JTeEg+LT9hnsWhPdlMjX059Y2LaQK5cfd0AZgsQdjB4gZAhW1+JE5Tdu qhyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716521907; x=1717126707; 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=4rjLaqux6n3a7+R/7FlUB+W5AeNaAqDsKuPO95aKmjo=; b=IR0RHeTVshbbOUzujV8XEpLX5rWLEXCYm/cKmGGM2R6AUze0W0I7Rm5SNo7XTfTFSN PNNnR+B6LtSBjt/KlDUXnPe/8X/sY1wG8cgnavHbKVLbWoI3t2Y9ehPWhuB82HZXn4Vq wRzS+ThON5ZbmYDaXJRwYi/2lin+SD746wRCCpZKw5e/nRki5mM5vZya4916LoeuhzBP 4FGGLH5NzpQzfuVbci8pIJz3MaYiuAjJ0JfngbXxkzwJJkwQy5YGQ+GV4OOX2p8Kcj0Z mmaheNufsjGac8NKcWBRfEK+5Jhl3U0olSUMNijhuXereVtdVjLzuwmFeT7EpmSO2g5W i1Yw== X-Forwarded-Encrypted: i=1; AJvYcCVk9xXKqjYg98xtVxlgWdexN6emOGVOPxaXyE8tm4mExA4ZgVKFly+CLgCGQ9qQVY+TtTqBXqRnjNpLgJsPFhekEk4= X-Gm-Message-State: AOJu0YyqOLkZ+WyMVlo2ayFFN6X/l8+8b1Lvr1zlZj3eEeSHbKQGrUTy dN+qbyg2FOLFptxpdBG52bc4Goie9ThvViTLCxY+3Sue+jhARK8irQ6Bw2DdnwRueZUsiIIeS/j TJV6u5/X6mygRYVU3bQ== X-Google-Smtp-Source: AGHT+IFjyBiedP4yQeSnv9T+OmD26CtUHgQCt5FkCWaEvXFDvir0hBHjpfuYbfRsKpcdcsuSG+tax+f1009tpb2V X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:6902:2b03:b0:de4:5ce2:7d2 with SMTP id 3f1490d57ef6-df7721dc43cmr300341276.4.1716521907001; Thu, 23 May 2024 20:38:27 -0700 (PDT) Date: Fri, 24 May 2024 03:38:18 +0000 In-Reply-To: <20240524033819.1953587-1-yosryahmed@google.com> Mime-Version: 1.0 References: <20240524033819.1953587-1-yosryahmed@google.com> X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1-goog Message-ID: <20240524033819.1953587-4-yosryahmed@google.com> Subject: [PATCH 3/3] mm: zswap: make same_filled functions folio-friendly From: Yosry Ahmed To: Andrew Morton Cc: Johannes Weiner , Nhat Pham , Chengming Zhou , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yosry Ahmed X-Rspamd-Queue-Id: E140414000A X-Stat-Signature: t6pr7qei93ppoiiq1guyfum7n6box8y6 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1716521907-319690 X-HE-Meta: U2FsdGVkX18nMqiTXaTpiwo1ayvzepMR/dG1EKYtFJKe1Tf9An/hwhQfj+KWp1kCl1SItU3yjkMfwTrUe0TlyNtDFsz1f2Pqc9TUACxEMSULH7OiuPNpbQ+ciKu0C9setg61YVVUSrHZO444Zhz8aN4p+fpFT+bMwYOTOy9CoHaExiumlaTjRKmlXUvjCMA6W7h7rESe2m7az+8L4SaB8MVAtRwIugUOtbmm5kbHnDeaKSsUECWvsBP/7P/0wAo9F8XbK9F0AqUVSqEsPOiqulsAlwwLPFm+GRhD+/TVoHwkQz153C5z+qADbzwZrb6S9SWouILjf7iqdvpcCOVxUZEjXqPP0QTVukKR4IBou3txP8eDYyYfsI2KVje12bhtoIEjjmymmSHrKfHNXuIapCKAXIfikIQGcUw92Xf3s7y4V69voD+dUPF6yh6srUO9QqzaxijFu5cuCH4+wt5Ppz2O0hdyAs0WsKjIXGD12Ks9iUXJUQ7nucEOimg80GNO93ud6gQgA4u/T5YSU6Oql19kK+oJThCysRtgT7qrzgL0tHJMkLF/jbLAa77Pl0Vi1aHC+71DUw82mYxji6lEx07H5SSJNooCXheBJN9UDvG/gQmRBi3x59ap3eqsgfuL5wCW8CdM/wXRAweH/ym23/2azn6dJ/3HD+p61AnTgbzA71ChjLzn3oj/SkUZbG9xhJxYSmSq45oUuWv2z/9DIfnJ3vcuXvIeGGJm58M3BysY6O4uGx3VnQtqruMTwY2bqtGSjGSzzzPi6aLlinE89SsLtPGVHuVrzV1tmuy+BXlP/epxc71NgunDxcOpezusyVD4dIGEsIorkbWDQPxKxKONKnbv+MbcWXEkZ6p5hteXU7cAfQUVaYrOpz0k6rsHEab/ExBbbne/e8iBtX5V09wOK8L8+DWiY9TStAWFwOy4oVN7wZ0B4tE++jPI8l1/C38e3HEv+Yhdinq3zEP c8E9HqVp CifbgYXnXcpkKhcTUr4OKoNIInAZCpDhoObc1uYaP8QrjLLbAim1Ct0eEpcHp6KLA9TPM/48XvnZfGY1GKWWoNXDCytLeGIJKhqUWFs1v6iDy5+FU3w1O+2p6mCeasR7QN3L2i8KLYKZApQESYKsQXrZKiiWZixCOhfsu5bpfTAdow/C96KqGGOETRUICh/IgsyvyQshvsKc05Lploa96FHwX7sRGU6DIZO9Sx5HCY0MoMKg47LWaRAwCvtj4IK8K8tuXejGbkTPLzt01ZY/EOQObDwmGDp3umhBCL6v8eoqm9p1qYf8djU6+vRrRZbCNlAX44tzHp3O6nVNghSvHJovEmIyZ3hwML1B9ObgDf1t+in01CKiT6lN4F6h5n6Zea+VAM3NvDujlRw62lne8piyCSd8uX7GUQQqykfFD3uOnX+GeokiodfIy82lOxH3e1cJIXThpqsdlTozNXAAhJFzDEoKmivRsKgZCNCaNyl4q6QfVnM7N2EqlS2FFXQ+JbFBprtVrsgUIZh3vSA6eXj+4c39MB3cMx7q38CBEJ7eNr4lJHJWfEY48QP2LGPaxEim0SkWONsYUvrHtqOaFTVap1BlqEHYAWJrnIXztFuiMHlxuHNKJcSQImTHWXzAjGSUNc7JH8IKhOLEAgFyE09ByvkNrCz3a1PfaUNq+62QTzrb/o0ZIn8nHdw== 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: A variable name 'page' is used in zswap_is_folio_same_filled() and zswap_fill_page() to point at the kmapped data in a folio. Use 'data' instead to avoid confusion and stop it from showing up when searching for 'page' references in mm/zswap.c. While we are at it, move the kmap/kunmap calls into zswap_fill_page(), make it take in a folio, and rename it to zswap_fill_folio(). Signed-off-by: Yosry Ahmed Reviewed-by: Nhat Pham Reviewed-by: Chengming Zhou --- mm/zswap.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index bac66991fb14e..b9b35ef86d9be 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1375,35 +1375,35 @@ static void shrink_worker(struct work_struct *w) **********************************/ static bool zswap_is_folio_same_filled(struct folio *folio, unsigned long *value) { - unsigned long *page; + unsigned long *data; unsigned long val; - unsigned int pos, last_pos = PAGE_SIZE / sizeof(*page) - 1; + unsigned int pos, last_pos = PAGE_SIZE / sizeof(*data) - 1; bool ret = false; - page = kmap_local_folio(folio, 0); - val = page[0]; + data = kmap_local_folio(folio, 0); + val = data[0]; - if (val != page[last_pos]) + if (val != data[last_pos]) goto out; for (pos = 1; pos < last_pos; pos++) { - if (val != page[pos]) + if (val != data[pos]) goto out; } *value = val; ret = true; out: - kunmap_local(page); + kunmap_local(data); return ret; } -static void zswap_fill_page(void *ptr, unsigned long value) +static void zswap_fill_folio(struct folio *folio, unsigned long value) { - unsigned long *page; + unsigned long *data = kmap_local_folio(folio, 0); - page = (unsigned long *)ptr; - memset_l(page, value, PAGE_SIZE / sizeof(unsigned long)); + memset_l(data, value, PAGE_SIZE / sizeof(unsigned long)); + kunmap_local(data); } /********************************* @@ -1554,7 +1554,6 @@ bool zswap_load(struct folio *folio) bool swapcache = folio_test_swapcache(folio); struct xarray *tree = swap_zswap_tree(swp); struct zswap_entry *entry; - u8 *dst; VM_WARN_ON_ONCE(!folio_test_locked(folio)); @@ -1580,11 +1579,8 @@ bool zswap_load(struct folio *folio) if (entry->length) zswap_decompress(entry, folio); - else { - dst = kmap_local_folio(folio, 0); - zswap_fill_page(dst, entry->value); - kunmap_local(dst); - } + else + zswap_fill_folio(folio, entry->value); count_vm_event(ZSWPIN); if (entry->objcg)