From patchwork Wed Dec 13 04:18:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 13490335 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 F1CB8C4332F for ; Wed, 13 Dec 2023 04:18:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7FB4A6B0306; Tue, 12 Dec 2023 23:18:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 781346B0307; Tue, 12 Dec 2023 23:18:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D3B26B030B; Tue, 12 Dec 2023 23:18:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 472306B0306 for ; Tue, 12 Dec 2023 23:18:45 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1812DC0B1C for ; Wed, 13 Dec 2023 04:18:45 +0000 (UTC) X-FDA: 81560489010.19.59DFED0 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) by imf11.hostedemail.com (Postfix) with ESMTP id 3A7484000E for ; Wed, 13 Dec 2023 04:18:42 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of chengming.zhou@linux.dev designates 91.218.175.172 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702441123; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tT1emKgYQM0+F4uJHP6P+57UiBL/0RPI31P/wvcqXbc=; b=XJoeKRjCQPULotp/qp5ebJKiNBbBrZSPJYZMbWBqaKMabooXpjoJQIc9Zo1mylPyCk6NAJ vRonQ1OLiW55937g/JSAXA4lS0bgg5VOndUO1aXoFvoxyIQuZ1U7uQjfzWpG6CNnyBCu3N ibo3ZDwlcmt6AiHESPm4kmPnALn8/Hg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702441123; a=rsa-sha256; cv=none; b=f4uEC4XTyzaULSko5wDRntbd2mmEjwOvTK45iWMXS8pim21ac8ibXizVb7tBGGzMJghP5s nBZXMxME0Q3Z4Iid1riyR1GMf4/CQX13ZimhetpZuMnEZ/iqaTvGWpbZBwfrDyLqNrXNJY CMuoQEeJ9UEPA0bp/pPW2uvn3JK2RyU= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of chengming.zhou@linux.dev designates 91.218.175.172 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou Date: Wed, 13 Dec 2023 04:18:02 +0000 Subject: [PATCH 5/5] mm/zswap: cleanup zswap_reclaim_entry() MIME-Version: 1.0 Message-Id: <20231213-zswap-dstmem-v1-5-896763369d04@bytedance.com> References: <20231213-zswap-dstmem-v1-0-896763369d04@bytedance.com> In-Reply-To: <20231213-zswap-dstmem-v1-0-896763369d04@bytedance.com> To: Andrew Morton , Nhat Pham , Chris Li , Johannes Weiner , Seth Jennings , Dan Streetman , Vitaly Wool , Yosry Ahmed Cc: Nhat Pham , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Chengming Zhou X-Developer-Signature: v=1; a=ed25519-sha256; t=1702441093; l=1963; i=zhouchengming@bytedance.com; s=20231204; h=from:subject:message-id; bh=XtUmsKxEGZDM6rCPaj7hU7R0sVQDeXZ+79WRnhx41L4=; b=daDp6iGtf2E6cgWllBKZRMe+XLcYJPeNFS2p+GHbNKI/dAonKm2M1/DQ3KX+qO/v3iXSgap41 5xxgLXMKxrsDJFAkHGGJmnbdCOdDUZdM+O8ekdbB4ml4twb8Nf1Erxz X-Developer-Key: i=zhouchengming@bytedance.com; a=ed25519; pk=xFTmRtMG3vELGJBUiml7OYNdM393WOMv0iWWeQEVVdA= X-Migadu-Flow: FLOW_OUT X-Stat-Signature: 5todb3qm163kada3f7ecdmzdktw179yk X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 3A7484000E X-Rspam-User: X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1702441122-257257 X-HE-Meta: U2FsdGVkX18pNTEqAmuPSJ0urfbl1iV0g7SCzxP/8yh1qpuLmOXlEdN0ey48jNoWHdwL9qcafX1mgDrQZmGChS5mI9eYjv/IICN1d7MqcKxr5TjF9JUEvRlWCozacu77Ufrz9orta1Xjp/WZ2/C04oTHZqzBt8/eO1tCMYOMJ7N+cbJYGNCx/A7XbNsNwxKpA+ZUpLGMxNTJruViPT9pGvd0mMN2HINY6GYqUvGjop9yoNIX5XaBRZ120Tlmj4FgEH2rRXQhAjkCCtKRz3s9WA3m7tSDPfxCRG83ivzEkJ2FygZeXqtLUYkUYTFdwm0EuIIqIVHjyaND3lBNWK8iM0UKVu38XGAqKuZIZ/tx9Xvatxw0lEKRNGycjbX+/mr5NapthoF0QZtIcOF0kBoOOh0a/ZTxrcsuC+H2fTys1euT/iOyfACfPujWnklsrrGuRNbM2HGq2nfBoFj9c8f3K57iJihH19C8ycx/XtVEeJ3qc3Y+dADnSc9dSUUcy6tTmAOcVD89d0B8UgLsqX6o4vnUrcYACXJfRRCUnfF7zPMxWhAbhPVhz9SMcmH8Uq8P+7gNDOIfpmsg3h72FfaRcAMHmtwf7efpFuTXmT0L8kLsYaFBhMmtFJsexgjyec7OSrRZmp42HoNwUtAs55pyulgtajz2pZqpMm4XzvP9Bwv7vk3VQG+nkem/KlQWFXgTdgjLjP26LWaJ8+AyfE2My8LQsH1y30VK+6aOjAMdujjFNZk90xK2Fya1xMpx56cMZDDTIdFvtzp8Cgk2ujtLgY0IRmLwCDtzixECGu3ZHZHguIbjIXWDHeLoly5FnhBTsFKrKBkRuj0fun6hn8+rxT0YuU4TfVwpvFtE81n//V6kyVjFn4uy09ZraNVMxaAveBBJo0XZQBenE1igwu8uvtB36GC742/knK7keLU4hjDj08utTmeEDpdB9cdYX8VdWYs/LwptqZ23sW4kwyK SkA4K2/D oFnRkvEEZBE7AuSz2qj61TvbCoJ5OaCpw/gEkNaSr3Xj9A+Ie+CpvWMPFsZuNL2vB6PCkpkEVMeTiG9iYc3zqI8DxSFwzgjCSZ3PFxAAILSVs9kGp6XlPNftpOq/u1GgYfwjgSC9nWVV1lnRJ4c/PR5ROGjiZRydHZNEZoMxlDhR33TuV1GThnzQcGvWctM/caEK+NnxBgTg38zz98LhG102oA+jmhecJC5j/pXoOAxmaZ4ep5I5Kjmthzbgw9deglY7tgCT0AaV8DOm1+tFF1p7ke9WVL65MUApACTTSkhovmMYSjt7YSrD3cOTYmOGzDyXZC4Hcl7b9LQXCJnX+aB9pCdMhLAGs66525pC87SChx5rys3ay7ISJ4Q== 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: Also after the common decompress part goes to __zswap_load(), we can cleanup the zswap_reclaim_entry() a little. Signed-off-by: Chengming Zhou Reviewed-by: Nhat Pham Reviewed-by: Yosry Ahmed Reviewed-by: Chengming Zhou --- mm/zswap.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index 0476e1c553c2..9c709368a0e6 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1449,7 +1449,6 @@ static int zswap_writeback_entry(struct zswap_entry *entry, struct page *page; struct mempolicy *mpol; bool page_was_allocated; - int ret; struct writeback_control wbc = { .sync_mode = WB_SYNC_NONE, }; @@ -1458,16 +1457,13 @@ static int zswap_writeback_entry(struct zswap_entry *entry, mpol = get_task_policy(current); page = __read_swap_cache_async(swpentry, GFP_KERNEL, mpol, NO_INTERLEAVE_INDEX, &page_was_allocated, true); - if (!page) { - ret = -ENOMEM; - goto fail; - } + if (!page) + return -ENOMEM; /* Found an existing page, we raced with load/swapin */ if (!page_was_allocated) { put_page(page); - ret = -EEXIST; - goto fail; + return -EEXIST; } /* @@ -1481,8 +1477,7 @@ static int zswap_writeback_entry(struct zswap_entry *entry, if (zswap_rb_search(&tree->rbroot, swp_offset(entry->swpentry)) != entry) { spin_unlock(&tree->lock); delete_from_swap_cache(page_folio(page)); - ret = -ENOMEM; - goto fail; + return -ENOMEM; } spin_unlock(&tree->lock); @@ -1503,15 +1498,7 @@ static int zswap_writeback_entry(struct zswap_entry *entry, __swap_writepage(page, &wbc); put_page(page); - return ret; - -fail: - /* - * If we get here because the page is already in swapcache, a - * load may be happening concurrently. It is safe and okay to - * not free the entry. It is also okay to return !0. - */ - return ret; + return 0; } static int zswap_is_page_same_filled(void *ptr, unsigned long *value)