From patchwork Thu Oct 19 09:46:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikhil V X-Patchwork-Id: 15603 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp266794vqb; Thu, 19 Oct 2023 02:47:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEi/PgvqYvAfqTQB0ZRzxUy8u6PER0UlRBm8xpN1rkxYkpsASGffFuvOnvmu9PIAzXQVzU3 X-Received: by 2002:a05:6a20:8411:b0:14e:2208:d62f with SMTP id c17-20020a056a20841100b0014e2208d62fmr2663295pzd.22.1697708875605; Thu, 19 Oct 2023 02:47:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697708875; cv=none; d=google.com; s=arc-20160816; b=H2pwudvQbPwqyheOYnH8yCFmj77mRFYAoX4ByR5pMSfmnN1c6eyjoMih4sQ3ECuX2I nRMNTv6F0rl6HbTMH82xNoVuZ5tZkvk39iy41raAaLOCEiQZPk9fWZ2f4CBw476ETEPS xEFs2ymzESniz5afls88ldRVIdhhXOTuq7KgEkjw2bp521V5oM/ffwWrWqPS8Wtk9SYP Ey/3AJliBaAuc5jqbwEZvLYhzaiweqpjjvRjUAZkPygGzOZyHQZlTfYX53e3CbF3BqW/ JgJjAd/yRMC0+9pWZy+XyF8MGqUfl2uu9dD6tV88Gl7FLCg/sHYRozlyU0HASSnaAiSt 1DWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=d/LRBcgUOKI8CzuX0DfvgrJ2RKaI2w5IC+EtJfAJAB4=; fh=cIgzg8nfoGwBqyJ+F0i/MBf8Yyqyv8/4qMjisng3KwY=; b=ImZcpIGeQsdrFggWxPOx5mdtKXCXoJNtNri+JiWd0Myol+HZkzmqsaZGfHX0w+UpG3 FzGpDrOVgx81CJBL/c0saZFJtboZ7Mgt7oVJf4pNa41xB94erLT6wqpfZU0zIMXU255S 4K8WbxJcstvTVNhMmhq3S5FZngAubXdlMNNZf8p7C1knAUW2+zlzC8As7y9DulAMHp6x CxBJqJ7Q9w5YW6tLJ3Hvo8LyN0JwBTrXosBK+GLGatq/+1YE8QN/xT1zlLcaOKxP769z GehwSn3OHdD4gQdXJ4QfMYZBBQQJ1beDz8yD9eqYLgzi9x11XkLU4qHFtJOxqaj3KDHl xyQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=nHRc45rK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id 136-20020a63008e000000b0055c7eb53d7fsi4074207pga.584.2023.10.19.02.47.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 02:47:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=nHRc45rK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 771518073DDB; Thu, 19 Oct 2023 02:47:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345060AbjJSJrn (ORCPT + 24 others); Thu, 19 Oct 2023 05:47:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345108AbjJSJrl (ORCPT ); Thu, 19 Oct 2023 05:47:41 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A247011D; Thu, 19 Oct 2023 02:47:39 -0700 (PDT) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39J9bWGc015350; Thu, 19 Oct 2023 09:47:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=qcppdkim1; bh=d/LRBcgUOKI8CzuX0DfvgrJ2RKaI2w5IC+EtJfAJAB4=; b=nHRc45rKe7r+Imm0mDy3VLyAlQm3k1Ih+qsC0asrGdBKMcV7KEsriOIZJXAsgtcJhlkg Xtk3VOQb4kkI7zMSitZixk+eG7zQHN8AAXqhA5yPdqEPH/Ukx9EVgXQPHCLm7ZIG/ZS5 c46U+4KoNDY0Rr7PTFIAhGaKrjz1hNCSVvv+e2tM4O3X/MkMPvH4XyZMIg4d4QfRZaGQ UBTTGca6PxkyPMUdJ/l8XxL7RBTI98ei+GBIxGc9TmfbtvSVImi1OTbO0ybZgLDPSobZ VyQZZG7YmZ0oJyRplG7zt8xFfTHwx+EoAzZce3Z6G05xebmePO6FF99PqUSrNH2r2gbP 0w== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ttcuv2u52-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Oct 2023 09:47:14 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 39J9lD4f031318 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Oct 2023 09:47:13 GMT Received: from hu-nprakash-blr.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Thu, 19 Oct 2023 02:47:06 -0700 From: Nikhil V To: Pavel Machek , Len Brown , "Rafael J. Wysocki" CC: Nikhil V , Jonathan Corbet , Catalin Marinas , Peter Zijlstra , Steven Rostedt , "Paul E. McKenney" , Tejun Heo , Randy Dunlap , , , , , , , , , Subject: [PATCH v2 0/4] PM: hibernate: LZ4 compression support Date: Thu, 19 Oct 2023 15:16:33 +0530 Message-ID: X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: oYnHSVhVJwt5vtusK7SueU_pKNui8MK_ X-Proofpoint-GUID: oYnHSVhVJwt5vtusK7SueU_pKNui8MK_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-19_07,2023-10-18_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 mlxscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310190082 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 19 Oct 2023 02:47:52 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780176781790051679 X-GMAIL-MSGID: 1780176781790051679 This patch series covers the following: 1. Renaming lzo* to generic names, except for lzo_xxx() APIs. This is used in the next patch where we move to crypto based APIs for compression. There are no functional changes introduced by this approach. 2. Replace LZO library calls with crypto generic APIs Currently for hibernation, LZO is the only compression algorithm available and uses the existing LZO library calls. However, there is no flexibility to switch to other algorithms which provides better results. The main idea is that different compression algorithms have different characteristics and hibernation may benefit when it uses alternate algorithms. By moving to crypto based APIs, it lays a foundation to use other compression algorithms for hibernation. 3. LZ4 compression Extend the support for LZ4 compression to be used with hibernation. The main idea is that different compression algorithms have different characteristics and hibernation may benefit when it uses any of these algorithms: a default algorithm, having higher compression rate but is slower(compression/decompression) and a secondary algorithm, that is faster(compression/decompression) but has lower compression rate. LZ4 algorithm has better decompression speeds over LZO. This reduces the hibernation image restore time. As per test results: LZO LZ4 Size before Compression(bytes) 682696704 682393600 Size after Compression(bytes) 146502402 155993547 Decompression Rate 335.02 MB/s 501.05 MB/s Restore time 4.4s 3.8s LZO is the default compression algorithm used for hibernation. Enable CONFIG_HIBERNATION_DEF_COMP_LZ4 to set the default compressor as LZ4. Compression Benchmarks: https://github.com/lz4/lz4 4. Support to select compression algorithm Currently the default compression algorithm is selected based on Kconfig. Introduce a kernel command line parameter "hib_compression" to override this behaviour. Users can set "hib_compression" command line parameter to specify the algorithm. Usage: LZO: hib_compression=lzo LZ4: hib_compression=lz4 LZO is the default compression algorithm used with hibernation. Changes in v2: - Fixed build issues reported by kernel test robot for ARCH=sh, [1]. - Based on 6.6-rc6. [1] https://lore.kernel.org/oe-kbuild-all/202310171226.pLUPeuC7-lkp@intel.com/ Nikhil V (4): PM: hibernate: Rename lzo* to make it generic PM: hibernate: Move to crypto APIs for LZO compression PM: hibernate: Add support for LZ4 compression for hibernation PM: hibernate: Support to select compression algorithm .../admin-guide/kernel-parameters.txt | 6 + kernel/power/Kconfig | 26 ++- kernel/power/hibernate.c | 85 +++++++- kernel/power/power.h | 19 ++ kernel/power/swap.c | 189 +++++++++++------- 5 files changed, 251 insertions(+), 74 deletions(-)