Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp2554384rdb; Wed, 15 Nov 2023 04:24:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IHiQnQZVDoV5pBwFYuz3cSAMxCN2eN7ZStf+smlVqydl2SNmidiKrKtuB47wePXr/tnHLBW X-Received: by 2002:a17:903:264a:b0:1cc:5168:688 with SMTP id je10-20020a170903264a00b001cc51680688mr4471616plb.60.1700051043260; Wed, 15 Nov 2023 04:24:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700051043; cv=none; d=google.com; s=arc-20160816; b=th1dRMiB1PFhl/FIMXp/rMT6/cBPizpnEdIwMT+E+upYeQfvM6wozVGDF2NeVIHBlO vDF+6+1fpVClGcF/kd/cQTe2qKQRc9U8X4yJgu6Fv0q6y17gjxtVHLqtkt0EKrg8qfnt N2ETLxrpxvtivkq3/C+QoGMIbusWexP7v9uk/wuHG2tJT6XMS06jon3sN//gM6hZQ+gg hObUnA764XCxYJSNtOZi45P+mGWDagpvWfERBp+Rx6W1GyQi+76jeRqCiZbfZknwrpii fFRr2VqPb+J0kbXeTDGAY16ICtHkjKpHrO1QMgsglPqkAyBthJJUmsCt7w7hUd6Wf6T0 xStA== 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=eHywq8Zwh107MoZU5g4aLiOWOLQNY4JViDCHD9yOF08=; fh=DL7Tzq5pRM+LJBAJAQL5rnVWWj6tED453/IRf0MzzXM=; b=AvvtDaHzfsXfFm95A79qaDfDWeiVKg62wkZcmKAREswOXggn7XUclrxenEegpYx/6a qJpBUrkPR267HToS8LrC2HCbyzfKZoNw1fhv5qzqmfR/3lwqakQbLiILiSf0vaOlJR7d 9lxF+8UTQR5RPOFofin7VtlMfptqrAo44GN73K4mj0otK9ZZJFnmTQDZZ8yAkhdgkkut WKkaX6eNFHeT0LoufPwft8Te+fMFGA67WF4lH1PAmQP7sgSVYY2RJdWZamJmLfjLVgTW HtroHlYgObbnE0kbFU8bs7ucTpRPdBE7lu5Nz2HQfLy6TCGk2Ra7A+DTccJtAr6Y46dP Ulvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=YMO0Hrfi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id z17-20020a170903019100b001cc60ca8f43si10407342plg.358.2023.11.15.04.24.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 04:24:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=YMO0Hrfi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id CBA3E81896F6; Wed, 15 Nov 2023 04:24:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343737AbjKOMX6 (ORCPT + 99 others); Wed, 15 Nov 2023 07:23:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343708AbjKOMX5 (ORCPT ); Wed, 15 Nov 2023 07:23:57 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62E861BE; Wed, 15 Nov 2023 04:23:42 -0800 (PST) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AFC0DZk022770; Wed, 15 Nov 2023 12:23:26 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=eHywq8Zwh107MoZU5g4aLiOWOLQNY4JViDCHD9yOF08=; b=YMO0Hrfiu77o8xlqC7wBb1w3R1lITaUh0bMFyOTGJjVOhF9BNJ5fBZOjY40pw2QBJqLv gPY1MOlc715gCrmmuYLLZD7k9YzVHRhRFoiJ/tmvsZ1NGIVo9tEsx3UxGrtY/pZrTBfb uuJi9Emqar8PkaRLryRqDCL9K4LS/wEhAfrF1Lt/eWerNvHOR3ycWdPsMdHUld70RFrW lBu5nrP8qaVBf6zNQP0s9OQhBfsnrjj2VbuYP39zfHBEV+khOdIIVYSihvvBZAxb5uV2 p7iFboJ+LNs0Lx060x0jVNkMH/n6/W29Qu6Wu87VLJXF//XUbArCzSRCAXDKDvOzMJQj jQ== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ucq5f8xqb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 12:23:26 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3AFCNPQL017125 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 12:23:25 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; Wed, 15 Nov 2023 04:23:19 -0800 From: Nikhil V To: Len Brown , Jonathan Corbet , "Rafael J. Wysocki" , Pavel Machek CC: Nikhil V , Randy Dunlap , Peter Zijlstra , "Steven Rostedt (Google)" , Tejun Heo , "Paul E. McKenney" , Catalin Marinas , , , , , , , , , Subject: [PATCH RESEND v2 4/4] PM: hibernate: Support to select compression algorithm Date: Wed, 15 Nov 2023 17:52:10 +0530 Message-ID: <4f0854e2892298973d6d50fefc66279961604d12.1700048610.git.quic_nprakash@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain 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: Zj_UwvVwYz-k9Ghjr6FOArBCSQt8iEHe X-Proofpoint-ORIG-GUID: Zj_UwvVwYz-k9Ghjr6FOArBCSQt8iEHe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-15_10,2023-11-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxscore=0 spamscore=0 phishscore=0 clxscore=1015 impostorscore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311150094 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, T_SCC_BODY_TEXT_LINE 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 (snail.vger.email [0.0.0.0]); Wed, 15 Nov 2023 04:24:01 -0800 (PST) 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 65731b060e3f..4acc2d95030a 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1735,6 +1735,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 274327232dab..721a9e3e0c9a 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); -- 2.17.1