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,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 27F15C35658 for ; Fri, 21 Feb 2020 17:13:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D2B1420722 for ; Fri, 21 Feb 2020 17:13:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qh8dozjs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2B1420722 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 7D7956B0008; Fri, 21 Feb 2020 12:13:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 75C666B000A; Fri, 21 Feb 2020 12:13:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 64C3B6B000C; Fri, 21 Feb 2020 12:13:24 -0500 (EST) 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 482446B0008 for ; Fri, 21 Feb 2020 12:13:24 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 0E3E72460 for ; Fri, 21 Feb 2020 17:13:24 +0000 (UTC) X-FDA: 76514780328.08.cast69_1da16a43bc011 X-HE-Tag: cast69_1da16a43bc011 X-Filterd-Recvd-Size: 6352 Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Fri, 21 Feb 2020 17:13:23 +0000 (UTC) Received: by mail-il1-f172.google.com with SMTP id p78so2200414ilb.10 for ; Fri, 21 Feb 2020 09:13:23 -0800 (PST) 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=bR4lHzdd7hFGSOfT6wjCLMaQmFgxgzcu/EhXcaZsebQ=; b=qh8dozjsctmQVD6+hAItWi6rwODWcT0x8935378dY0i+7F68q4f1Z+nhwqWQzXUjon 0+mt4fMd+pKGWyPF70eeJ4So0QIP0Dz9/sFJTLb09DtfyKeu+iq5smh08/pok2huvcUe Q4xkAeoNxwgjAH1amjvB/69GUAuET15/YzX4DFYC3X4Nr+5ZfeBmia3Uz7tQaHoPjze3 +PP20TlRmnZOr0VgrzghowxkW3e2P/nSmj0F8si25Wx/MEMvpUPuOuBOBUn6N5UX+a2v ZGFXedWfKMeBXCHw9Dy3+7ujpOsJ2H8F8Gli2G3rfBxVbDhFPlLw4fwo0XkdCWCtPpBC AZiQ== 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=bR4lHzdd7hFGSOfT6wjCLMaQmFgxgzcu/EhXcaZsebQ=; b=ff/VKZ6xfcQlsG8TEyh5pfbpnfkF8JWf9x/ObkQn7V2IbPMKhUuu7eKw5vwZDS/9zv IJdMBG43qEnc8FeBlPuiCE+bb8iau40xwGgI/ipJSbbmqygOfrge5qww3XbSYcQyHzut PutCkCKJFa/3SsC1rI5eSzvah9Esg1f9lmmA5L/pP0TAinChkQ6KBLLEoeQe2GCoPgcD qGiBUdHdvIoWuODjGluslY34r3GPkjr1dm72OfnyMUNSJU518b+yw9+zb/L7H0jeYL5R eObucJnhunHLgRJKCWlJkz4CY81p4jB5F8HgIvaATJ3Vf9qjL8ZwuIZWq/tmglR+ecyJ +naA== X-Gm-Message-State: APjAAAVbloCnFlruqjafdkBtVwa2OiZr1MjytSAAeH9Zu6pl0EL3bnx4 /aD03RCCm3gDyDuHmYN11FdAOgUgT+yQe3Yo8eSevw== X-Google-Smtp-Source: APXvYqztHZabXw7bx19dBMXUx8qWPmbjO8MeCOuuKPbKnHXSxH2rxcNkSfUoHY2wGoFbYsm+2JCRKB+YNw5gBeOb86w= X-Received: by 2002:a92:884e:: with SMTP id h75mr37619356ild.199.1582305202309; Fri, 21 Feb 2020 09:13:22 -0800 (PST) MIME-Version: 1.0 References: <20200221084910.GM20509@dhcp22.suse.cz> <20200221093635.GN20509@dhcp22.suse.cz> In-Reply-To: <20200221093635.GN20509@dhcp22.suse.cz> From: Luigi Semenzato Date: Fri, 21 Feb 2020 09:13:10 -0800 Message-ID: Subject: Re: is hibernation usable? To: Michal Hocko Cc: "Rafael J. Wysocki" , Chris Murphy , Linux Memory Management List , 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: On Fri, Feb 21, 2020 at 1:36 AM Michal Hocko wrote: > > On Fri 21-02-20 10:04:18, Rafael J. Wysocki wrote: > > On Fri, Feb 21, 2020 at 9:49 AM Michal Hocko wrote: > > > > > > On Thu 20-02-20 09:38:06, Luigi Semenzato wrote: > > > > I was forgetting: forcing swap by eating up memory is dangerous > > > > because it can lead to unexpected OOM kills > > > > > > Could you be more specific what you have in mind? swapoff causing the > > > OOM killer? No, not swapoff, just fast allocation. Also, in some earlier experiments I tried gradually increasing min_free_kbytes (precisely as suggested) and this would randomly trigger OOM kills when swap space was still available. > > > > , but you can mitigate that > > > > by giving the memory-eaters a higher OOM kill score. Still, some way > > > > of calling try_to_free_pages() directly from user-level would be > > > > preferable. I wonder if such API has been discussed. > > > > > > No, there is no API to trigger the global memory reclaim. You could > > > start the reclaim by increasing min_free_kbytes but I wouldn't really > > > recommend that unless you know exactly what you are doing and also I > > > fail to see the point. If s2disk fails due to insufficient swap space > > > then how can a pro-active reclaim help in the first place? > > > > My understanding of the problem is that the size of swap is > > (theoretically) sufficient, but it is not used as expected during the > > preallocation of image memory. > > > > It was stated in one of the previous messages (not in this thread, > > cannot find it now) that swap (of the same size as RAM) was activated > > (swapon) right before hibernation, so theoretically that should be > > sufficient AFAICS. Correct, those were my experiments. Search the archives for "semenzato", there are a couple of threads on the topic. But really, why not have a user-level interface for reclaim? I find it very difficult to understand the behavior of the reclaim code, and any attempt to reclaim from user level (memory-eating processes, raising min_free_kbytes) can end in the OOM-kill path. Using cgroups' memory.limit_in_bytes doesn't have this problem, precisely because it only calls try_to_free_pages(), which doesn't trigger OOM killing. If I could make that call from user level (without cgroups) it would greatly simplify my current workaround, and would be useful in other situations as well. Something like echo $page_count > /proc/sys/vm/try_to_free_pages cat /proc/sys/vm/pages_freed # the number of pages freed at the latest request > Hmm, this is interesting. Let me have a closer look... > > pm_restrict_gfp_mask which would completely rule out any IO > happens after hibernate_preallocate_memory is done and my limited > understanding tells me that this is where all the reclaim happens > (via shrink_all_memory). It is quite possible that the MM decides to > not swap in that path - depending on the memory usage - and miss it's > target. More details would be needed. E.g. vmscan tracepoints could tell > us more. > > -- > Michal Hocko > SUSE Labs