From patchwork Fri Sep 15 14:17:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 140648 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1281381vqi; Fri, 15 Sep 2023 12:46:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEcyLiZtTj+1FfDaJpiMpzzCreVtxi3z7BNRV9VOFmhlVv0GMcqsSn7d/9UYiY8poDFyqAT X-Received: by 2002:a17:902:ecc8:b0:1b8:5aba:509d with SMTP id a8-20020a170902ecc800b001b85aba509dmr2862623plh.21.1694807206205; Fri, 15 Sep 2023 12:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694807206; cv=none; d=google.com; s=arc-20160816; b=iDI5T6JseJOe0YxKtyDEkRxw9hbGVpd+DDfdi5GOh1175HQQejs6s1JvuG9ros1oHp zlh6XSEzZ44fsGwyE5BgGRzSOnaZ8A0i6tzFMTRsKdV5dI9pvcbitL+U/b9cEccnTPXH 1Omteeo2sqT3QIHFaNglpydiqTc2qgiPzJsCVHmjXBDDKsT4jHgvLZPaM8vNdB96tt74 vBFfj+7IBDHrcqYv/y9ywZO3TKu23WWCOWwLHBW0Gt3LOYEFfP9z5GMO6MwyxAzFvPdg IIRiO+jbrOde+NlRIvH7+LLVGk21hFpPXWRKt8ZoquN5SXgEF50zOiET3eQEZsRQMghN 0HgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=QemNO+c45J3TSx6FcSHQfwkZOTsDS0K4Gg9M0rrbiy8=; fh=gbrdUV9UebpbcsJYI2b/W9hy+ulikgjN8mEOSoE/04U=; b=bi+Mz3NUu7aYvg4i4NPMDH6cv1VZTy07u1/ZKTrgYciKFfB/uR9KY54RjnSPFyLAzh wBz0RROR8Cl22Nx3K2rJdBKqLPmIm2Vuf5Nek7cL3Zt4eAlkqSJtAWi9pOyPCpDXBQPC A3aaHGjnNOJpT28glYsOhO0PZi09+nh3VtrIxZRXnaS1ozhVRsTS74ZdGSeSOl7+hE0i IbfHw7pEB3iMoOAQonk75iwaQ+y/EreskAp8j0hQY/mgSWZ7B4KXd/kr3ArNgMIwUX75 R3K3ubIAyT/YbIvHGY2xoCybml4MXpQIJkLheCgzjQsQjlJASdoqfTX2QARRU/ZCbkjB URpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XPCWL4ZO; 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=linaro.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id p12-20020a170902c70c00b001bde9e8a29fsi3731117plp.183.2023.09.15.12.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 12:46:46 -0700 (PDT) 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=@linaro.org header.s=google header.b=XPCWL4ZO; 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=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7EE3D802F19A; Fri, 15 Sep 2023 07:17:29 -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 S235647AbjIOOR3 (ORCPT + 31 others); Fri, 15 Sep 2023 10:17:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235602AbjIOOR1 (ORCPT ); Fri, 15 Sep 2023 10:17:27 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B32122736 for ; Fri, 15 Sep 2023 07:17:05 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-31f7400cb74so1877386f8f.2 for ; Fri, 15 Sep 2023 07:17:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694787424; x=1695392224; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=QemNO+c45J3TSx6FcSHQfwkZOTsDS0K4Gg9M0rrbiy8=; b=XPCWL4ZOINzEDGzwkxAd+4pp4o23wSRqDe9Bpdm1tPc3ae6fh8SgGIHQKZXkyzZ++y kCxzgIpjNoQ9PAH9i8T1nbW3CeRPPzOURCUmP1SpkZHmStJwjDwXLvISreOQxpNwrI0F u3L55A6eUZ909+UDlyereh1eX3Qw2sHB1A6ESDy3BTbts+l5cxlrVRiFOmLsjHyHrd33 QoKhSkc2VwvTqY+yGMmd0GWoeaF96Spa89WoYGUACxTV6MHC12kks8NWwr1NnDFtVCWY Ccl4+K/WlTg9GFL7XN+hhvZfgDN3NE0kVn8CLPcPDJN1lvT0Ne64/k5mNhA6/3buYrqx o2sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694787424; x=1695392224; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QemNO+c45J3TSx6FcSHQfwkZOTsDS0K4Gg9M0rrbiy8=; b=RKhepyvn5ahQpalbIs69/ppejXYlYtLrFgmKFy4OR5duP3gfXu4m8fN/AHJGkuOPm/ rKdx8WbIrVzrzm6WACxSC8lzbzH0WNnOCzeeRBnqNlTeMT4P2RcXKzxuo8+bd0CQgWpf bDC8CtFs5EcEo9G4avuJZ8UsYh0hCDu+JloRd1YA/sqq1lul1DrbsSD6kuP3pz24UvNJ Vs6jD3PCO1Haq/yhDXRPMZYjJKxt9j5bYH5QY848KmkWXJ6p3q4xh85vos8sHrlgkTqE VPS/dU2Gpko4lqd65skbU06glLsxTyqklC6Cnewq+3MhX5K6/tstzC/8BxdnnW7+YIhO uz7A== X-Gm-Message-State: AOJu0Ywk0ycI59PRlkZg5bROGrhTtGy5+Ntnq435eHiSJYTtm4WgyX5a VDYeVaB0UJx7RRAIcWOmt5lMNg== X-Received: by 2002:a5d:4e4e:0:b0:31f:ecb2:1bf6 with SMTP id r14-20020a5d4e4e000000b0031fecb21bf6mr1562489wrt.8.1694787424007; Fri, 15 Sep 2023 07:17:04 -0700 (PDT) Received: from loic-ThinkPad-T470p.. ([2a01:e0a:82c:5f0:92b0:d1e8:d03e:ab51]) by smtp.gmail.com with ESMTPSA id z11-20020a5d440b000000b0031423a8f4f7sm4519852wrq.56.2023.09.15.07.17.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 07:17:02 -0700 (PDT) From: Loic Poulain To: rafael@kernel.org, pavel@ucw.cz Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Loic Poulain Subject: [PATCH] PM: hibernate: Request 0 CPU latency during image decompression Date: Fri, 15 Sep 2023 16:17:00 +0200 Message-Id: <20230915141700.91540-1-loic.poulain@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS 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]); Fri, 15 Sep 2023 07:17:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777134160746818016 X-GMAIL-MSGID: 1777134160746818016 The (SMP) load_image_lzo procedure relies on multiple threads and their synchronization for decompressing the hibernate image. for performance reasons, it is important to keep the CPUs responsive so that the synchronization overhead stays minimal. This overhead roughly corresponds to thread wakeup latency, which is linked to the CPU idle exit time. By requesting 0 CPU latency, we prevent CPUs to enter their deepest idle states, ensuring that they will be as responsive as possible during the whole decompression procedure, and by extension improve the hibernate resume time (CPU dependent). On iMX8M mini SoC, that gives a ~40% boost for the decompression time: PM: hibernation: Read 365640 kbytes in 1.88 seconds (194.48 MB/s) vs PM: hibernation: Read 363476 kbytes in 1.26 seconds (288.47 MB/s) Note: 40% diff sounds huge, and may point to iMX specific cpuidle issue. Anyhow, we know that during this bottleneck procedure, the CPUs will be fully dedicated to the decompress task, and must be kept ready for it. Signed-off-by: Loic Poulain --- kernel/power/swap.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/power/swap.c b/kernel/power/swap.c index f6ebcd00c410..d2cd53497c4e 100644 --- a/kernel/power/swap.c +++ b/kernel/power/swap.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -1180,6 +1181,7 @@ static int load_image_lzo(struct swap_map_handle *handle, unsigned char **page = NULL; struct dec_data *data = NULL; struct crc_data *crc = NULL; + struct pm_qos_request qos; hib_init_batch(&hb); @@ -1190,6 +1192,8 @@ static int load_image_lzo(struct swap_map_handle *handle, nr_threads = num_online_cpus() - 1; nr_threads = clamp_val(nr_threads, 1, LZO_THREADS); + cpu_latency_qos_add_request(&qos, 0); + page = vmalloc(array_size(LZO_MAX_RD_PAGES, sizeof(*page))); if (!page) { pr_err("Failed to allocate LZO page\n"); @@ -1470,6 +1474,8 @@ static int load_image_lzo(struct swap_map_handle *handle, } vfree(page); + cpu_latency_qos_remove_request(&qos); + return ret; }