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+bMwYOTOy9CoHaExiumla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umhBCL6v8eoqm9p1qYf8djU6+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)