Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1055517pxv; Fri, 9 Jul 2021 16:24:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwy0x0yNdLTjqR6Dc2LLUuFLW047j7GsvYWlUOkyxdprL2BNe/oJNdbb3HUxT0z+bTz7uMa X-Received: by 2002:a6b:794b:: with SMTP id j11mr29921195iop.129.1625873095566; Fri, 09 Jul 2021 16:24:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625873095; cv=none; d=google.com; s=arc-20160816; b=iDwW0ICD9RoBx9NszbhrtAFmqOLiZEogWOePQ01Yht1S27TvUidXSPkxAMz+YibyEE 5ZYkDrKO2lT/gHTusAuMQsH/EZUGlCSWTfI774FEWVdGYQufIhOvl1SHEJBdqqdyHCOw 9vsu03FRre7NWd/+XD0Kd1ExxWCTgFxHVqx50DT9jo1ArfGChvFhtukITGxV74ZnCsP1 IYPEih5AOpFSzPoqyAcFHLEcFv4N+aUS0ieR2rQHoFYfNi5Oq3k5PgyspVV2gy//Yl4u bBEgOC8bj+vA9ivC+TomNImC652Q1aYNqLOmcZ/KuJLSPsrEaYiPigXt9/YhaYExaj96 VnJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=z3wl6RUe64j2ktudh1QXGUWI+b37bnu1qQ0VROOBcwc=; b=qYv9Hg1tLnuTCI+CtqvJeOn9Zwjv1jtnsbc7c3SdxyPHlnVk2aGK6nVdrx4zJkuvMR n8+fpsW8g/xgDkwYPXPXtzsTpT0N+TRTeXg97JBBicWv7CFkCwQ7MR1PtsuKzynR0KWj 5zmO0giCZ9e3xYVbFHc8DNHy4I/1s6Q0uMeQKMjbRI5Hyz0zsA4h0qhV7jxrxIt+g9mX t72cJ43iIIvV++6I1NVBOcAUiQV9CqmJhYsTbjxOFXndtwg7AzZsaJa3G47hsUzjF3Il 2lXtjGYpBU29iCzVXFtYcUSUqBQufezx/jvbzDa90RXrNN2a/ZAavwjmCyFF91Hs8/sE lHwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mP4kT1ln; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v14si7448556ilj.0.2021.07.09.16.24.41; Fri, 09 Jul 2021 16:24:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mP4kT1ln; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230082AbhGIX0m (ORCPT + 99 others); Fri, 9 Jul 2021 19:26:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229882AbhGIX0l (ORCPT ); Fri, 9 Jul 2021 19:26:41 -0400 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7AF0C0613DD for ; Fri, 9 Jul 2021 16:23:56 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id o10so12120483ils.6 for ; Fri, 09 Jul 2021 16:23:56 -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=z3wl6RUe64j2ktudh1QXGUWI+b37bnu1qQ0VROOBcwc=; b=mP4kT1ln+2gZKQefMzT9fgCMsUN+T9AvXJqutn9W9hbWQtQ9SU37TzrJzFETRl2tlS R+pydXnVQpx0K0csHb5wQRYqHuaMC5owLErCUGdUIzDBjR5yjw//hHsU8eFMocO/BYVf gQpt9eclrzW6i+cWbegfovVbWWS6g+C6f+UR8= 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=z3wl6RUe64j2ktudh1QXGUWI+b37bnu1qQ0VROOBcwc=; b=e24s5ya02JU0IWer1CwS8dcTMVbVQpfogfrlvKyeLeYB7q9/RdKblFrunxzVTMrtb8 w67BDw+hbtVBGNvPEI7KyZWQdtp6lFtNPcbNofWOqj0IOGQp7SrjAE3A5kuWbM0Ot8rt UwAG6S1ti+a8bqr0GglkCXscpgVE3cv2Aa7p2RSGl6UawlzTZbGgUgZRCXuvQ9GKUOds AsFZ7VfqVDlradxX9716t8j5peHQ/yHHnmIq8iyGMo9V8NS4WNw3Y6woRReWuH7l4xBa a7JZte9CZZDcjNxEE2KKQUt4aiiVY99FTENkafcJewkF2qKtaMksvtfXFFggjY2KpPpv ukHw== X-Gm-Message-State: AOAM532MOkk9EymPgKLIYF80cFLT3S/cUHqkJvdJrjvCWWHSrILvCZJ1 OhNiAyXt/S4SejLHUhYmrMsB7yQg6yRYpA== X-Received: by 2002:a92:c504:: with SMTP id r4mr3331414ilg.131.1625873035304; Fri, 09 Jul 2021 16:23:55 -0700 (PDT) Received: from mail-io1-f44.google.com (mail-io1-f44.google.com. [209.85.166.44]) by smtp.gmail.com with ESMTPSA id c19sm3713263ili.62.2021.07.09.16.23.54 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jul 2021 16:23:54 -0700 (PDT) Received: by mail-io1-f44.google.com with SMTP id 62so2342096iob.0 for ; Fri, 09 Jul 2021 16:23:54 -0700 (PDT) X-Received: by 2002:a05:6638:d93:: with SMTP id l19mr20497179jaj.46.1625873034167; Fri, 09 Jul 2021 16:23:54 -0700 (PDT) MIME-Version: 1.0 References: <20210709105012.v2.1.I09866d90c6de14f21223a03e9e6a31f8a02ecbaf@changeid> <20210709152024.36f650dfec4c66ef3a60a845@linux-foundation.org> In-Reply-To: <20210709152024.36f650dfec4c66ef3a60a845@linux-foundation.org> From: Evan Green Date: Fri, 9 Jul 2021 16:23:18 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] mm: Enable suspend-only swap spaces To: Andrew Morton Cc: David Hildenbrand , Pavel Machek , Alex Shi , Alistair Popple , Jens Axboe , Johannes Weiner , Joonsoo Kim , "Matthew Wilcox (Oracle)" , Miaohe Lin , Michal Hocko , Minchan Kim , Vlastimil Babka , LKML , linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 9, 2021 at 3:20 PM Andrew Morton wrote: > > On Fri, 9 Jul 2021 10:50:48 -0700 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. > > > > Swap regions with SWAP_FLAG_NOSWAP set will not appear in /proc/meminfo > > under SwapTotal and SwapFree, since they are not usable as general swap. > > > > This patch doesn't appear to set SWAP_FLAG_NOSWAP anywhere. Perhaps > there's another patch somewhere which changes the hibernation code? If > so, can we please have both patches in a series? There's no other patch, in the kernel at least. SWAP_FLAG_* is exposed to usermode, which would set it when calling swapon(2). Once this patch is accepted, I'll have to add the option into util-linux [1], so that I can use it in my init scripts. Said a different way, this patch isn't about altering how hibernate behaves, but about giving usermode the freedom to set up hibernate and swap independently. [1] https://github.com/karelzak/util-linux/blob/b4533177aeac287e0b0563cd1b9ee61bce29ee88/sys-utils/swapon.c#L710 > > Once we have a description of how this thing gets set, please let's > discuss what happens if someone tries to enable generic swap onto that > device after hibernation has set SWAP_FLAG_NOSWAP (I'm basically > guessing now). Will it work? Is there a backward-compatibility issue > here? The above paragraph maybe cleared this up. The hibernate code will still happily do I/O to any region handed to it by the swap code. That could be a region already peppered with active swap (the normal case today), or a NOSWAP region which swap otherwise stays out of (but still manages). If we did swapoff and swapon with a different setting for NOSWAP, that should all work fine, since hibernate leaves it to the swapfile code to be in charge of sector allocs/frees. There shouldn't be any backward compatibility issues because SWAP_FLAGS_VALID enforced that usermode had been keeping the unallocated bits as 0. -Evan