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=-6.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 B4D96C07E9C for ; Mon, 12 Jul 2021 21:32:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6B8B5611CD for ; Mon, 12 Jul 2021 21:32:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B8B5611CD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 62F206B0095; Mon, 12 Jul 2021 17:32:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B7FF6B0096; Mon, 12 Jul 2021 17:32:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 40A826B0098; Mon, 12 Jul 2021 17:32:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0098.hostedemail.com [216.40.44.98]) by kanga.kvack.org (Postfix) with ESMTP id 143D26B0095 for ; Mon, 12 Jul 2021 17:32:45 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 17FD71850A724 for ; Mon, 12 Jul 2021 21:32:44 +0000 (UTC) X-FDA: 78355235448.10.C08ED0F Received: from mail-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.52]) by imf22.hostedemail.com (Postfix) with ESMTP id BD7AF191E for ; Mon, 12 Jul 2021 21:32:43 +0000 (UTC) Received: by mail-io1-f52.google.com with SMTP id y8so24515342iop.13 for ; Mon, 12 Jul 2021 14:32:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=p0UbOU0vjiqc719wOG0oZB7U04BfmrswCV40XldGFR0=; b=YqAFiVSy2G1zBJfGO843I1ZiXvfaN9nxExGEz/h3bVNireLhXXg2m6/9qeSswhiRhE lhzVRSRwgUVs6N7/VeOkw6PODsHmssoGDB+FgddHKZU+fKTC+AwQRhxO5+ERQCvIngg4 TVkXhlejoVbx4vliSkFmDszzwPHtef0K8odyM= 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=p0UbOU0vjiqc719wOG0oZB7U04BfmrswCV40XldGFR0=; b=R3ERbZS2HrQfTbdwjZSH2zSv0vmOFenT0EPSML4UOXIb2oczc+rcW+Z5oOxjVvxn+z J9ydsW/+H9yXz275l8EZlBI8iZGExTTxrfQTwav8rQI0r/NqRsglLin1Y1E8j8HNOWBS HKvhN6WBbwPtssHT1YABIqgoZVwsjgHWAYa1dXA7vIT9gQZ1lPS8qc2x0fehzqtFYU6s ZEG6urKnvXQypfMsVRmDLT9E7QDVoaPXldcJY8EFVS+f0DyA5vfU1Yt3Vt0SjKTtKOEL IG9EHK8SjKicOG4fCkTm//eseWAH4eaKqQOEEWCKAeSCaYYG2nSrVF3CtG3Q/jFNTq6v q3uA== X-Gm-Message-State: AOAM533ybQZ1muHZvnJT7xRHBWxf0PbGohtnIr5ocRNRpw2POZbtPq6P m27+xFPdSrKjM9zkBtFJaAWsSYlmRgU8uQ== X-Google-Smtp-Source: ABdhPJzWMXdoeySxeUr6mh/KanNss7HarVL7sRCPx8G33sy7khf87Gcz20EGlEmOWrAQcJi9mCY3AA== X-Received: by 2002:a02:6946:: with SMTP id e67mr917485jac.4.1626125563032; Mon, 12 Jul 2021 14:32:43 -0700 (PDT) Received: from mail-io1-f41.google.com (mail-io1-f41.google.com. [209.85.166.41]) by smtp.gmail.com with ESMTPSA id o13sm6183963ilq.58.2021.07.12.14.32.41 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jul 2021 14:32:42 -0700 (PDT) Received: by mail-io1-f41.google.com with SMTP id d9so24480128ioo.2 for ; Mon, 12 Jul 2021 14:32:41 -0700 (PDT) X-Received: by 2002:a6b:7719:: with SMTP id n25mr683754iom.37.1626125561291; Mon, 12 Jul 2021 14:32:41 -0700 (PDT) MIME-Version: 1.0 References: <20210709105012.v2.1.I09866d90c6de14f21223a03e9e6a31f8a02ecbaf@changeid> In-Reply-To: From: Evan Green Date: Mon, 12 Jul 2021 14:32:05 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] mm: Enable suspend-only swap spaces To: Michal Hocko Cc: Andrew Morton , David Hildenbrand , Pavel Machek , Alex Shi , Alistair Popple , Jens Axboe , Johannes Weiner , Joonsoo Kim , "Matthew Wilcox (Oracle)" , Miaohe Lin , Minchan Kim , Vlastimil Babka , LKML , linux-mm@kvack.org, linux-api@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=YqAFiVSy; spf=pass (imf22.hostedemail.com: domain of evgreen@chromium.org designates 209.85.166.52 as permitted sender) smtp.mailfrom=evgreen@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Rspamd-Server: rspam02 X-Stat-Signature: z17g5mgp1kd86g7h7ja67ai9hn9jnpr9 X-Rspamd-Queue-Id: BD7AF191E X-HE-Tag: 1626125563-279040 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 Mon, Jul 12, 2021 at 12:03 AM Michal Hocko wrote: > > [Cc linux-api] > > On Fri 09-07-21 10:50:48, Evan Green wrote: > > Currently it's not possible to enable hibernation without also enabling > > generic swap for a given swap area. These two use cases are not the > > same. For example there may be users who want to enable hibernation, > > but whose drives don't have the write endurance for generic swap > > activities. > > > > Add a new SWAP_FLAG_NOSWAP that adds a swap region but refuses to allow > > generic swapping to it. This region can still be wired up for use in > > suspend-to-disk activities, but will never have regular pages swapped to > > it. > > Could you expand some more on why a strict exclusion is really > necessary? I do understand that one might not want to have swap storage > available all the time but considering that swapon is really a light > operation so something like the following should be a reasonable > workaround, no? > swapon storage/file > s2disk > swapoff storage Broadly, it seemed like a reasonable thing for the kernel to be able to do. The workaround you suggest does work for some use cases, but it seems like a gap the kernel could more naturally fill. Without getting too off into the weeds, there a handful of factors that make this change particularly useful to me: * Slicing off part of your SSD to be SLC (single level cell) is expensive. From what I understand you gain endurance and speed at the cost of 3-4x capacity. In other words for every 1GB of SLC space you need for swap, it costs you 3-4GB of storage space out of the primary namespace. So I'm incentivized to size this region as small as possible. Hibernate's speed/endurance requirements are not quite as harsh as regular swap. Steering them separately gives me the ability to put the hibernate image in regular storage, and not be forced to oversize expensive/fast swap space. * Even with the workaround, swap can end up in the hibernate region. Hibernate starts by allocating its giant 50%-of-memory region, which is often the forcing function for pushing things into swap. With the workaround, even if my hibernate region is in last priority, there's still a reasonable chance I'll end up swapping into it. If I have different security designs for swap space and hibernate, then even a chance of some swap leaking into this region is a problem. * I also want to limit the online attack surface that swap presents. I can make headway here by disallowing open() calls on active swap regions (via an LSM), and permanently disabling swapon/swapoff system calls after early init. The workaround isn't great for me because I want to set everything up at early init time and then not touch it. By suspend time, on my system I no longer have the ability to make swapon/swapoff calls. -Evan