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=-7.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 2687EC433DB for ; Mon, 22 Feb 2021 13:02:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CBDC864E41 for ; Mon, 22 Feb 2021 13:02:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231414AbhBVNB4 (ORCPT ); Mon, 22 Feb 2021 08:01:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:52621 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230220AbhBVNBl (ORCPT ); Mon, 22 Feb 2021 08:01:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613998814; 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=TRfCGo+d4jZVJhCFZnvsjweX1KWQd9768AoENBDOGlQ=; b=DlY3cpOcN6TJg4ZPvCOCONZWr6zWh9aSBLpCgZsgypZRuH4NO84JXHxwLNIjVXK3POR/D4 Y4aRETxmj9rZ2nvQxkFUYYvDwUsfXG3svgArpS+273OpwNSlRdN0Vfkw0PbYysQ/iRdBrw SV2svNtrU5RZqonDCzE65TB9uHVMSWI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-368-1hH8o-AHMaSAy3fNzDzl1g-1; Mon, 22 Feb 2021 08:00:09 -0500 X-MC-Unique: 1hH8o-AHMaSAy3fNzDzl1g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6E7EF8799EC; Mon, 22 Feb 2021 13:00:06 +0000 (UTC) Received: from [10.36.115.16] (ovpn-115-16.ams2.redhat.com [10.36.115.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5648872F85; Mon, 22 Feb 2021 12:59:56 +0000 (UTC) Subject: Re: [PATCH RFC] mm/madvise: introduce MADV_POPULATE to prefault/prealloc memory To: Michal Hocko 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 References: <20210217154844.12392-1-david@redhat.com> <640738b5-a47e-448b-586d-a1fb80131891@redhat.com> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: <73f73cf2-1b4e-bfa9-9a4c-3192d7b7a5ec@redhat.com> Date: Mon, 22 Feb 2021 13:59:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org On 22.02.21 13:56, Michal Hocko wrote: > 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. Exactly. But for hugetlbfs/shmem ("!RAM-backed files") this is not what we want. -- Thanks, David / dhildenb