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.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 F2C3EC433E3 for ; Tue, 7 Jul 2020 08:58:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE5052075B for ; Tue, 7 Jul 2020 08:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594112333; bh=tjvAF4Z1MwTFyGyHy8TDsIGHXC1Wuecz62LenDpLIwU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=eA4mfukGDqVsER0DynRPlF1BZIM8Nj+gaCpJr12JBFpUbbhmSRQul34SF19ypBWAJ F1ll0FpzMO7hNCjcR42C92rI6PQ0b2IOl6w/NRvD64XY7qn+gCsSg6MjwAUpRPlfpt 9h4nrkt/72h7xTcs2jOI00rbYtWhQ+2XrZHBaJtM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727916AbgGGI6w (ORCPT ); Tue, 7 Jul 2020 04:58:52 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:40707 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727072AbgGGI6v (ORCPT ); Tue, 7 Jul 2020 04:58:51 -0400 Received: by mail-wr1-f66.google.com with SMTP id f2so16314369wrp.7; Tue, 07 Jul 2020 01:58:50 -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=p2KKakvKcIBMPs7A15wXqiGUJod4izHac2NRC29BoeY=; b=MDH4S47AMz7278CpBIu8PAnelnTJg5bloVDlONZOu1RdtNjCbLfm4zpdYm2se/F8hb /jtAxQkTrRa2OZHv3vV+M3Sp/4fYQfbcvzsBrpN+p/MLXO+5aVrPw6OgemdsccRohBDD 3Aj3yyxWC1PFl8jakN7hP6LGs02dzJDkVWo+LlS4SMPi5/pA0rydMgPvDmtZZFgJlOVO VMSnCnxDDmQ31OcSUJ+sWMvaNx6zFc3mp4u8RSp3qe8cnjP3G/05EBhYNPagyFPa4epF fJ4OiQ3JTpZTi92hWM5vnCam5yIE/lbmB+JL46WIBRzABS7C47/ab+3kg1pWWXQew1i+ HAYA== X-Gm-Message-State: AOAM533YYOFUsnNzdNE3RgW7+1O2ZdwvP0fYkibwabaewm2pZjDxVNgC rgoPq+DJwkl0u4bcGuMaHVE= X-Google-Smtp-Source: ABdhPJwh9XUbUNDBRq8RVH5mZ3inft6fVxiv+AyB+oFzHzHwbX6vqWzzuu2czS9FjeuVL6nNGIn0OA== X-Received: by 2002:adf:81c8:: with SMTP id 66mr52819103wra.348.1594112329520; Tue, 07 Jul 2020 01:58:49 -0700 (PDT) Received: from localhost (ip-37-188-179-51.eurotel.cz. [37.188.179.51]) by smtp.gmail.com with ESMTPSA id v5sm192665wmh.12.2020.07.07.01.58.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 01:58:48 -0700 (PDT) Date: Tue, 7 Jul 2020 10:58:47 +0200 From: Michal Hocko To: Pavel Machek Cc: Jann Horn , "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" , "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: <20200707085847.GA5913@dhcp22.suse.cz> References: <20200703113026.GT18446@dhcp22.suse.cz> <20200707073823.GA3820@dhcp22.suse.cz> <20200707080726.GA32357@amd> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200707080726.GA32357@amd> Sender: linux-api-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org On Tue 07-07-20 10:07:26, Pavel Machek wrote: > Hi! > > > > > > 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 > > The goal is to have cryprographically-safe get_random_number() with 0 > syscalls. > > You'd need to do: > > if (!poll(did_i_migrate)) { > use_prng_seed(); > if (poll(did_i_migrate)) { > /* oops_they_migrated_me_in_middle_of_computation, > lets_redo_it() */ > goto retry: > } > } > > Which means two syscalls.. Is this a real problem though? Do we have any actual numbers? E.g. how often does the migration happen so that 2 syscalls would be visible in actual workloads? -- Michal Hocko SUSE Labs 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 DF94BC433E1 for ; Tue, 7 Jul 2020 08:58:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8E586206CD for ; Tue, 7 Jul 2020 08:58:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E586206CD 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 DE4926B0026; Tue, 7 Jul 2020 04:58:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D6DBC6B0028; Tue, 7 Jul 2020 04:58:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C356D6B002C; Tue, 7 Jul 2020 04:58:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0159.hostedemail.com [216.40.44.159]) by kanga.kvack.org (Postfix) with ESMTP id A64F86B0026 for ; Tue, 7 Jul 2020 04:58:51 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 5433D8248047 for ; Tue, 7 Jul 2020 08:58:51 +0000 (UTC) X-FDA: 77010679662.27.rate56_21150bb26eb3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id 3319C3D668 for ; Tue, 7 Jul 2020 08:58:51 +0000 (UTC) X-HE-Tag: rate56_21150bb26eb3 X-Filterd-Recvd-Size: 5163 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 08:58:50 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id f7so41284728wrw.1 for ; Tue, 07 Jul 2020 01:58:50 -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=p2KKakvKcIBMPs7A15wXqiGUJod4izHac2NRC29BoeY=; b=LF9O3mx9XYSHYtxN2xJKqbVP9KIxsSx7cQLFUkyHhBIAtbgWLugiHLo68CkgLCdRqb FlY5lsXYIkoneM+wEKo2844ve3F8WnMirmzUsvNqLQinlPBZGLEtEUkGH8gX2JLS682U JyyG9nb02mUFCrcGNfav3D0sIfgsZdW6RBqEl36bZMTJOmPkxfYSnbJkZPq88Md/GTWo 5HILGHP6oWdH8imLCZzv4MJMpF3FtzPRnrVDJ6XwTTg0BqEfx0rHbk4Kh3KFTjIV7WeN +lTPZSy/76O2fMb+vRhiZfpYSRjgwRduAQCuqaOWV11cKvPxeG5ucKRciqnSG0/pSK+m KIBQ== X-Gm-Message-State: AOAM532EfkGqXWcAKyHGPVWUBuvnvErWSsvDY7799TvscZVdCzPsPSYU yH+avKBEUeP0Zs5+ERmHyi0= X-Google-Smtp-Source: ABdhPJwh9XUbUNDBRq8RVH5mZ3inft6fVxiv+AyB+oFzHzHwbX6vqWzzuu2czS9FjeuVL6nNGIn0OA== X-Received: by 2002:adf:81c8:: with SMTP id 66mr52819103wra.348.1594112329520; Tue, 07 Jul 2020 01:58:49 -0700 (PDT) Received: from localhost (ip-37-188-179-51.eurotel.cz. [37.188.179.51]) by smtp.gmail.com with ESMTPSA id v5sm192665wmh.12.2020.07.07.01.58.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 01:58:48 -0700 (PDT) Date: Tue, 7 Jul 2020 10:58:47 +0200 From: Michal Hocko To: Pavel Machek Cc: Jann Horn , "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" , "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: <20200707085847.GA5913@dhcp22.suse.cz> References: <20200703113026.GT18446@dhcp22.suse.cz> <20200707073823.GA3820@dhcp22.suse.cz> <20200707080726.GA32357@amd> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200707080726.GA32357@amd> X-Rspamd-Queue-Id: 3319C3D668 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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 Tue 07-07-20 10:07:26, Pavel Machek wrote: > Hi! > > > > > > 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 > > The goal is to have cryprographically-safe get_random_number() with 0 > syscalls. > > You'd need to do: > > if (!poll(did_i_migrate)) { > use_prng_seed(); > if (poll(did_i_migrate)) { > /* oops_they_migrated_me_in_middle_of_computation, > lets_redo_it() */ > goto retry: > } > } > > Which means two syscalls.. Is this a real problem though? Do we have any actual numbers? E.g. how often does the migration happen so that 2 syscalls would be visible in actual workloads? -- Michal Hocko SUSE Labs From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michal Hocko Subject: Re: [RFC]: mm,power: introduce MADV_WIPEONSUSPEND Date: Tue, 7 Jul 2020 10:58:47 +0200 Message-ID: <20200707085847.GA5913@dhcp22.suse.cz> References: <20200703113026.GT18446@dhcp22.suse.cz> <20200707073823.GA3820@dhcp22.suse.cz> <20200707080726.GA32357@amd> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20200707080726.GA32357@amd> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Pavel Machek Cc: Jann Horn , "Catangiu, Adrian Costin" , "linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org" , "linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org" , "linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org" , "rjw-LthD3rsA81gm4RdzfppkhA@public.gmane.org" , "len.brown-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org" , "fweimer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org" , "keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org" , "luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org" , "wad-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org" , "mingo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org" , "bonzini-mXXj517/zsQ@public.gmane.org" , "Graf (AWS), Alexander" List-Id: virtualization@lists.linuxfoundation.org On Tue 07-07-20 10:07:26, Pavel Machek wrote: > Hi! > > > > > > 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 > > The goal is to have cryprographically-safe get_random_number() with 0 > syscalls. > > You'd need to do: > > if (!poll(did_i_migrate)) { > use_prng_seed(); > if (poll(did_i_migrate)) { > /* oops_they_migrated_me_in_middle_of_computation, > lets_redo_it() */ > goto retry: > } > } > > Which means two syscalls.. Is this a real problem though? Do we have any actual numbers? E.g. how often does the migration happen so that 2 syscalls would be visible in actual workloads? -- Michal Hocko SUSE Labs