From patchwork Thu Oct 19 09:46:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikhil V X-Patchwork-Id: 155413 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp266952vqb; Thu, 19 Oct 2023 02:48:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGa2s9aYmoEAHkJ9b490x7FyVR8xrtZniZoFePs1nu5LXoBwhkOhm1n/lKB9LJLMDQvsx/t X-Received: by 2002:a05:6358:5d91:b0:135:4003:7851 with SMTP id s17-20020a0563585d9100b0013540037851mr1601540rwm.19.1697708905168; Thu, 19 Oct 2023 02:48:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697708905; cv=none; d=google.com; s=arc-20160816; b=dD3GHuBtlkwbhEhsZLs78a9vU+VEYKeGl3Q/tl8I10dIjWXpni5DhwhWOIzPPZAT2u OQ5sf/V7qAtyOA+KTybRD8uExR2Q6TzPqRWF8/P1D6cJn1T2VwJKtCeYCd+I6Q5Bf6oi oGk9UwlQGft9Ov61IIcDpci2TpGto7mW1Wju7ZXaT3n135DO2grlG5B2lSxQVqbWFdpI aQSLVzuIW8sC6pDeAJZDYXIhFyn6Qj7mVLhQ7LjuTci1nvOURpF1SkWYNOrC4A+AKB9A F053Q9e58RI3fdz0AjETcgcObkyd1NJAlYsBghWmXGAh8nC7FGE5O7q4jU/L1LVVZ0G5 xRjQ== 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=Xr1YP9hElhcmLJxqzj69nYRaoxySfxgceC8VrlJTVsM=; b=z7v2Lah6lDI/2TYecn5E9MCn2ojiKcyemwn6D/m/aA1+ENFDQIuZ2JVc9ndA3zVYif pFur/c9CPnOKoTgQ4ioYd8smzyP1M5jlGOyg2zjG4cjak9ks2FM9UJklEKF7XgHFYgar ODjtdon/2VGWrExioP6X/UK6waxcH+Fueb+QeNkL6epWZ44TPaa1Xx4bRziYajzb6h9m fq8g4d9hq6XufwtTWiGnWh2mUkWceU1AQw1mlbcWMxlRipHghcG9YYY/6eWqPYJUUjsM So4s1xCFIrJ4oXfEz/vw2Wo8uq+bYE2bd8d5+5rG7040rb5aB/AhkBll+HQkrdmgqjpK ZftA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=R6bwRuNj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id y33-20020a056a00182100b006b3aded7e97si6085859pfa.305.2023.10.19.02.48.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 02:48:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=R6bwRuNj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 78CED822CC0D; Thu, 19 Oct 2023 02:48:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345154AbjJSJsN (ORCPT + 24 others); Thu, 19 Oct 2023 05:48:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345116AbjJSJsE (ORCPT ); Thu, 19 Oct 2023 05:48:04 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9AC8131; Thu, 19 Oct 2023 02:48:02 -0700 (PDT) Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39J7siPh002966; Thu, 19 Oct 2023 09:47:50 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=R6bwRuNj8GCZtZCZzfxogCi75Vo87gLNwazoCjcBbJ6IpET1ZRYEeMnxRkAk7UPBZLnf KEligqetJ3jvqihEWCxKVzXuvicpfLFMsoBsLXEnRRulTHACO3bZjSQT17emwncGWyfP mNBtiwMIEEP3symDRlqZg3xQFatUFmD+NGC30tl/0d8blVUw5kLUj6UtWwDyecLvnZlg 9pkano/0aaaW/NTCFDROg62HiEWKKMdh7P7nnIXCSLMYQWal4l5gwtyw81BaNQPIWRm8 /oWfuZelwMH8ulGa3MvEcwzTnpNAaoD9TJorBKzDHjyWPBhadqBGR1ws/mVxD0lAC0sm Dg== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tt905bd49-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Oct 2023 09:47:50 +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 39J9lnM2000706 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Oct 2023 09:47:49 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:43 -0700 From: Nikhil V To: Len Brown , "Rafael J. Wysocki" , Jonathan Corbet , Pavel Machek CC: Nikhil V , Catalin Marinas , Peter Zijlstra , "Steven Rostedt (Google)" , "Paul E. McKenney" , Tejun Heo , Randy Dunlap , , , , , , , , , Subject: [PATCH v2 4/4] PM: hibernate: Support to select compression algorithm Date: Thu, 19 Oct 2023 15:16:37 +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: 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-GUID: 9uIls0hZuIT0Xva8RGiQPr3RlT9tzcZ9 X-Proofpoint-ORIG-GUID: 9uIls0hZuIT0Xva8RGiQPr3RlT9tzcZ9 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 spamscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310190082 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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 (snail.vger.email [0.0.0.0]); Thu, 19 Oct 2023 02:48:24 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780176812992624529 X-GMAIL-MSGID: 1780176812992624529 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);