Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3087362rwl; Mon, 27 Mar 2023 09:04:25 -0700 (PDT) X-Google-Smtp-Source: AK7set/KAmbNkZq1+7E47s3NgqdT2Bc9Mo+DZWdx8BlyPXHyBYoXtpOeBM6yHro2u4WIxCNycZu4 X-Received: by 2002:a05:6a20:4d96:b0:dd:e6f5:a798 with SMTP id gj22-20020a056a204d9600b000dde6f5a798mr11953804pzb.6.1679933065263; Mon, 27 Mar 2023 09:04:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679933065; cv=none; d=google.com; s=arc-20160816; b=pNginswOR3W6CEHbhbiosxjvjkCft8mNngf9qV/tKTIXRnsuCMplBTmd0CT5TKyPPC 3PXQm8xwwo/8BQ9JaXkYuN+mcuglyHyeaJW/PSV9vBNljEyDqogA9HA54IWRH6bl0RkJ 3nrlf7dyYZGhXsISVyoTbn/9fN23+pFeEN8brJ3ZgRBu9iK0Dt2Z1ZmxAHycLLNfo5Am JHPnvmN4u15v1tKgXIlRighyG4lic3e+Ef6ndVB+uX+2PEaoAr7iUxZZ3QpgLI5BDmH5 J0XF+KfAVX8IunMpLf5FTXjsqLb0d0rtIJevphqp/wnwEG2OpxqWPvnTIUWHPX+klFxe BTsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=5CR1Sll8eAmJOYGhHNJX6eHhHK4J1HG0cP5cGUjsxt4=; b=EcZyABkFCu/4vtuI0xB1lor/fEZOlxEsP7u6cGz/9S+z4680hVd2SG/CLgnO+64O84 lQKTZ/X1hCVP2ZvqMthc/4OSeaG3BKTMbGD23muaum7qRYlSPEZSKL0iIi8K0DNMKdKi flqEWhfrti/YG7Ek5fBBzwZFO+TPfeZhnnx+hUyddLcBUrfF4FKH0u8CoG4r1E5silU/ Cf9TaOTY8WFcf2hmg46rYvoiPMIvXuJrGbcp/uAuabiWljEGHLiDblg2znQi13s8LGVF Qnolua3dc/4P2Oth/2C5UMwhNa0Dtzvw/VgVUIPIo2TlpRjRtXv1jv7EigiDT4rZLAd/ 4wNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f3-20020a056a0022c300b00627f807ef24si21602414pfj.31.2023.03.27.09.04.05; Mon, 27 Mar 2023 09:04:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232949AbjC0QCe convert rfc822-to-8bit (ORCPT + 99 others); Mon, 27 Mar 2023 12:02:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232546AbjC0QCG (ORCPT ); Mon, 27 Mar 2023 12:02:06 -0400 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 976135FDC; Mon, 27 Mar 2023 09:01:37 -0700 (PDT) Received: by mail-ed1-f51.google.com with SMTP id i5so38460567eda.0; Mon, 27 Mar 2023 09:01:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679932896; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7Tc92jHKfzCM4jUDYAxaTKlNKg/5FTvfvoaAMWmN/OQ=; b=mb525LNVTuNpuaGSn7Xf1LNE/4/6BXVqvA5ibcQbKG2seFxUD/+ds2nzcVTi4k7AB8 fGxMZ0xEm5NKf4onIaxNLdKywTDOk9yKKhVO9scNLGzEMRMETtH9YIL9BrNN42yON87e S/7VKcMvN4xxv0WEwpxVCWJGML8mlAqmTtSoOcO8ZWtwwUlFHyVgFK5TomvqdT0P6FBA CLQCjsT3XyLh70O0AuBjqcaqDc4i57lw4Z+22ZbGSKCua7Zr42nxOfgkquQYBiFKw3xh nKNV/Xq5cm5m6Vd37cqYM3zMESa7N+UMbD7peaQglwJMeIzP/CSXRlCVkWrEilDrWjPO wvLw== X-Gm-Message-State: AAQBX9eJlLzl6xFDWSZ5w1rBKhBpDjEZFP2JC2+VcAsKtS7M8mXgpxIF GP7L65q8WeKeIGXpq3Oyl2ovPFcrJcKD+PDgbsQ= X-Received: by 2002:a17:907:d02:b0:931:6921:bdbb with SMTP id gn2-20020a1709070d0200b009316921bdbbmr5766122ejc.2.1679932895870; Mon, 27 Mar 2023 09:01:35 -0700 (PDT) MIME-Version: 1.0 References: <20230303055133.28752-1-luoxueqin@kylinos.cn> In-Reply-To: <20230303055133.28752-1-luoxueqin@kylinos.cn> From: "Rafael J. Wysocki" Date: Mon, 27 Mar 2023 18:01:24 +0200 Message-ID: Subject: Re: [PATCH v2] PM/hibernation: set the default image size for large memory To: Xueqin Luo Cc: rafael@kernel.org, len.brown@intel.com, pavel@ucw.cz, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, xiongxin@kylinos.cn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=0.5 required=5.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no 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 On Fri, Mar 3, 2023 at 6:51 AM Xueqin Luo wrote: > > From: xueqin Luo > > As computers have more and more memory, they can store larger and > larger images. This poses a problem. Let's take a 16GB computer as > an example. When the number of pre-allocated pages is greater than > 900,000 and smaller than image_size, the duration of S4 increases > with the number of saved pages. When the number of pre-allocated > pages reaches 1.2 million, the duration of S4 increases by 8-10s. Well, I'm not quite sure what the problem is from the description above. Can you please explain? > We found that the image size is generally more than 900,000 pages, > so we set the default size of image_size for 16GB and above > computers to 1 million pages, which can reduce the running time > of S4 under certain conditions. > > This is the test data for 5 hours after the computer is turned on: > > Original kernel begin: > > [2023-02-24 19:16:56] [ 46.105423][ 2] [ T3075] PM: hibernation entry > [2023-02-24 19:16:59] [ 47.632000][ 1] [ T3075] done (allocated > 959239 pages) > [2023-02-24 19:18:05] [ 56.987043][ 2] [ T3075] PM: hibernation exit > > Five hours later: > > [2023-02-25 00:22:48] [18069.651640][ 4] [ T7590] PM: hibernation entry > [2023-02-25 01:23:59] [21671.194049][ 0] [ T8563] done (allocated > 1228878 pages) > [2023-02-25 00:24:06] [18080.639889][ 2] [ T7590] PM: hibernation exit > > After 5h, you can see that the S4 takes 8s more time. > > Five hours later, the modified kernel test data: > > [2023-02-24 15:52:08] [18190.171183][ 7] [T11151] PM: hibernation entry > [2023-02-24 15:52:11] [18191.677021][ 7] [T11151] done (allocated > 792597 pages) > [2023-02-24 15:53:15] [18201.028488][ 2] [T11151] PM: hibernation exit > > You can see that after five hours, the time has changed little compared > to the initial test data. > > Signed-off-by: xueqin Luo > --- > > v3: modify some comments > > v2: add test data > > kernel/power/snapshot.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c > index cd8b7b35f1e8..fa3950b19849 100644 > --- a/kernel/power/snapshot.c > +++ b/kernel/power/snapshot.c > @@ -136,7 +136,14 @@ unsigned long image_size; > > void __init hibernate_image_size_init(void) > { > - image_size = ((totalram_pages() * 2) / 5) * PAGE_SIZE; > + /* The totalram pages() for a computer of 16 memory size is > + * equal to 4032990 pages. And according to our observation, > + * the average image size is less than 1 million pages. > + */ > + if (totalram_pages() < 4032990) > + image_size = ((totalram_pages() * 2) / 5) * PAGE_SIZE; > + else > + image_size = 1000000 * PAGE_SIZE; > } > > /* > -- > 2.25.1 >