Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp284719lqm; Tue, 30 Apr 2024 23:25:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVaZqGT+iW49/LKm1CLb5LNU1KrumtsGjP+id9a50tN7CV7/45XRXn4D2qY9KKCbfBxExKY1i0Y6j6get6BGbnjbpl5+vq1Oeq+1gxgKw== X-Google-Smtp-Source: AGHT+IEtud6sFjODBolHEOC7YrDD9GkYK5urMFvM/IQJIvy7GnWuVWjk33UZEMpAPVi4ERR33VQx X-Received: by 2002:a05:620a:394b:b0:790:7772:5c4 with SMTP id qs11-20020a05620a394b00b00790777205c4mr1532591qkn.60.1714544705510; Tue, 30 Apr 2024 23:25:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714544705; cv=pass; d=google.com; s=arc-20160816; b=WxaIour78McQZRRL1e8Hols0im3reENpwL9OTcT1RSFh28GHfNMYfw1hG8z6nSF6pp Gb/MTn3gKtJZqHJTrBC47AmyWzVDMHJPlUFdGwnBWiWX7+esi9AsiRFiCgalNIvaRRA0 tv+mOG0JL9vPjFBiAJ8HR6pax+JZxy1T+OkWFvwGyYs7wE6/IvLJwurm7Gge5Eul0FvE KpUgS4XW/NQKtPdMDzEDjra7BwUscq8q6p8yzceOVEK3BYB0eKyPigO5LpTGWvsnPa/2 yWKwBAJ7iTFGcXzw64NPe+TqS/WKWgcP95P2O4p0oEuMc98iTVkPXz0qDBkyNFniBXYv YzVg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=rlywhDM5dANIfY7Auj2TGF5Vh0fzpL/TBhTvUnaV50U=; fh=m0w7DKkmtWurdHnxuHZuwaT7APcQ09LxrkNdOsIX6ds=; b=o4eFeAQz2iGhpnRphPlnx9zLkFKlUEvxY4kxN9pmiYUb2eYTUEN/VrqnBLmhpNjZCY pKkv4SRcWV5dK3m0koDMnmzO1atzvNAD3f694mFnwne0btL32ull7KeUBryRY+qmS7BJ mUR6izsKav5somcDxqCZFtXUuluc7ifrZKsTe/mfQej0304p2uwgkQdjSTcr/TT7yDs5 AaK+yNWDkEXkGuDOf+mnoVWobABJqeBeMzBQvxGZHy85nPDoNvYEQpbQBvUKk+LwKFoE vGcaGHEdL6E2D6IBx6TpamG67Mo3rfzLmTDmm2UvuGkr2Yfy4q140OOO6H96E49B1DnJ CK5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ucw.cz header.s=gen1 header.b=k9Hg5Guy; arc=pass (i=1 spf=pass spfdomain=ucw.cz dkim=pass dkdomain=ucw.cz dmarc=pass fromdomain=ucw.cz); spf=pass (google.com: domain of linux-kernel+bounces-164966-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164966-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ucw.cz Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ye3-20020a05620a3b8300b0078d77462f41si28833890qkn.596.2024.04.30.23.25.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 23:25:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164966-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ucw.cz header.s=gen1 header.b=k9Hg5Guy; arc=pass (i=1 spf=pass spfdomain=ucw.cz dkim=pass dkdomain=ucw.cz dmarc=pass fromdomain=ucw.cz); spf=pass (google.com: domain of linux-kernel+bounces-164966-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164966-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ucw.cz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3477D1C22702 for ; Wed, 1 May 2024 06:25:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ACE994D11B; Wed, 1 May 2024 06:24:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ucw.cz header.i=@ucw.cz header.b="k9Hg5Guy" Received: from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AE294C3C3; Wed, 1 May 2024 06:24:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.255.230.98 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714544697; cv=none; b=Adyle3qIi2hXa5FErel7PWP6Q9InxfShvPFsxplrKSSfN9wwec4qq2MbhB7/Sbz8LLSAj4iTB+c8EEizzfCTRdor8vTryw/5NWdSGWDpZZ8gX7r0dfq4gwGlCPiI5M8ef3ed3FhugKoO0a+iFNnAjz7j/5Qirzv7stwnIRp74yY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714544697; c=relaxed/simple; bh=szuttc/QC/Sxc5UHd3+sAZAHunyukn12/WvWz5dIhy8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=j57aI8PqgHUeT46PRKdgog+petA7khQ3Q7Nrc7cOO5I/s/a7jtWwG0QbvBDT73Y4Irn0qx9XinTQDzaSsNSad1FTGyrphyM6IWPXd2CDDhPyeYAf3R6J7ROimf1IcilhAYWNeBE24RXTexIcHy54+Gu19p/nJMZzQsZbX/0obcc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ucw.cz; spf=pass smtp.mailfrom=ucw.cz; dkim=pass (1024-bit key) header.d=ucw.cz header.i=@ucw.cz header.b=k9Hg5Guy; arc=none smtp.client-ip=46.255.230.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ucw.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ucw.cz Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 9851D1C0084; Wed, 1 May 2024 08:24:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1714544686; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rlywhDM5dANIfY7Auj2TGF5Vh0fzpL/TBhTvUnaV50U=; b=k9Hg5Guy34fpmsO6WvenI+gAzfoIvNXi9PQ/sZjGEkKA7Bn6kFQxfWbSlU2ZiQprE0FWa5 bOZ+I9dbXivaC5w68EiypSk8FUNBQU2MvxGV9b8zWItZ+MHfwWfmOeKcLdArl6vmWAQQ8w BsOEggBeLbtFCKSJ1kG6VW/IcYVPNjA= Date: Wed, 1 May 2024 08:24:46 +0200 From: Pavel Machek To: Xueqin Luo Cc: rafael@kernel.org, len.brown@intel.com, linux-pm@vger.kernel.org, xiongxin@kylinos.cn, linux-kernel@vger.kernel.org Subject: Re: [PATCH -next] PM: hibernate: add retry mechanism for S4 image loading failures Message-ID: References: <20240501061258.2874092-1-luoxueqin@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240501061258.2874092-1-luoxueqin@kylinos.cn> > During the S4 resume process, there's a rare chance of image loading > failure. We provide three retries to load it successfully. If the > recovery fails after these attempts, print out the handle CRC32 > value. When the CRC32 value obtained on each retry are inconsistent, > there may be a memory anomaly. When the values are consistent, it > might indicate corrupted swapped memory data. > > Signed-off-by: Xueqin Luo NAK. If machine is so broken it can't load memory image, it is not safe to continue. Pavel > --- > kernel/power/hibernate.c | 8 ++++++++ > kernel/power/swap.c | 14 ++++++++------ > 2 files changed, 16 insertions(+), 6 deletions(-) > > diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c > index 43b1a82e800c..d9bcf38221ef 100644 > --- a/kernel/power/hibernate.c > +++ b/kernel/power/hibernate.c > @@ -703,6 +703,7 @@ static int load_image_and_restore(void) > { > int error; > unsigned int flags; > + int cnt = 0; > > pm_pr_dbg("Loading hibernation image.\n"); > > @@ -713,7 +714,14 @@ static int load_image_and_restore(void) > goto Unlock; > } > > +retry: > error = swsusp_read(&flags); > + if (error && (cnt++ < 3)) { > + pr_err("Failed to load hibernation image, trying to load again...\n"); > + swsusp_free(); > + goto retry; > + } > + > swsusp_close(); > if (!error) > error = hibernation_restore(flags & SF_PLATFORM_MODE); > diff --git a/kernel/power/swap.c b/kernel/power/swap.c > index 5bc04bfe2db1..4b866c645cd7 100644 > --- a/kernel/power/swap.c > +++ b/kernel/power/swap.c > @@ -1489,15 +1489,17 @@ static int load_compressed_image(struct swap_map_handle *handle, > ret = snapshot_write_finalize(snapshot); > if (!ret && !snapshot_image_loaded(snapshot)) > ret = -ENODATA; > - if (!ret) { > - if (swsusp_header->flags & SF_CRC32_MODE) { > - if(handle->crc32 != swsusp_header->crc32) { > - pr_err("Invalid image CRC32!\n"); > - ret = -ENODATA; > - } > + } > + if (!ret) { > + if (swsusp_header->flags & SF_CRC32_MODE) { > + if (handle->crc32 != swsusp_header->crc32) { > + pr_err("Invalid image CRC32, swsusp header CRC32: %u, handle CRC32: %u\n", > + swsusp_header->crc32, handle->crc32); > + ret = -ENODATA; > } > } > } > + > swsusp_show_speed(start, stop, nr_to_read, "Read"); > out_clean: > hib_finish_batch(&hb); > 2.25.1