Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp58924ybl; Tue, 7 Jan 2020 02:07:10 -0800 (PST) X-Google-Smtp-Source: APXvYqwfpt0rFrwMGR1dEU36pY0BlwvU41G7A2Oogu19n665Pm9VpIgvFAdHfcLQmeYn3CmS3NPd X-Received: by 2002:aca:c509:: with SMTP id v9mr6420209oif.151.1578391630067; Tue, 07 Jan 2020 02:07:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578391630; cv=none; d=google.com; s=arc-20160816; b=oalJws6y7PA6B/1IscnHbMnlRrwt7XVeqjYUIwmynhAZ8at7lSWBCVsSpy6qWAI9iT BB0D2nnfnmVmOFtpnqI9yhhOiVyIoNqfIgMaeHMR4KPQe5bPjA1dMWpbUAgVOfA2mJmi DndxNMdnAhUH/HRzHc1I28Qs3vRM21qDVbiL0Iwjk2eMwduv88ngAC7a7s7uGrzLxPeD aQmfV/sspnXWhomYGdWs8WN6C0WteSD4/grISGG4f58VkxWLJqLG7GFh05gguM4A+xvb 8ZX1+g3mU20Jao4GdKjoJYRFUeV3v2CUE1QPXD6wF4QupkZD56b+jyIQfl7UJ7GWnnJ8 pOKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=P9OKbMZWRAmiTF6ODcRzRiBwtRnKeMsOcJnKTjB3BHc=; b=gHgAKpXSn17agMVyXn8q+OZVb3RFVAmA2zi7Ri3IMpq4yDAptQnA7QqDCQZseQSuUL eK3n2A6sQAUOj9RQByryCX5TDB/b43KEzyf43gEC28KG098ba15lbv76v9lNf/3gW2xO KH34tJlEOvialf8U6hqVQOUVPx0XXf1k5PDHZIidsYmjUCkVxRzTo+AnMmkKwTYcPTIe 7356CqpADIlnE5JK+eiPTDikgg73cfRWVIVyEEY8gfa1Ruj6e2hrqZjdwCIQoa8NdaP6 jAoIyGkiPs69XmiBNG2V8T7yrxXRYY6SAqc4IsuBRaKsZTd4XcrPFS+djozFvrTffAGy hMzA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b4si2559906oiy.97.2020.01.07.02.06.57; Tue, 07 Jan 2020 02:07:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727745AbgAGKEz (ORCPT + 99 others); Tue, 7 Jan 2020 05:04:55 -0500 Received: from mail-oi1-f194.google.com ([209.85.167.194]:46090 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbgAGKEz (ORCPT ); Tue, 7 Jan 2020 05:04:55 -0500 Received: by mail-oi1-f194.google.com with SMTP id p67so17371392oib.13 for ; Tue, 07 Jan 2020 02:04:55 -0800 (PST) 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=P9OKbMZWRAmiTF6ODcRzRiBwtRnKeMsOcJnKTjB3BHc=; b=gEPVAHVzzdOqXWzI19Y4TsUWCZsMvxsR2IzR939Zy6E2fpHd477Fk3K1tDzn84VqRF 3zcZWrnvgSW+hT7ZJZgw7IH/hQxTbL05M5nlsGw4nSDwsxvGLMqoSGG1YHyw9TaDYaDL N5U2MNeng7CDjfLPekF/FTKjAvwfJhHh7RrIXMfKRN/jmwH4FHlWipFSNvv91cWZeZhv NNZD5Mvhswq6/g16xOVDcbkWCfjXAYL95CIxvzUMgAMY9d03ZL7JmWy+wNF2OLAbu10T rkZuqEE5djp+cyAbKVTyp1Gvx7FBjmuGAjhlspVSL5OdNjSVP6zOkqT/sxTWoJZOa1Mu j7Mw== X-Gm-Message-State: APjAAAXE3rujs5fOJudbOHSYTnGnIINkxBrFF9G2SU2WGl6H+hJaYYOo ZbkivWBh9kUkjk4IcrhNdQ3R58GsuEmTMotlwEI= X-Received: by 2002:aca:cd92:: with SMTP id d140mr6575824oig.68.1578391494788; Tue, 07 Jan 2020 02:04:54 -0800 (PST) MIME-Version: 1.0 References: <20191226220205.128664-1-semenzato@google.com> <20191226220205.128664-2-semenzato@google.com> <20200106125352.GB9198@dhcp22.suse.cz> In-Reply-To: <20200106125352.GB9198@dhcp22.suse.cz> From: "Rafael J. Wysocki" Date: Tue, 7 Jan 2020 11:04:43 +0100 Message-ID: Subject: Re: [PATCH 1/2] Documentation: clarify limitations of hibernation To: Michal Hocko Cc: Luigi Semenzato , Linux Memory Management List , Linux Kernel Mailing List , "Rafael J. Wysocki" , Andrew Morton , Geoff Pike Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 6, 2020 at 1:53 PM Michal Hocko wrote: > > On Thu 26-12-19 14:02:04, Luigi Semenzato wrote: > [...] > > +Limitations of Hibernation > > +========================== > > + > > +When entering hibernation, the kernel tries to allocate a chunk of memory large > > +enough to contain a copy of all pages in use, to use it for the system > > +snapshot. If the allocation fails, the system cannot hibernate and the > > +operation fails with ENOMEM. This will happen, for instance, when the total > > +amount of anonymous pages (process data) exceeds 1/2 of total RAM. > > + > > +One possible workaround (besides terminating enough processes) is to force > > +excess anonymous pages out to swap before hibernating. This can be achieved > > +with memcgroups, by lowering memory usage limits with ``echo > > > +/dev/cgroup/memory//memory.mem.usage_in_bytes``. However, the latter > > +operation is not guaranteed to succeed. > > I am not familiar with the hibernation process much. But what prevents > those allocations to reclaim memory and push out the anonymous memory to > the swap on demand during the hibernation's allocations? Nothing in particular AFAICS, at least in theory. The approach taken by the hibernation code is rather straightforward: allocate enough memory to store a copy of every page (in RAM) that needs to be saved. These allocations are made one page at a time, so in theory they should not fail as long as there is enough swap space in the system, but I'm probably missing something here.