Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1131919pxv; Fri, 23 Jul 2021 00:00:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPbmLuTPtHuCbzlnUeZjGOIBX++vGif+EnuyyAP7exqXBHb4oaXwmPTIJxLTATKkXJ6Iwf X-Received: by 2002:aa7:db93:: with SMTP id u19mr3861960edt.227.1627023656355; Fri, 23 Jul 2021 00:00:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627023656; cv=none; d=google.com; s=arc-20160816; b=Bq4o/rXjVEZYBHhEyYneBzOYft+gDy73oUnx/TsJenUi8m7RwzgFWpviKUz/i4eRv3 tluRTh1VVobyNiTcGioA9Ui2EsDYq86bCxMLWQekbWDAEl3a+yy/ZlzcjsOaen6E+gTi Atk0XvaoAaX3ObGHkolM3P/tyHRSQJOy/0j5Xy2LXtZv9Zm8zQyLzoQN1gO6OrybIDmP w/KqBhmnaUb/DH2L7nARwxd0eAXAKLfH/mqB2HUQUmWpOFkdohgSs0voxMqUagdL5RCt aBRYcLO/OqDnig5oCpiXyGzKIO8Xuhjwlq5MBWGwXsB0/9ORFSCs67FzuN8ejX/lnBA3 ALfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject :organization:from:references:cc:to:dkim-signature; bh=ElwTUrgx2uwYZtx6RXk2BFBNKStGzvaPr0AwpeE9zds=; b=bDaS8n/UkOd6GjCg8rfdHZjtHeYOJq2EqjQw1urCNwAl/TBd1OqdxybGQx2JP/Hapg YkmybFVoztJlEJPhBnPWK8rWgRlhqgKU8rArgXl3AEZjmoDA2P+CbhJjTiHTO4KFUZF5 0CldtM4Wo7tzyHsRvBKJusAJ5ZX1isiC3LMH6rmfbRCEYObaRke0XClVKkyancpU4tR0 pIBYuG8Bv60lqv9VA+L+MzNhlFNw/Y2xq9z2T4rKX826ttpd9k5zUmoSHQ4ZNkKXaEy6 r/vL37RiXMe8vGDgZB5KRv7b/r0mbpNa1oweyaaXR9a7/YxJ2YEWVrejzN35Xt011Fdo 503A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ar6XOjQn; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cm4si31027260edb.535.2021.07.23.00.00.32; Fri, 23 Jul 2021 00:00:56 -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=@redhat.com header.s=mimecast20190719 header.b=Ar6XOjQn; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234152AbhGWGSM (ORCPT + 99 others); Fri, 23 Jul 2021 02:18:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46987 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234095AbhGWGSL (ORCPT ); Fri, 23 Jul 2021 02:18:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627023525; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ElwTUrgx2uwYZtx6RXk2BFBNKStGzvaPr0AwpeE9zds=; b=Ar6XOjQndwGIAZJ8LffQEs39bnM1MD1rJDDVK8tyZNTlvxW/AsD67ofM5QAeOWG0SphHbt T09j+nfh+n0aFCnrm4RneULBS2g0TpXEY079QW+wEpIvW+xJaWvyA9wHiR/3HoaAlOCUWe PNKT/T259kGoveBC/axkfEwzL9p+OSA= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-104-u1uMuu7fPGajssi2XTzS8w-1; Fri, 23 Jul 2021 02:58:43 -0400 X-MC-Unique: u1uMuu7fPGajssi2XTzS8w-1 Received: by mail-wm1-f70.google.com with SMTP id g39-20020a05600c4ca7b0290236a25b0497so45422wmp.2 for ; Thu, 22 Jul 2021 23:58:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:organization:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=ElwTUrgx2uwYZtx6RXk2BFBNKStGzvaPr0AwpeE9zds=; b=Z7Bp3czmj26AvrttfJwumMt87Fm579U20qEuMcQiID+8awx4M6sSr964Fm2+vPyRds cKqv98ybpJYEaT348RmRlhzbmZhe6g9ioacVzWz6Kk3Ct4XDPndo4hPZjGJql0933uvk VnqKtc3MeDf+cR5abkIe2CUiimT6Nud4PTIl6qdAq4XQBLq6jT/kt8vj2XLIp4tgduuh AfavO4xExLsby0+zAQigaS+rbcde3R/IaB8m3DnpgsVAm5Zx+EoVl6sDsVMCBRZIcKNd POgpTz1xi4xuSfq5EqsylMxhXQSIqKEBfAG9YPJS5klOfKemueZ6tNDIKF2BgrPrv90w pYLQ== X-Gm-Message-State: AOAM532hvVvVuhzA1klz6oPJi3+G1gOAwsmIwNfUSHXVXayc+lzQjkcF ObBHT9aMEhZrOhS7ik5IRiL0xcbVGjslRiHdYhR9pftgQbLnqXpFvxnWDoQ2A/+pToYxelQnc/B G5gAMAEFADdLwftN9zmaN38Vd X-Received: by 2002:a5d:4cce:: with SMTP id c14mr3584270wrt.258.1627023522728; Thu, 22 Jul 2021 23:58:42 -0700 (PDT) X-Received: by 2002:a5d:4cce:: with SMTP id c14mr3584258wrt.258.1627023522457; Thu, 22 Jul 2021 23:58:42 -0700 (PDT) Received: from [192.168.3.132] (p5b0c676e.dip0.t-ipconnect.de. [91.12.103.110]) by smtp.gmail.com with ESMTPSA id z13sm32834744wro.79.2021.07.22.23.58.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Jul 2021 23:58:41 -0700 (PDT) To: Evan Green Cc: Andrew Morton , linux-api@vger.kernel.org, Michal Hocko , Pavel Machek , Alex Shi , Alistair Popple , Johannes Weiner , Joonsoo Kim , "Matthew Wilcox (Oracle)" , Miaohe Lin , Minchan Kim , Suren Baghdasaryan , Vlastimil Babka , LKML , linux-mm@kvack.org References: <20210721143946.v3.1.I09866d90c6de14f21223a03e9e6a31f8a02ecbaf@changeid> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v3] mm: Enable suspend-only swap spaces Message-ID: <3c46df04-abf4-4bcb-b9cf-430bb1d15b07@redhat.com> Date: Fri, 23 Jul 2021 08:58:40 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22.07.21 20:00, Evan Green wrote: > On Thu, Jul 22, 2021 at 12:12 AM David Hildenbrand wrote: >> >> On 21.07.21 23:40, 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. Swap and hibernate also have different security/integrity >>> requirements, prompting folks to possibly set up something like block-level >>> integrity for swap and image-level integrity for hibernate. Keeping swap >>> and hibernate separate in these cases becomes not just a matter of >>> preference, but correctness. >>> >>> 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. This flag will be passed in by utilities like swapon(8), usage would >>> probably look something like: swapon -o noswap /dev/sda2. >> >> Just a minor comment, I'd call it rather SWAP_FLAG_HIBERNATE_ONLY and >> SWAP_FLAG_HIBERNATE_ONLY -- that calls the child by its name. > > I went back and forth on this too. It seemed pretty close to toss-up > to me. I went with NOSWAP ultimately because it seemed more closely > tied to what the flag was actually doing, rather than building in my > one expected use case into the name. In some world years from now > where either hibernate has diverged, been deleted, or maybe some new > usage has been invented for swap space, the NOSWAP name felt like it > had a better chance of holding up. The argument is weak though, as > these features are pretty well cast in stone, and the likelihood of > any of those outcomes seems low. I can change it if you feel strongly, > but would probably keep it as-is otherwise. Just imagine technology Z popping up and using also the swap infrastructure. What would be the semantics of NOSWAP? With HIBERNATE_ONLY it's clear -- enable that device only for hibernation, nothing else. But you raise a good point: if hibernation isn't even possible in a configuration (e.g., not configured into the kernel), we should simply reject that flag. So if hibernation would vanish at some point completely from the system, it would all be handled accordingly. That would result in quite a consistent definition of SWAP_FLAG_HIBERNATE_ONLY IMHO. Makes sense? > >> >> I think some other flags might not apply with that new flag set, right? >> For example, does SWAP_FLAG_DISCARD_ONCE or SWP_AREA_DISCARD still have >> any meaning with the new flag being set? >> >> We should most probably disallow enabling any flag that doesn't make any >> sense in combination. > > Good point, I can send a followup patch for that. From my reading I'd actually enjoy if we'd have that logic in the introducing patch. > SWAP_FLAG_DISCARD and SWAP_FLAG_DISCARD_ONCE are still valid, since > the discard can be run at swapon() time. SWAP_FLAG_PREFER (specifying > the priority) doesn't make sense, and SWAP_FLAG_DISCARD_PAGES never > kicks in because it's called at the cluster level. Hm, that sort of > seems like a bug that freed hibernate swap doesn't get discarded. I > can disallow it now as unsupported, but might send a patch to fix it > later. Might be worth fixing, indeed. > >> >> Apart from that, I'd love to see a comment in here why the workaround >> suggested by Michal isn't feasible -- essentially a summary of what we >> discussed. > > Ah sorry, I had tried to clarify that in the commit text, but didn't > explicitly address the workaround. To summarize, the workaround keeps > generic swap out of your hibernate region... until hibernate time. But > once hibernate starts, a lot of swapping tends to happen when the > hiber-image is allocated. At this point the hibernate region is > eligible for general swap even with the workaround. The reasons I gave > for wanting to exclusively steer swap and hibernate are SSD write > wearing, different integrity solutions for swap vs hibernate, and our > own security changes that no-op out the swapon/swapoff syscalls after > init. > That would be nice to have in the patch description :) -- Thanks, David / dhildenb