From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0B60C4360C for ; Tue, 8 Oct 2019 20:11:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8A283206C0 for ; Tue, 8 Oct 2019 20:11:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AtOd3TWD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A283206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1B0708E0005; Tue, 8 Oct 2019 16:11:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 15F768E0003; Tue, 8 Oct 2019 16:11:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 04CB58E0005; Tue, 8 Oct 2019 16:11:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0244.hostedemail.com [216.40.44.244]) by kanga.kvack.org (Postfix) with ESMTP id D20DA8E0003 for ; Tue, 8 Oct 2019 16:11:06 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 7FDAC55F94 for ; Tue, 8 Oct 2019 20:11:06 +0000 (UTC) X-FDA: 76021711332.30.shirt17_43d0d52b4414f X-HE-Tag: shirt17_43d0d52b4414f X-Filterd-Recvd-Size: 5627 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Tue, 8 Oct 2019 20:11:05 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id p14so19933853wro.4 for ; Tue, 08 Oct 2019 13:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zRkRhcx1S5ZqWKlDmiJVwEoGZ+yDHNmQqx+oKN4Jgv8=; b=AtOd3TWDRf/o/4Bk21hI1q1YaTWWdaG3kfNytZ/qPPqQn0JmyK/rui2r0EuMm8vE2N Np/9eOnnhAfrOMxdeGVmpMNNUITk/jZ0GxMsHDhFh98bjdETUHvlBY2H2yWdhLUbI3W5 vOw1QD0teRf5YvXCnUOhW96QuhDy8himtKuUpNv4e8Cbmhg7SsZTzok5JiGonwy3xyCF F5Ed/T8RqitQMrGPS8M9hZq/uA/ExeBWPyxPR4ynWQ+mri6r3sRTW7Pq+bKlCVlSkT7+ AmUR5uR3NbMZ6Yc37l6ZxQyjo9BNg3wNZWoK0wGtnUY7GBdQj5t/AJWTt9Ft4SABFuL4 uzbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zRkRhcx1S5ZqWKlDmiJVwEoGZ+yDHNmQqx+oKN4Jgv8=; b=jWe7k/EwJjMMrDp/dvVIu/Cd8S+fKM56Lmu6Ey6smg3+8TwqH+nrsRHicltIbgU2T7 obIoga0BvpimrOKvT0XougoMqrDGqJ5W9RDAbWgUOW46B6UF6MJebrM9CRda4UTBXi6Q Zw+svgE9hFhv73LXW9ULfvnbKCLU26mc+kvl6fFoxD6WUTfimI2s8lu3lAmkLln1uisg psmtF6T/nxOP+4kTwywjBdqKXbtvGcicFjk++gl3q2MZMkD2jeG5ixel9HdIHYszl/YB 00sCO8LfiZjWyxB9eJQnXap1PLzGSzkQu5ZdagbIFcvCWR6LrlLd57i4YS2+8argqhxR bqfQ== X-Gm-Message-State: APjAAAW3gT6RvvYL5iZF2dDEo7SyT8RmWlPQvJAvV8T10Y4oqHWToXBi 6OQEaOLjord+feGtKWZO9MeFJjHFgsBdrq9bxeB8tA== X-Google-Smtp-Source: APXvYqwecQ8I1R5sloUUyTYf0HUKBV5L5CNFDnDEzLhwHMC1MDTm+0cieCjDImMOjidyvRvF2c1VqO+N08z5SbZTKEw= X-Received: by 2002:adf:f7ce:: with SMTP id a14mr15752442wrq.239.1570565464249; Tue, 08 Oct 2019 13:11:04 -0700 (PDT) MIME-Version: 1.0 References: <56319808-87dc-76ed-c1e0-9f60108e94a6@arm.com> In-Reply-To: From: Luigi Semenzato Date: Tue, 8 Oct 2019 13:10:52 -0700 Message-ID: Subject: Re: hibernation memory usage To: "Rafael J. Wysocki" Cc: James Morse , Linux Memory Management List , Bas Nowaira , Geoff Pike , Linux PM Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Actually, I think we only need to change the MM watermarks before hibernation and after resume. There's a patch that will do just that: https://lkml.org/lkml/2013/2/17/210 It didn't make it into mainline (which seems kind of unreasonable, since the watermarks themselves are based on heuristics) but shouldn't be difficult to apply. Or are there simpler solutions? On Tue, Oct 8, 2019 at 9:18 AM Luigi Semenzato wrote: > > Yes, that makes sense, thank you. Use separate partitions for swap > and hibernation. > > Normally the kernel starts swapping out when there's no reclaimable > memory, so anon usage will be high. Do you think cranking up > /proc/vm/swappiness would be enough to ensure that file pages stay > over 50%? Or would you use some tricks, such as running a > high-priority process which allocates >50% of RAM, thus forcing other > anon pages to be swapped out, then killing that process and quickly > hibernating before too many pages are brought back in? Or changing > the kernel so that in the first part of hibernation we'll just swap > stuff out? > > On Tue, Oct 8, 2019 at 8:39 AM Rafael J. Wysocki wrote: > > > > On Tue, Oct 8, 2019 at 5:26 PM Luigi Semenzato wrote: > > > > > > Thank you for your reply! > > > > > > I understand the need for saving all state, not just process/task > > > state. But for many of the systems that could benefit from > > > hibernation, the majority of RAM is taken by user processes (I am > > > thinking laptops). It should be possible to copy their anonymous > > > pages to disk more or less directly, without making an extra copy like > > > it's done for all other pages. I am not sure what happens with kernel > > > tasks, but they don't have anonymous pages (that I know). > > > > > > I am curious to know how/if hibernation is currently used in practice. > > > It doesn't seem practical to require that user processes take less > > > than 50% of RAM at all times. There may be special cases in which the > > > restriction can be achieved by terminating non-essential processes > > > before hibernating, but I don't know of any. > > > > > > I would also like to know how much work it might take to avoid the > > > extra copy of the anonymous pages of frozen processes. > > > > Whatever doesn't fit into 50% of RAM needs to be swapped out before > > hibernation. The efficiency of that depends on the swap handling code > > and the underlying hardware. If that is efficient enough overall, > > trying to avoid it altogether isn't going to make much of a > > difference.