From patchwork Wed Oct 4 09:30:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikhil V X-Patchwork-Id: 14902 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6f87:b0:13f:353d:d1ed with SMTP id tl7csp2494028rwb; Wed, 4 Oct 2023 02:32:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGvgY/ZJMtfT0m74aYp4W8c68ldREuGfM8VYNOY+AF2QYev2DF+WJf2V5/QC/5g3yQIr1Tk X-Received: by 2002:a05:6a20:5485:b0:161:25e5:8de9 with SMTP id i5-20020a056a20548500b0016125e58de9mr1929602pzk.48.1696411940080; Wed, 04 Oct 2023 02:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696411940; cv=none; d=google.com; s=arc-20160816; b=vskiOB6oadDe6JHPOJwgf0Ku7mK6K5mvFn09ml7vqxDtuktsjwdnvkyervh9BX4X3J Qjo88BnsuvJyWL2QPrv2pHNrR7N7BtnXpjPVadg5MhXa1q/xA7c7pFLIQTTHx0w0tmS8 uMbPRm7jp26gpadHbufHGlMVh13c35FVX5uAy6xHC51nsFhHXUHTgzcyizuyC6b0XzXg MOARYoaKkV/qU4BlgGhP7G20CnMqS3woISICsFCPz+CQEkcyaF7CsvmcwbnygI0YMOB9 m9Ja1VhFUIG3VOxkOA0KHjJ0SzXWLQ/JDVAx84EHfqc3YBE1TkTdxRrEGFQz2St8aDtA jFng== 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=gjwpo7lC09458NWPJEtYmjKkWWJRSyPQaso/gCQe69k=; fh=IXqhMW9sxtvx7PT7DHqt8QsEyj8XjZbHOHO/DCt7Pho=; b=t80cO68wu25vbvmh00bUGy78pCElY4d2O7gLQWcBql70D0Vf8KklbGs2C79IOGxeac BfNFRopB4TiUJKrS0d2tMQEKmYU6l2RrFEvezThZuMlDvnChGyuwcs8fUFr/yPv1bVLq 9ZCB9fqcDTtnkgarglj45nHBxkForqLMetCoG8f/KitTgR28MGXCdhh+RXfuvCD/2Ybo UMJY7BJiJo9RfCPlt/UgMYkiVCbhmdApdZa/rx7QyUm1WXJeyBBDbKbogvOGvnB/GxUc DxHVVonSlg45uDaX6gS6YpNeKd/8gWlgSzCKgmDqBsHOnYgcxkLa1bs/0s9QdXLkVy7M nWXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=bPjcpIio; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id e2-20020a637442000000b005859da6172bsi3229671pgn.727.2023.10.04.02.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 02:32:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=bPjcpIio; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 5C49C81A5A5A; Wed, 4 Oct 2023 02:32:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241906AbjJDJbl (ORCPT + 18 others); Wed, 4 Oct 2023 05:31:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241800AbjJDJbk (ORCPT ); Wed, 4 Oct 2023 05:31:40 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A46AAB; Wed, 4 Oct 2023 02:31:36 -0700 (PDT) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3949R3bN026887; Wed, 4 Oct 2023 09:30:59 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=gjwpo7lC09458NWPJEtYmjKkWWJRSyPQaso/gCQe69k=; b=bPjcpIiowGTGMUVnyxtD83aFYXl3uGQ41l98+hPM5x2fNOdzKp+p/rSjVD1Usqj0E0GW jH+hLJK4PdO4T8a4xW+COMWQTpJbxsb+J7wKWVOPZGouNzVEk+wvXlU15V7WKConkrnS wHPsEU8O7zF3LxtzrDqEPk6TVKM+JLNjH6VFvK2S+JBZIh0eGeSyVEHlphBvWYE8mqlf S/yhh/RPIL9TTH1ePCjSMfBFP41QaAkX89TgdrKioghJJGxe4WFA5JoGjgMwRyD+r0X3 7tKi77DzClg943GdmiYbpbZ8ASI9xlYY4ulWMGaD7xkkHyXHCfJO1f4vbHr4Wti0pVCd 1g== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tghsjtghb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Oct 2023 09:30:58 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3949Uvbo005583 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 4 Oct 2023 09:30:57 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.36; Wed, 4 Oct 2023 02:30:50 -0700 From: Nikhil V To: Pavel Machek , Len Brown , "Rafael J. Wysocki" CC: Nikhil V , Jonathan Corbet , Catalin Marinas , Tejun Heo , "Peter Zijlstra" , Randy Dunlap , "Paul E. McKenney" , "Steven Rostedt (Google)" , , , , , , , , , Subject: [PATCH 0/4] PM: hibernate: LZ4 compression support Date: Wed, 4 Oct 2023 15:00:13 +0530 Message-ID: X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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-GUID: KE-ZLKf0s4nz6dpU_WwvhWBcz4pZyiAR X-Proofpoint-ORIG-GUID: KE-ZLKf0s4nz6dpU_WwvhWBcz4pZyiAR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-04_01,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 bulkscore=0 impostorscore=0 adultscore=0 clxscore=1015 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310040067 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,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 04 Oct 2023 02:32:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778816846521960689 X-GMAIL-MSGID: 1778816846521960689 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. 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 | 25 ++- kernel/power/hibernate.c | 85 +++++++- kernel/power/power.h | 19 ++ kernel/power/swap.c | 189 +++++++++++------- 5 files changed, 250 insertions(+), 74 deletions(-)