Received: by 2002:ab2:6f44:0:b0:1fd:c486:4f03 with SMTP id l4csp70186lqq; Wed, 12 Jun 2024 17:18:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVou5NosA9FOw8NNpU1ZgWtErbGiY4rxZn11gfFJpJGzw9nRASszogwEFhPyCb7+xoUbdQvdk35LyGRKjbn6l7KJ7WWO/uA+A8fNtnVPA== X-Google-Smtp-Source: AGHT+IE/g/iqXcyp51xE23NAHQsH2jassYznC7RwV7rj+W5QYNBes7d/Ff+TmdVaSCq0QfO8CrZI X-Received: by 2002:a9d:5611:0:b0:6f9:41f6:c7e with SMTP id 46e09a7af769-6fa1bf54ce3mr3511783a34.1.1718237902546; Wed, 12 Jun 2024 17:18:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718237902; cv=pass; d=google.com; s=arc-20160816; b=QFsviJNfneSTYH/OYVr9Rs4a1ZH4JVkt85NEiJnRKW2SYf9M3d4Y2Kpm51OjEl2RSU Nf4nSouzZqPwTgO+S73Qtr06T1WMmXUi6r6Hx1pKE4XfZ9ZQAXJINO6Ph/xK8tBg3+eP Ln/HZSarx2nzQhqAyZ30g3nx0JNSyWJqNyOez9mzz8Mj7g2LklgdtXD5a9GfMMoPHcOm Za5p1rvIzXXEh4aTv6xkyUebivtcw7H16TQZlyBNf/x7gPnar/OzOMtVprHyHK/mYaIw k1YMOvYg8b8iinhNvUw02sK+Ql+SjOQ+K8kJHiTgMq1cjbQBIq93aVOVVYpVK4L8+oT7 uAWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=nM1IRL3FhQf4hdUIvRFuGRgOcnxQOCG2z5fACrcTNq8=; fh=n99NTaZzOYBRJU4F561m74yDrC/hLikxXv6Qbn0Ycpw=; b=p4tCIuoPMkxuXL5mWL7AfK29SWF91mAdfVOMynL0EcK892g/0eleXQA5ZBv7qLgCXa 5olZ4c10S3MUCrfj6Jb9Mbnc2x2vpMGHTmIdvJxntlSB+tz5R/48QrVxpLOjBz9W+/qW iNjVvg7iYhcXUFgkxlLWkLQIXiwnovhCsi9EBXFeEmSjCsrZU3REGdjC6V1HCTpV9qLs TSj3jWGMAK5I3WJFFHlmcOmreNoaQXF4sYnhx5SrJs7d5ESJhxHckXeLAM/eI9JVF+vJ lFs46VeB3rOmdgWVsUqiKQH+0Q1tYaw9z6cOCLhjoX2qQvS+s3eWkzbtGS87PZnM/irr YZug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NQCyg9V4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-212402-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212402-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-798ac08edf7si19178685a.723.2024.06.12.17.18.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 17:18:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212402-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NQCyg9V4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-212402-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212402-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4508D1C21ABC for ; Thu, 13 Jun 2024 00:18:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB969522F; Thu, 13 Jun 2024 00:18:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NQCyg9V4" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F349A32; Thu, 13 Jun 2024 00:18:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718237894; cv=none; b=JV7XudasR0sctyYov8ByTKOKreRppbrl+60XzpTNu//MptZdN+exGOAh8HCP4hBn2rRG3RwE0TM6iI63TkAeJINm5/nlP/0yXaubP6jyujNJbvXu/AUF4SMVhU6C9yH8jO79Q9eqmulXJNgmHdUwN0GcwxC/Ww4sK8uONvigkjg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718237894; c=relaxed/simple; bh=SZefi0GZVNFS6wlza5IFvVBTTsmZN0q2ny+3b4RPSCo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=q1nfuVkyaJeYLN7pUwZrZmcxANsMEP4jogPWJDtkdf+YXEK8r08xtyHhXBL8z41zUO81PGDTYA+Em0J8vy9yyMQQy5CGhSFtjr7lAQN5OVYaaWY52m+WtChKPDhRmKJB9dn25AK8pvixVHSnbG8NYshRmS8mi91NP7kFSkBljwI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NQCyg9V4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A2D3C116B1; Thu, 13 Jun 2024 00:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718237893; bh=SZefi0GZVNFS6wlza5IFvVBTTsmZN0q2ny+3b4RPSCo=; h=From:To:Cc:Subject:Date:From; b=NQCyg9V4s+sJGt5RCWLFNEfoydPbD6uAkjxL6atxK6M0m4UIPdBlbz+wv90Fd2Ffo NRyArc1kpAReNK9OcsxMAS8kSB8hW8oX/BrwiGIXfbTVL72EkONZxOjuxtphJQ5zng sdmDtGqrPx7u7CJPQevJbpmoOMduoXwhXmPFcmTkOHzxVcEE1Y1KrgOLr4FPTlsNyT f6jR24eIcvVwPNcgEdP1Fl+MeMyiB9O4cHmvVQnYbSyRTbLSGdOa5uT8ipIrhCtM2R qtFa5tLb6M8eTh7EXsPjVpq0uReX1hXxWcjW8VxxLy9ZbHDQYtX3IVMRd32L9cJeNQ 7R1kKlvmD2/tA== From: Jisheng Zhang To: Minchan Kim , Sergey Senozhatsky , Jens Axboe Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH] zram: use copy_page for full page copy Date: Thu, 13 Jun 2024 08:04:22 +0800 Message-ID: <20240613000422.1918-1-jszhang@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit commit 42e99bd975fd ("zram: optimize memory operations with clear_page()/copy_page()") optimize page copy/clean operations, but then commit d72e9a7a93e4 ("zram: do not use copy_page with non-page aligned address") removes the optimization because there's memory corruption at that time, the reason was well explained. But after commit 1f7319c74275 ("zram: partial IO refactoring"), partial IO uses alloc_page() instead of kmalloc to allocate a page, so we can bring back the optimization. commit 80ba4caf8ba9 ("zram: use copy_page for full page copy") brings back partial optimization, missed one point in zram_write_page(). optimize the full page copying in zram_write_page() with copy_page() Signed-off-by: Jisheng Zhang --- drivers/block/zram/zram_drv.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 3acd7006ad2c..4b2b5098062f 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1478,11 +1478,13 @@ static int zram_write_page(struct zram *zram, struct page *page, u32 index) dst = zs_map_object(zram->mem_pool, handle, ZS_MM_WO); src = zstrm->buffer; - if (comp_len == PAGE_SIZE) + if (comp_len == PAGE_SIZE) { src = kmap_local_page(page); - memcpy(dst, src, comp_len); - if (comp_len == PAGE_SIZE) + copy_page(dst, src); kunmap_local(src); + } else { + memcpy(dst, src, comp_len); + } zcomp_stream_put(zram->comps[ZRAM_PRIMARY_COMP]); zs_unmap_object(zram->mem_pool, handle); -- 2.43.0