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=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 A3AC0C433DB for ; Thu, 25 Feb 2021 17:33:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3DFBA64F21 for ; Thu, 25 Feb 2021 17:33:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3DFBA64F21 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CB6516B006C; Thu, 25 Feb 2021 12:33:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C68406B006E; Thu, 25 Feb 2021 12:33:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B30026B0070; Thu, 25 Feb 2021 12:33:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0191.hostedemail.com [216.40.44.191]) by kanga.kvack.org (Postfix) with ESMTP id 9D8916B006C for ; Thu, 25 Feb 2021 12:33:21 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 63166180206FE for ; Thu, 25 Feb 2021 17:33:21 +0000 (UTC) X-FDA: 77857486602.14.42D7A08 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id 79FDCC0042C5 for ; Thu, 25 Feb 2021 17:33:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Ww8ipOst8GbveiTvOaDMMaZrpR8vD/2Cq+k5zcspXqA=; b=paAIEUvVWl4rXXM9lK2H74nS40 r1/GuSDOiKBCOoEd8accZONl5Zhrr2If/UqTPdZ/S5qKVeQfVqSHG0GEsVW4a+9N4Cp1m4OCdjfEw /76+Km0HfdQKdBZcm3QUNZGxWnQYSqOKvEHa0h4g30LAJrIJyYmYGKyHqisjaobvWHDi/CXt4Vu5n 92okHsFJ0ayQ4EY3mWz5nIrzG1g+XDQi9rOSn7N+BHmjJR+CHuimZorvXygeUA8zBoX8GF9Gug18k IdK/zQLfuBM63sH5hSPL56PFbLcDlRGs/w8n1xcJYSyaZB63j6AvnJYbFhf+Vf/BGHxoNeFVoe/ds qldzHCWQ==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lFKVR-00Ay26-5c; Thu, 25 Feb 2021 17:32:54 +0000 Date: Thu, 25 Feb 2021 17:32:53 +0000 From: Matthew Wilcox To: Nadav Amit Cc: Linux-MM , LKML , Hugh Dickins , Andy Lutomirski , Thomas Gleixner , Peter Zijlstra , Ingo Molnar , Borislav Petkov , Sean Christopherson , Andrew Morton , "x86@kernel.org" Subject: Re: [RFC 0/6] x86: prefetch_page() vDSO call Message-ID: <20210225173253.GB2858050@casper.infradead.org> References: <20210225072910.2811795-1-namit@vmware.com> <20210225121645.GZ2858050@casper.infradead.org> <0EFCDB0B-DB73-4866-9C0B-7192737CA372@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0EFCDB0B-DB73-4866-9C0B-7192737CA372@vmware.com> X-Stat-Signature: xeeaq5ubyzzf4q7uf6jeaw4r9mkg19y6 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 79FDCC0042C5 Received-SPF: none (infradead.org>: No applicable sender policy available) receiver=imf22; identity=mailfrom; envelope-from=""; helo=casper.infradead.org; client-ip=90.155.50.34 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614274394-636539 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 Thu, Feb 25, 2021 at 04:56:50PM +0000, Nadav Amit wrote: > > > On Feb 25, 2021, at 4:16 AM, Matthew Wilcox wrote: > > > > On Wed, Feb 24, 2021 at 11:29:04PM -0800, Nadav Amit wrote: > >> Just as applications can use prefetch instructions to overlap > >> computations and memory accesses, applications may want to overlap the > >> page-faults and compute or overlap the I/O accesses that are required > >> for page-faults of different pages. > > > > Isn't this madvise(MADV_WILLNEED)? > > Good point that I should have mentioned. In a way prefetch_page() a > combination of mincore() and MADV_WILLNEED. > > There are 4 main differences from MADV_WILLNEED: > > 1. Much lower invocation cost if the readahead is not needed: this allows > to prefetch pages more abundantly. That seems like something that could be fixed in libc -- if we add a page prefetch vdso call, an application calling posix_madvise() could be implemented by calling this fast path. Assuming the performance increase justifies this extra complexity. > 2. Return value: return value tells you whether the page is accessible. > This makes it usable for coroutines, for instance. In this regard the > call is more similar to mincore() than MADV_WILLNEED. I don't quite understand the programming model you're describing here. > 3. The PTEs are mapped if the pages are already present in the > swap/page-cache, preventing an additional page-fault just to map them. We could enhance madvise() to do this, no? > 4. Avoiding heavy-weight reclamation on low memory (this may need to > be selective, and can be integrated with MADV_WILLNEED). Likewise. I don't want to add a new Linux-specific call when there's already a POSIX interface that communicates the exact same thing. The return value seems like the only problem. https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_madvise.html