From patchwork Wed Oct 4 09:30:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikhil V X-Patchwork-Id: 148204 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6f87:b0:13f:353d:d1ed with SMTP id tl7csp2493919rwb; Wed, 4 Oct 2023 02:32:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG26pcdn3P7wtS9RIgjMdOofYxSzWg6ge0EsUjTswgoSEGnc6XUYO80jkJLobiTbTc7TnWo X-Received: by 2002:a05:6a20:3cab:b0:15a:bf8:7dfc with SMTP id b43-20020a056a203cab00b0015a0bf87dfcmr1962047pzj.15.1696411924959; Wed, 04 Oct 2023 02:32:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696411924; cv=none; d=google.com; s=arc-20160816; b=Hiikv8AIhlKO5UbhMidaTKRqwyq+w93wvyIW4U5Z2XgxKh/rcfEJk3BxE+DuBdZ2PO 9OYbco1AsPzseFCpoMrkqHd1S1KoDBFlt9qD3wN9R4vVYnSnCT30IKM3z5ktXdQAthpp HYHDlULnsNSiDK/tawgICfFqVmRGfoH9y4RXo6H6hw7gM+wbHBQkYLNgIiDlDggK1GCw KPyWxyxPwrQe91zPfy3CnHDI8DpxJg8ZfUf6hyAYo4lRXEvQbC6MBykDFIsOoEAkGqsm +5UumpolRoYW2IyapPaZcV55rHp+MbMHku7wPGC65Ucue4TDGbbwFAmEIA4mU+57+6Q0 yIBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=MUhzYguRNuFFCnbPijV6TT9fkbP4WSksbMRqsHfa5KE=; fh=zXZ4TwGYk7gB/57gYsP3Vng7cSpHqTA7q2L5M8bR6Gc=; b=081XDGZvNdRV1WRdj4UI98ejYSSSFWi68vZ1qvkdI2s2pFe3/mpNlkuPwxD0ZUestx gKTZR5v1ZRAut7WZXVwBIEDYhNKApaYfw8CanKL8iAENK6KVWaPE0NGN2U4UVsbzHa0d kPbl+bnDwcRbm4ppjGTiZHYsno05h2AwcBtC8yAdqloe4Q+QyUWhxy3A5ou01C9IonQl V6QaO+q4JB6uxtCpuuTVCiFAVOuyjgK7R/haXfLDgKxM8Ip2dTN2dxVzDg090fZ5euoF EhbsfC21fck2gGMp4dHhb2fTM1vY2nbBxyy62JcH47yZw0RNPBDLsgyIUIUyVvuKvMJd E+3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Z0U4G0+c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id d10-20020a170903230a00b001b8ac52a19esi3760781plh.436.2023.10.04.02.32.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 02:32:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Z0U4G0+c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 35560833CE0D; Wed, 4 Oct 2023 02:32:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242000AbjJDJb6 (ORCPT + 18 others); Wed, 4 Oct 2023 05:31:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242039AbjJDJbx (ORCPT ); Wed, 4 Oct 2023 05:31:53 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D5E511B; Wed, 4 Oct 2023 02:31:47 -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 3945WKvB013360; Wed, 4 Oct 2023 09:31:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=MUhzYguRNuFFCnbPijV6TT9fkbP4WSksbMRqsHfa5KE=; b=Z0U4G0+celwPaRj8LN05Z5/4gHdthZuXqXIdpyxXFPG83QRBkrLLkM0r30eVRz7KQc5/ 3umNF53hwWpj2olOVKy4yuIebnRvCY+HxCReLdZUCRT5+Pq1FRF3McEtGhc7QrDawaDM GO93Pg95f/qo+7ouA55efwRzXBk6ZiUzBz4XQ3yXrVLCR2SQR52BE7V2hi6L3W+MzNSN s6CO9WE2ERsZEXNF66wQCl+kgpLqXN2Xmo+IM6KDnPeJKcix0yAGXLG/ZkwweGI3LeZL mjoBboRZMNtX5Lt0gejP/sYbjUXZXYsk2pgn/MEzUQygB6SIsnx/TWEGSGqJcWXIzhvt tQ== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tghsjtgjm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Oct 2023 09:31:33 +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 3949VWT3023298 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 4 Oct 2023 09:31:33 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:31:25 -0700 From: Nikhil V To: "Rafael J. Wysocki" , Jonathan Corbet , Len Brown , Pavel Machek CC: Nikhil V , Catalin Marinas , Tejun Heo , Peter Zijlstra , Randy Dunlap , "Paul E. McKenney" , "Steven Rostedt (Google)" , , , , , , , , , Subject: [PATCH 4/4] PM: hibernate: Support to select compression algorithm Date: Wed, 4 Oct 2023 15:00:17 +0530 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: 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: eEf-C7-HcELNFc3GGS28LbssY0OvEitw X-Proofpoint-ORIG-GUID: eEf-C7-HcELNFc3GGS28LbssY0OvEitw 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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Wed, 04 Oct 2023 02:32:04 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778816830299238909 X-GMAIL-MSGID: 1778816830299238909 Currently the default compression algorithm is selected based on Kconfig. Introduce a kernel command line parameter "hib_compression" to override this behaviour. Different compression algorithms have different characteristics and hibernation may benefit when it uses any of these algorithms, especially when a secondary algorithm offers better decompression speeds over a default algorithm, which in turn reduces hibernation image restore time. Users can set "hib_compression" command line parameter to override the default algorithm. Currently LZO and LZ4 are the supported algorithms. Usage: LZO: hib_compression=lzo LZ4: hib_compression=lz4 LZO is the default compression algorithm used with hibernation. Signed-off-by: Nikhil V --- .../admin-guide/kernel-parameters.txt | 6 ++++ kernel/power/hibernate.c | 31 ++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 0a1731a0f0ef..3f5f3e453db1 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1734,6 +1734,12 @@ (that will set all pages holding image data during restoration read-only). + hib_compression= [COMPRESSION ALGORITHM] + lzo Select LZO compression algorithm to compress/decompress + hibernation images. + lz4 Select LZ4 compression algorithm to compress/decompress + hibernation images. + highmem=nn[KMG] [KNL,BOOT] forces the highmem zone to have an exact size of . This works even on boxes that have no highmem otherwise. This also works to reduce highmem diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index 87be8cda9b9b..ccc7a1aaed8d 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -742,7 +742,8 @@ int hibernate(void) * Query for the compression algorithm support if compression is enabled. */ if (!nocompress) { - strscpy(hib_comp_algo, default_compressor, sizeof(hib_comp_algo)); + if (!hib_comp_algo[0]) + strscpy(hib_comp_algo, default_compressor, sizeof(hib_comp_algo)); if (crypto_has_comp(hib_comp_algo, 0, 0) != 1) { pr_err("%s compression is not available\n", hib_comp_algo); return -EOPNOTSUPP; @@ -1416,6 +1417,33 @@ static int __init nohibernate_setup(char *str) return 1; } +static const char * const comp_alg_enabled[] = { +#if IS_ENABLED(CONFIG_CRYPTO_LZO) + COMPRESSION_ALGO_LZO, +#endif +#if IS_ENABLED(CONFIG_CRYPTO_LZ4) + COMPRESSION_ALGO_LZ4, +#endif +}; + +static int __init compression_setup(char *str) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(comp_alg_enabled); i++) { + if (!strcmp(str, comp_alg_enabled[i])) { + strscpy(hib_comp_algo, str, sizeof(hib_comp_algo)); + goto setup_done; + } + } + pr_info("Cannot set specified compressor. Falling back to %s\n", + default_compressor); + strscpy(hib_comp_algo, default_compressor, sizeof(hib_comp_algo)); + +setup_done: + return 1; +} + __setup("noresume", noresume_setup); __setup("resume_offset=", resume_offset_setup); __setup("resume=", resume_setup); @@ -1423,3 +1451,4 @@ __setup("hibernate=", hibernate_setup); __setup("resumewait", resumewait_setup); __setup("resumedelay=", resumedelay_setup); __setup("nohibernate", nohibernate_setup); +__setup("hib_compression=", compression_setup);