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=-1.0 required=3.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 7A83DC433E1 for ; Tue, 7 Jul 2020 07:38:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3F8C1206E2 for ; Tue, 7 Jul 2020 07:38:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3F8C1206E2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E03D86B005A; Tue, 7 Jul 2020 03:38:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB3106B005C; Tue, 7 Jul 2020 03:38:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA39A6B005D; Tue, 7 Jul 2020 03:38:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B6DA86B005A for ; Tue, 7 Jul 2020 03:38:28 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9D76C181AEF09 for ; Tue, 7 Jul 2020 07:38:27 +0000 (UTC) X-FDA: 77010477054.25.name26_5a0117626eb2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 71EFD1804E3A1 for ; Tue, 7 Jul 2020 07:38:27 +0000 (UTC) X-HE-Tag: name26_5a0117626eb2 X-Filterd-Recvd-Size: 4715 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 07:38:26 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id 17so45346514wmo.1 for ; Tue, 07 Jul 2020 00:38:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ikBOfPiAYjEtvfpg2ndBX1AEFGTwRae8CH9t1jZQyN4=; b=nuQDdXSv+1cZzaIfCBE2UckKVVVG37ZfPBNdpOuDx0fPBnXiyH80SxHZaeY+a4iMHP qYjnwepFXZxPl9iXC0ydETu93Ukn+hfLWzuQANzDG/su68Y60PjEtBIDpUYG4LPJi3Gr IAGGfcJWKxE4NA/8t4QbiuHKkeMFI5Agv3uFHuVD5IFkOFKjTFT/rf2FB5xjkrVBh/A5 NSF3OINWkkOzVyZ57s+vG2KTL17g7Kvhv2wso5m7njpgM1o8YDFdpdZTwxwzo0jTU2FB L2IvVciGfkRUMFuk9FNrXn5BHBN+FSRgOz9z3gZU2c5NERUgndvIuMaPMtLnKY/j1OoV p+Lg== X-Gm-Message-State: AOAM531txgiTooSoBAdMydaH02U3Ug9bwNquzIjbzGCNy0BBkkf7/N8m Td4PnB+JJIAeJNqVe6Xafpg= X-Google-Smtp-Source: ABdhPJw+rfkXNBOmAmzmsHQwYBliQFLIQ5OnnLWSGUd52iK1yN+tLiulM3nr1g/sS85KQZxjR0w1Lg== X-Received: by 2002:a1c:408b:: with SMTP id n133mr2750285wma.88.1594107505827; Tue, 07 Jul 2020 00:38:25 -0700 (PDT) Received: from localhost (ip-37-188-179-51.eurotel.cz. [37.188.179.51]) by smtp.gmail.com with ESMTPSA id 33sm28857100wri.16.2020.07.07.00.38.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 00:38:24 -0700 (PDT) Date: Tue, 7 Jul 2020 09:38:23 +0200 From: Michal Hocko To: Jann Horn Cc: "Catangiu, Adrian Costin" , "linux-mm@kvack.org" , "linux-pm@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "linux-api@vger.kernel.org" , "akpm@linux-foundation.org" , "rjw@rjwysocki.net" , "len.brown@intel.com" , "pavel@ucw.cz" , "fweimer@redhat.com" , "keescook@chromium.org" , "luto@amacapital.net" , "wad@chromium.org" , "mingo@kernel.org" , "bonzini@gnu.org" , "Graf (AWS), Alexander" , "MacCarthaigh, Colm" , "Singh, Balbir" , "Sandu, Andrei" , "Brooker, Marc" , "Weiss, Radu" , "Manwaring, Derek" Subject: Re: [RFC]: mm,power: introduce MADV_WIPEONSUSPEND Message-ID: <20200707073823.GA3820@dhcp22.suse.cz> References: <20200703113026.GT18446@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 71EFD1804E3A1 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 03-07-20 15:29:22, Jann Horn wrote: > On Fri, Jul 3, 2020 at 1:30 PM Michal Hocko wrote: > > On Fri 03-07-20 10:34:09, Catangiu, Adrian Costin wrote: > > > This patch adds logic to the kernel power code to zero out contents of > > > all MADV_WIPEONSUSPEND VMAs present in the system during its transition > > > to any suspend state equal or greater/deeper than Suspend-to-memory, > > > known as S3. > > > > How does the application learn that its memory got wiped? S2disk is an > > async operation and it can happen at any time during the task execution. > > So how does the application work to prevent from corrupted state - e.g. > > when suspended between two memory loads? > > You can do it seqlock-style, kind of - you reserve the first byte of > the page or so as a "is this page initialized" marker, and after every > read from the page, you do a compiler barrier and check whether that > byte has been cleared. This is certainly possible yet wery awkwar interface to use IMHO. MADV_EXTERNALY_VOLATILE would express the actual semantic much better. I might not still understand the expected usecase but if the target application has to be changed anyway then why not simply use a transparent and proper signaling mechanism like poll on a fd. That would be certainly a more natural and less error prone programming interface. -- Michal Hocko SUSE Labs