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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 E41ADC433DB for ; Mon, 22 Feb 2021 12:58:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5E00164F0B for ; Mon, 22 Feb 2021 12:58:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E00164F0B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9CB0E6B0080; Mon, 22 Feb 2021 07:58:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 953936B0081; Mon, 22 Feb 2021 07:58:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 81B486B0082; Mon, 22 Feb 2021 07:58:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0116.hostedemail.com [216.40.44.116]) by kanga.kvack.org (Postfix) with ESMTP id 68FB56B0080 for ; Mon, 22 Feb 2021 07:58:09 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2FBD087CA for ; Mon, 22 Feb 2021 12:58:09 +0000 (UTC) X-FDA: 77845906698.19.5E1CC49 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf07.hostedemail.com (Postfix) with ESMTP id 06E2FA0009DD for ; Mon, 22 Feb 2021 12:58:07 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1613998687; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VapX0P1cjmfTsM5vWm6XJfMkWbyfERrb6gAU3Sl6W4Q=; b=WJkXS1MRD8pmy72Tqm8tbLj4R9dTBxozMzQZtygXtuV4ch1Z4xqZsV9zWtePWU+3bU2bTa o+K5m3839jIF7PigP8a7p2FBcw0YyQiTe/A055r3eVYeXRHhAJ9DL6F0hly9nbPqxMVTqo ZD1DSkJ2z7GHZJcsJHgnMOzqIX3Awrc= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 1D631AE1C; Mon, 22 Feb 2021 12:58:07 +0000 (UTC) Date: Mon, 22 Feb 2021 13:56:35 +0100 From: Michal Hocko To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Arnd Bergmann , Oscar Salvador , Matthew Wilcox , Andrea Arcangeli , Minchan Kim , Jann Horn , Jason Gunthorpe , Dave Hansen , Hugh Dickins , Rik van Riel , "Michael S . Tsirkin" , "Kirill A . Shutemov" , Vlastimil Babka , Richard Henderson , Ivan Kokshaysky , Matt Turner , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Chris Zankel , Max Filippov , linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-arch@vger.kernel.org Subject: Re: [PATCH RFC] mm/madvise: introduce MADV_POPULATE to prefault/prealloc memory Message-ID: References: <20210217154844.12392-1-david@redhat.com> <640738b5-a47e-448b-586d-a1fb80131891@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <640738b5-a47e-448b-586d-a1fb80131891@redhat.com> X-Stat-Signature: ymac7aemqyinm91qw3xqhuh3ek3gpxnk X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 06E2FA0009DD Received-SPF: none (suse.com>: No applicable sender policy available) receiver=imf07; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1613998687-64803 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 Sat 20-02-21 10:12:26, David Hildenbrand wrote: [...] > Thinking about MADV_POPULATE vs. MADV_POPULATE_WRITE I wonder if it would be > more versatile to break with existing MAP_POPULATE semantics and directly go > with > > MADV_POPULATE_READ: simulate user space read access without actually > reading. Trigger a read fault if required. > > MADV_POPULATE_WRITE: simulate user space write access without actually > writing. Trigger a write fault if required. > > For my use case, I could use MADV_POPULATE_WRITE on anonymous memory and > RAM-backed files (shmem/hugetlb) - I would not have a minor fault when the > guest inside the VM first initializes memory. This mimics how QEMU currently > preallocates memory. > > However, I would use MADV_POPULATE_READ on any !RAM-backed files where we > actually have to write-back to a (slow?) device. Dirtying everything > although the guest might not actually consume it in the near future might be > undesired. Isn't what the current mm_populate does? if ((vma->vm_flags & (VM_WRITE | VM_SHARED)) == VM_WRITE) gup_flags |= FOLL_WRITE; So it will write fault to shared memory mappings but it will touch others. -- Michal Hocko SUSE Labs