From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id GP0xCZxTrF7kQwAA0tVLHw (envelope-from ) for ; Fri, 01 May 2020 16:51:40 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id +BrwEKVTrF5JQQAA1q6Kng (envelope-from ) for ; Fri, 01 May 2020 16:51:49 +0000 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:470:142::17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C486A941DEC for ; Fri, 1 May 2020 16:51:47 +0000 (UTC) Received: from localhost ([::1]:55252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jUYt9-000697-Ko for larch@yhetil.org; Fri, 01 May 2020 12:51:47 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jUYsu-0005L3-9J for guix-patches@gnu.org; Fri, 01 May 2020 12:51:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jUYru-0004HT-MO for guix-patches@gnu.org; Fri, 01 May 2020 12:51:32 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38979) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jUYdu-00066o-0A for guix-patches@gnu.org; Fri, 01 May 2020 12:36:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jUYdt-0006OM-Tx for guix-patches@gnu.org; Fri, 01 May 2020 12:36:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#40927] [PATCH] Allow resume from swap device during boot Resent-From: Tobias Geerinckx-Rice Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 01 May 2020 16:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40927 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 40927@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Cc: 40927@debbugs.gnu.org Received: via spool by 40927-submit@debbugs.gnu.org id=B40927.158835093624536 (code B ref 40927); Fri, 01 May 2020 16:36:01 +0000 Received: (at 40927) by debbugs.gnu.org; 1 May 2020 16:35:36 +0000 Received: from localhost ([127.0.0.1]:50525 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jUYdF-0006NN-0W for submit@debbugs.gnu.org; Fri, 01 May 2020 12:35:36 -0400 Received: from tobias.gr ([80.241.217.52]:35332) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jUYdD-0006NC-3Q for 40927@debbugs.gnu.org; Fri, 01 May 2020 12:35:19 -0400 Received: by tobias.gr (OpenSMTPD) with ESMTP id 49131a35; Fri, 1 May 2020 16:35:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=tobias.gr; h=from:to:cc :subject:references:in-reply-to:date:message-id:mime-version :content-type; s=2018; i=me@tobias.gr; bh=Dg16dHMq7hxz9cPZtd4pXO eevmmBwIFJiAsWH28V2QA=; b=jK3JcdJNLSxtt/B5LXDTPssTVIaJ9btLxOWvSL vtuXzBH6SBRa0L6MbqlgIco23ql1HWLH/MYWaRt5gCRb0ehgLx/+sA19U08PGyo2 NokHMhyiOzfOnET81sXC/iAtm3MJEEucwKR45UbKO9jlWL65sjeADAsey4j42Tfj XcGud2wSPemfBcGFqY/snPas4PLDCgDodoAupGRJU1o80O7haJ35IPuNjoFgt+I7 iUZEs0HyDXHr+uWncu5VojAkRRBdun99EKlaeLbJgieFoNEKxk29yI0XBZyKYZwR xTLLahIzXpnhpLCUgq83YUk++6UzZ4gA5wgxPoVFyxvDnDRg== Received: by submission.tobias.gr (OpenSMTPD) with ESMTPSA id 79ef74f2 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Fri, 1 May 2020 16:35:16 +0000 (UTC) References: <87zhawax60.fsf@m4x.org> In-reply-to: <87zhawax60.fsf@m4x.org> Date: Fri, 01 May 2020 18:35:28 +0200 Message-ID: <87o8r7ehpr.fsf@nckx> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" Reply-to: Tobias Geerinckx-Rice , Tobias Geerinckx-Rice via Guix-patches From: Tobias Geerinckx-Rice via Guix-patches via X-Scanner: scn0 X-Spam-Score: -0.11 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=tobias.gr header.s=2018 header.b=jK3JcdJN; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 2001:470:142::17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Scan-Result: default: False [-0.11 / 13.00]; HAS_REPLYTO(0.00)[me@tobias.gr]; GENERIC_REPUTATION(0.00)[-0.49539485600973]; MX_INVALID(1.00)[cached]; DWL_DNSWL_FAIL(0.00)[2001:470:142::17:server fail]; R_SPF_ALLOW(-0.20)[+ip6:2001:470:142::/48:c]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.16), country: US(-0.00), ip: 2001:470:142::17(-0.50)]; TO_DN_NONE(0.00)[]; R_DKIM_REJECT(1.00)[tobias.gr:s=2018]; DKIM_TRACE(0.00)[tobias.gr:-]; MAILLIST(-0.20)[mailman]; SIGNED_PGP(-2.00)[]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:22989, ipnet:2001:470:142::/48, country:US]; TAGGED_FROM(0.00)[larch=yhetil.org]; FROM_NEQ_ENVFROM(0.00)[guix-patches@gnu.org,guix-patches-bounces@gnu.org]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; REPLYTO_DOM_NEQ_FROM_DOM(0.00)[]; DMARC_NA(0.00)[gnu.org]; HAS_LIST_UNSUB(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; DNSWL_BLOCKED(0.00)[2001:470:142::17:from]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_COUNT_SEVEN(0.00)[8]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: 7G+BZmjMtd5I --=-=-= Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Jean-Baptiste, Jean-Baptiste Note =E5=86=99=E9=81=93=EF=BC=9A > This is a very important feature for people like me using GUIX=20 > SD on a > laptop (yes, it is possible, mine is a corebooted X230 running > linux-libre!) Greetings, brother in hardware. Note that hibernation and resumption already work fine if you rely=20 on the kernel's built-in support. I've been hibernating my X230T=20 for years without patches. This explicit initramfs support is only needed if your storage=20 drivers aren't available when the kernel itself tries to resume,=20 and the initramfs has to retry later. That's slower but allows=20 things like ahci to be modular instead of built-in. > This patch is based on a patch floating around. The core=20 > functionality > has been isolated, the resume function isolated, the patch=20 > rebased and > tested. I'm not taking credit for it, even though tracing the=20 > exact > origin is hard. Heh. It's certainly very similar to a patch of mine that's =E2=80=98out=20 there=E2=80=99 although it's probably not the only one. > The resume hook is called if the resume=3D kernel argument is=20 > provided, > which one can do during system configuration. This patch ignores the =E2=80=98noresume=E2=80=99 flag, which is bad. If i= t's=20 present anywhere on the command line resumption should be skipped: + (when (and (not (member "noresume" args)) + resume-device + (file-exists? resume-device) + (file-exists? "/sys/power/resume")) + (resume-from-device resume-device)) > My scheme level is zero, so please bear with me. In particular,=20 > some > conditionals could maybe be moved within the function, I'd like to see everything moved into a self-contained DTRT=20 [try-to-]resume procedure, except for the =E2=80=98noresume=E2=80=99 check = (so=20 callers are free to explicitly resume if they so please): + (unless (member "noresume" args) + (resume-if-hibernated (find-long-option "resume"=20 args))) This is what the last iteration of my patch does. If (find-long-option "resume" args) is #f, fall back to=20 CONFIG_PM_STD_PARTITION. This is what the kernel does: even if=20 =E2=80=98resume=3D=E2=80=99 is missing, it will try to resume from that dev= ice if=20 specified. We should match that behaviour if we can. Problem is, I forgot how to get that value from user space, or if=20 it's even possible. I gave up on Linux's built-in hibernation=20 (swsusp) years ago. It's poorly written and maintained, and the=20 author fiercely defends it from all improvement. Instead I use TuxOnIce, which exposes it under=20 /sys/power/tuxonice/=E2=80=A6. That's obviously not an option here,=20 although it would be friendly to fall back to it for us ToI users=20 :-) *user. I think ToI even exposes the =E2=80=98last used hibernation device=E2=80=99= =20 somewhere, so user space can just use that instead of=20 CONFIG_PM_STD_PARTITION. This is obviously the right thing to do.=20 Again, not sure if swsusp does. > or the function itself called within some already-available=20 > hooks. We don't have a concept of =E2=80=98initramfs hooks=E2=80=99 and I think th= at's a=20 good thing. Gives me dracut flashbacks. Don't lets bother with=20 them until we need them, which is never. > Also it is not clear if the commit log is adequate for such a=20 > change. It's all right :-) If anything, it's too long: linux-boot: Add support for resuming from swap device. * gnu/build/linux-boot.scm (resume-from-device): New procedure. * gnu/build/linux-boot.scm (boot-system): Call it, unless=20 =E2=80=98noresume=E2=80=99 is present on the kernel command line. > Please let me know how to improve this and get this merged; I=20 > can also > write some documentation (probably once the mechanism is in=20 > place) to > explain how the feature can be used. If this works properly no documentation is needed. The kernel by=20 default writes to the first swap device; we should magically=20 resume from it. Forcing users to know (or care) about part 2 is=20 asymmetrical and wrong. Not sure if that's possible with vanilla Linux-Libre=E2=80=A6 Will stop shilling ToI for now, T G-R --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQT12iAyS4c9C3o4dnINsP+IT1VteQUCXqxP0AAKCRANsP+IT1Vt eXVJAP96WL9Wax3vlM72BnZTz9xN4HEz+gKGzzYM7+krnn3aDgD/R7XEZA7wmsAJ wttBqY9Eev3URVpL+tcvziEfAH1bIQI= =AkBZ -----END PGP SIGNATURE----- --=-=-=--