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 E5A78C11D13 for ; Thu, 20 Feb 2020 17:38:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 908A820637 for ; Thu, 20 Feb 2020 17:38:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="I120KkGB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 908A820637 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 DA8E26B000E; Thu, 20 Feb 2020 12:38:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D5A676B0010; Thu, 20 Feb 2020 12:38:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C97256B0032; Thu, 20 Feb 2020 12:38:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0003.hostedemail.com [216.40.44.3]) by kanga.kvack.org (Postfix) with ESMTP id AE7E66B000E for ; Thu, 20 Feb 2020 12:38:19 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 574C6181AC9CB for ; Thu, 20 Feb 2020 17:38:19 +0000 (UTC) X-FDA: 76511214318.08.price25_2b829cf784a27 X-HE-Tag: price25_2b829cf784a27 X-Filterd-Recvd-Size: 5295 Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Thu, 20 Feb 2020 17:38:18 +0000 (UTC) Received: by mail-il1-f182.google.com with SMTP id t17so24316619ilm.13 for ; Thu, 20 Feb 2020 09:38:18 -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=09KCaYoy2RCgOUWekQOBry08/RITy2C45iW7MfQatT0=; b=I120KkGBiZ/RnK1THwXaeDT/JwAsQz0AIndg8NiS8d1xkUgrjB8/KEskX6jfopYmL8 EtwTudOm66nfrNRPnVbHk4ioCh4Kz1zOjr4bPgtCquuLwSbJbDMALj3S8QI+TI3ZOTIl ffTQHgyaNLNogW20tOd5PIE0CloOyiPhzgtFV6OAm1ALHW2ct0bCYkxnhdDXhzoQsx+P X2lkiBMsomNljqyKtVQ/0spX58OMAbY7dJD+vYaQrKPwHQE56ZxvExS3XFsOHyUYpWIO gcExV8MHU8jcthyXTuAOAgf68uEOGDTh8vc/ANT8WHP48jE2H+efj/KGxkFzGh+3qemd vtdw== 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=09KCaYoy2RCgOUWekQOBry08/RITy2C45iW7MfQatT0=; b=P8BeXztOD0/hCUQhbn1ZChZDjLt0wIIXNRV2Eb41T9N6wOVpcbOJkirwKwZh52M7DC 7SHBOw2CybIUMkUyY48dfQt8xDmQTGC7UDWRrQN3JGZ9hAE+gh8U+nA2fYshABm1UGYs ymda4a3pOIjXIBCdsKHbL34vgKAU59B7Em1BGUHy01AbEtYKKyfjfNshMzbemdJLLC7b xzKMaSc8BEXv33sD5ce0GhahnBxI4gAwnhjFSiwDGw7yGM0WtActBBuOkF8gCwft8xEs xA2AtRA8yrmF9xjxEXdbZuCPSzQpgamTOSVl6mJSMVv/paiWmnzGju1+KtvIPfHvfE2l Q9pQ== X-Gm-Message-State: APjAAAWeGD2/A0bd5pZ9i4NIqVd7B+pAUHmw1Jb+7UetSHy0OHJJneA/ 6azYtWFppC2rdWyNq7EJhKVt2V4gPcc3V+ySPUgJ5/Ia X-Google-Smtp-Source: APXvYqyHbZdoZSA+TXdjzBr5fSRBLQykpIqX5ldMA8W56fN3JwAFX3qnaNIdgJRnxnmHxMgY7pIpCuwYhtyoMpIzBJk= X-Received: by 2002:a92:8dda:: with SMTP id w87mr30192090ill.55.1582220297799; Thu, 20 Feb 2020 09:38:17 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Luigi Semenzato Date: Thu, 20 Feb 2020 09:38:06 -0800 Message-ID: Subject: Re: is hibernation usable? To: Chris Murphy Cc: 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: I was forgetting: forcing swap by eating up memory is dangerous because it can lead to unexpected OOM kills, 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. On Thu, Feb 20, 2020 at 9:16 AM Luigi Semenzato wrote: > > I think this is the right group for the memory issues. > > I suspect that the problem with failed allocations (ENOMEM) boils down > to the unreliability of the page allocator. In my experience, under > pressure (i.e. pages must be swapped out to be reclaimed) allocations > can fail even when in theory they should succeed. (I wish I were > wrong and that someone would convincingly correct me.) > > I have a workaround in which I use memcgroups to free pages before > starting hibernation. The cgroup request "echo $limit > > .../memory.limit_in_bytes" blocks until memory usage in the chosen > cgroup is below $limit. However, I have seen this request fail even > when there is extra available swap space. > > The callback for the operation is mem_cgroup_resize_limit() (BTW I am > looking at kernel version 4.3.5) and that code has a loop where > try_to_free_pages() is called up to retry_count, which is at least 5. > Why 5? One suspects that the writer of that code must have also > realized that the page freeing request is unreliable and it's worth > trying multiple times. > > So you could try something similar. I don't know if there are > interfaces to try_to_free_pages() other than those in cgroups. If > not, and you aren't using cgroups, one way might be to start several > memory-eating processes (such as "dd if=/dev/zero bs=1G count=1 | > sleep infinity") and monitor allocation, then when they use more than > 50% of RAM kill them and immediately hibernate before the freed pages > are reused. If you can build your custom kernel, maybe it's worth > adding a sysfs entry to invoke try_to_free_pages(). You could also > change the hibernation code to do that, but having the user-level hook > may be more flexible. > > > On Wed, Feb 19, 2020 at 6:56 PM Chris Murphy wrote: > > > > Also, is this the correct list for hibernation/swap discussion? Or linux-pm@? > > > > Thanks, > > > > Chris Murphy