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 49B9DC433B4 for ; Tue, 18 May 2021 10:08:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EC5FD61185 for ; Tue, 18 May 2021 10:08:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC5FD61185 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 87F848D000E; Tue, 18 May 2021 06:08:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 856248D0001; Tue, 18 May 2021 06:08:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A9B08D000E; Tue, 18 May 2021 06:08:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0207.hostedemail.com [216.40.44.207]) by kanga.kvack.org (Postfix) with ESMTP id 3A23D8D0001 for ; Tue, 18 May 2021 06:08:03 -0400 (EDT) Received: from smtpin33.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DC5767597 for ; Tue, 18 May 2021 10:08:02 +0000 (UTC) X-FDA: 78153926004.33.B6ABD02 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf19.hostedemail.com (Postfix) with ESMTP id DB0C590009DE for ; Tue, 18 May 2021 10:08:00 +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=1621332481; 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=gigLto3lPv80FBXCxS3AVF3qLiXYEjmKtIPmgS5Cpus=; b=rO1X3eI4OIacPcCVcwRsqXTr7RBYSjw1S9LpAfLKyZFW7yqJTB5gDPbzF+U9Tt1ai2tN3Q JKfht12ARMgFgTtq52DowvkKXf3UiQV9CBdNqcwLR9X3GPBHdhqPg1io7tGbr5bzKIyiMU 7AHrYmrt5Gsl7DQ5vh15i/vJ2SvvL28= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id CDC14B1F7; Tue, 18 May 2021 10:08:00 +0000 (UTC) Date: Tue, 18 May 2021 12:07:59 +0200 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 , Mike Kravetz , Peter Xu , Rolf Eike Beer , 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, Linux API Subject: Re: [PATCH resend v2 2/5] mm/madvise: introduce MADV_POPULATE_(READ|WRITE) to prefault page tables Message-ID: References: <20210511081534.3507-1-david@redhat.com> <20210511081534.3507-3-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210511081534.3507-3-david@redhat.com> Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=rO1X3eI4; spf=pass (imf19.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.15 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: DB0C590009DE X-Stat-Signature: b69ub311mz7khjekbtxoq4b3sow5y7tm X-HE-Tag: 1621332480-662850 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: [sorry for a long silence on this] On Tue 11-05-21 10:15:31, David Hildenbrand wrote: [...] Thanks for the extensive usecase description. That is certainly useful background. I am sorry to bring this up again but I am still not convinced that READ/WRITE variant are the best interface. > While the use case for MADV_POPULATE_WRITE is fairly obvious (i.e., > preallocate memory and prefault page tables for VMs), one issue is that > whenever we prefault pages writable, the pages have to be marked dirty, > because the CPU could dirty them any time. while not a real problem for > hugetlbfs or dax/pmem, it can be a problem for shared file mappings: each > page will be marked dirty and has to be written back later when evicting. > > MADV_POPULATE_READ allows for optimizing this scenario: Pre-read a whole > mapping from backend storage without marking it dirty, such that eviction > won't have to write it back. As discussed above, shared file mappings > might require an explciit fallocate() upfront to achieve > preallcoation+prepopulation. This means that you want to have two different uses depending on the underlying mapping type. MADV_POPULATE_READ seems rather weak for anonymous/private mappings. Memory backed by zero pages seems rather unhelpful as the PF would need to do all the heavy lifting anyway. Or is there any actual usecase when this is desirable? So the split into these two modes seems more like gup interface shortcomings bubbling up to the interface. I do expect userspace only cares about pre-faulting the address range. No matter what the backing storage is. Or do I still misunderstand all the usecases? -- Michal Hocko SUSE Labs