From patchwork Wed Dec 6 09:46:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 13481324 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 53F03C10DC1 for ; Wed, 6 Dec 2023 09:46:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC29D6B009E; Wed, 6 Dec 2023 04:46:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D4BB36B00A6; Wed, 6 Dec 2023 04:46:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B01766B00A7; Wed, 6 Dec 2023 04:46:49 -0500 (EST) 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 9DCC26B009E for ; Wed, 6 Dec 2023 04:46:49 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 75B4114015E for ; Wed, 6 Dec 2023 09:46:49 +0000 (UTC) X-FDA: 81535914138.16.B85B049 Received: from out-187.mta1.migadu.com (out-187.mta1.migadu.com [95.215.58.187]) by imf14.hostedemail.com (Postfix) with ESMTP id 88F52100005 for ; Wed, 6 Dec 2023 09:46:47 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine); spf=pass (imf14.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.187 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701856007; 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=h8eN1DUckOMA/YVkW+LuDv2KkgdMbh5axm547Y4P2HY=; b=eWqoJSqG7Ey+TuvG1s+lC04+ICLkTcyrpOl63poPUiMfsDK/vBKL0V6xgBeEgGKSrimNBf M/ZyFdPZKyPiOl7DnrMUaYnjWNwH4v29QNHOzZ7Tjqw/JVl9s+sb79iG6RapZNqDDZeYvK QrJtIcQVImQAGc6QMXWp/dPcYh9uDy8= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine); spf=pass (imf14.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.187 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701856007; a=rsa-sha256; cv=none; b=n/DvSJhTDH0OR2xuA7Xfh7Dr4dsIGcYCD3b2NghchmAvwJyHqWCU/EW4lvA8id8AHQBOmf w8myrFMTT3lISG/rylmEJkaG7w0EKsEi3lQAZ/+hZHxb1MKDyfG0UqUP3vU5xyxjUCM9qu /CsHZdX9ZItBkRDvlvzkSi+RYdZHhCw= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou Date: Wed, 06 Dec 2023 09:46:30 +0000 Subject: [PATCH 7/7] mm/zswap: cleanup zswap_reclaim_entry() MIME-Version: 1.0 Message-Id: <20231206-zswap-lock-optimize-v1-7-e25b059f9c3a@bytedance.com> References: <20231206-zswap-lock-optimize-v1-0-e25b059f9c3a@bytedance.com> In-Reply-To: <20231206-zswap-lock-optimize-v1-0-e25b059f9c3a@bytedance.com> To: Vitaly Wool , Nhat Pham , Johannes Weiner , Michal Hocko , Seth Jennings , Dan Streetman , Andrew Morton , Yosry Ahmed Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chengming Zhou X-Developer-Signature: v=1; a=ed25519-sha256; t=1701855988; l=1963; i=zhouchengming@bytedance.com; s=20231204; h=from:subject:message-id; bh=WQp3TO7eGK4NEJ2KSQiW8NgcHiI75uDxqzzNLxV8SyA=; b=cX50JTACBKj/y4OSJ3fqN9XlNGNG8ePq/CbHqPflo46e6ZMG5upWYYRApku021YWMN1SgS3i9 B/xOj7S/bMGBm4R4og7jAUlPoBl15i7PcZIVp5JnUC1yxy4hhNQBj7H X-Developer-Key: i=zhouchengming@bytedance.com; a=ed25519; pk=xFTmRtMG3vELGJBUiml7OYNdM393WOMv0iWWeQEVVdA= X-Migadu-Flow: FLOW_OUT X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam-User: X-Rspamd-Queue-Id: 88F52100005 X-Rspamd-Server: rspam05 X-Stat-Signature: 7gpd8z7zu1p7npxfsiyyiiffxf5uetuc X-Rspam: Yes X-HE-Tag: 1701856007-978318 X-HE-Meta: U2FsdGVkX19yK8e8Bh2J2NTK9YT8SsU0hf8p7MR5GTn47wYk8u9DM6wVBYp/zynhV3eYeqxcnpWahHsxYTLD6Xch3tKkiZpNcVOkSIYQGwCwXOlxxrWZiyoXnOxdONOXToF/oZCo7zBCEyjP3DxtSlj6vMy6h5E8UK+83d6FnZHLVZEaX/EQh74eQqj+b4lCTbQwiCuOe9jyL+EIZY7cxtZvL92N2FJLy7ag9qP+kRV9caJWdf8fLQZYHxcX4kzAQbLQiqqw8VkYOoPI3Nnm7OMQplQKHbbi2k5QAltRQ0RuJZega8P4bEJQXowMWj89mXtUM2oboODw4Ruvj00SCVdQxheZWumoIVuR+BWtvtFFH2X5vgCekQ1d3Y0kWV+AGya+4Ec9PQ8VwBiw2rvMsRBzk6EkBelg1Ao0kqPQgDWkUqReL45SBwjVGReCOnPpSERxjYaK8YJhu5GyQ81KitQD+QwiJ9Ud4rIcNwXn1wMU3fFDl1KRhM0kCNubIjwQgWf7RN2WbIBbSn68TcShoi16D/PAWwrcdp/B8nCUuDp5BQeD1jBCn+ZubIrbo59EX3XlT1aCnDYUX7GORzklwkJTLzY9JECyBDFmDroT4H45kA1oT9mE160HLS8XjW+Em6B76o5Gk8viHvvrDRM9dw1QxDMXQlc0nTB1GwQQSL2Jr9MK07KO8zswOULq/uRnuBZ5GgbJ0iT8MtWzq6IeQDK4h+wIaejeejJQFsd6QitBtVLAmqTsb+LUIRtWOx1zZ9j2053qp6TNCSzVtxumP7eu3cehLi6Z9ZtDbP0GVoomiBBdWCz2aLvvwPTykTGTZk5dsTsDbM1Js7MlYj4P95XkpPetbk+51Llatd9GMwB57o/zPxPMQtV8ddHjPht536O/QxEQKUj7ijg95T7/R6RAIsIgctBvnT7O1Ts5msjFMLjYHY/yMFVJM2xm85l5YnjNJrzCjKrzjS8Z4Tn pGNmgXc7 N2dv3vMZ/PSsAirTyQDzIFeCz4p1RFCXJa3eMgqGvW7lzSkfSKm3AawjKSWZY5VLiVBsJ/LOBj251fVyH2kQ208M7Mil5j/WaImBoq3G5EaOk6sfFBUQIzYY+MivrnT/Wj+FslcOu+pIgN7ieD6mKsTQUzhuBzyHQLrpI1tBxMwIItI0vEzntlod9evZFKs+33hEyQWYSDTxE70aPHrWJhvez6P46/QvbfYqC89UbcGegbDQDA0CdTR/aUDw+MFQ4vPqeUIipKYJg4yuUwM7bpxzy/DL/GBlB4BHib11cOsEPTuhiff4xq+9CaJkXPOutWry0ItLBIL8d5QRfJNNvBNTZ7rznEZF5bbMOj2zuL37mX8mmKNMtG/9o0w== 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 --- mm/zswap.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index 50405811cd7b..d3fedda0d774 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1438,7 +1438,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, }; @@ -1447,16 +1446,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; } /* @@ -1470,8 +1466,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); @@ -1492,15 +1487,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)