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=-2.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 34E47C433E0 for ; Thu, 25 Feb 2021 08:52:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9BFFE64EDC for ; Thu, 25 Feb 2021 08:52:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9BFFE64EDC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0FA6F8D000F; Thu, 25 Feb 2021 03:52:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0AB3E8D0005; Thu, 25 Feb 2021 03:52:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F050D8D000F; Thu, 25 Feb 2021 03:52:24 -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 DAEEE8D0005 for ; Thu, 25 Feb 2021 03:52:24 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 9350B81EDBC1 for ; Thu, 25 Feb 2021 08:52:24 +0000 (UTC) X-FDA: 77856173808.15.99668BF Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf02.hostedemail.com (Postfix) with ESMTP id 60DC5407F8F3 for ; Thu, 25 Feb 2021 08:52:10 +0000 (UTC) Received: by mail-pl1-f170.google.com with SMTP id b8so6694plh.0 for ; Thu, 25 Feb 2021 00:52:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=d5/TPW++NCSJGRNsalsS5yFTJhGv1Cm8PSt/sN4M8bc=; b=bhTwLqqMLp3/+L2qX3Z9XIZoHOETK8uDKwtkpsnfzS51Sjq+nyIxTdm4NgUKUxdgJ7 03XXM4tOpPFUFFKRVihnZz7a3YeZbLJhRmN7ENtXwV/ZEncILLjlkBaTceBdJhCUq/CZ +1mbDcoeit8x1mlvC3SXOL3oXu3IfViQ9wz4pL9I0ZonAXJX92aPutVA1Q4hF97cx4Tn u2XEOJK4Dgo1hL42DHzE0EW1bWxXhysd+PLu8otIBF8BVveYTkzexflPN9A9Q71hkmhb D4AdK3LH4l/XDeLEqspLE1BoACNQ+siESoWUGB1YxQyNEHg/yWq19zq/tneS7pL4+Pkz 37bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=d5/TPW++NCSJGRNsalsS5yFTJhGv1Cm8PSt/sN4M8bc=; b=YKJMWro8LXAG3pVk5fBsmZ7D9/6I8yf+aKQvt4An6C0pxSc1RpqWcF0x6qphQNe0ob bI5+TlhVyuKo4VlNiV+2VRbrYDmk9omaYGbJhTRzpEIJbImW2L9T9iAcy2ZVOkAcecFZ bgI/DdCxondUG6BK9P2AOwXRj7P9MTj90tSY2UEsS4AfKi4XEXXrorjivklK6fJJTaZ1 YpQY3SsxjC8KC0MfOgScOrYJ5qx02O+xVwsmtNgcS0Xg8JP5t2YgB/7JIIopqCEg/LfO JVWbR4H0Ff9kNkJhdMdUgbztZD0D6HsVExN4J1UlkWnaEXtVLyKW8na5EkHE04iVIXd3 e2dA== X-Gm-Message-State: AOAM532KHi07LxT4wqr5IKdvDHPRcUi9AhsarcMeel+CH6A9Pjvv/m65 L2bz3mAMZpzJiOYw2XGqmMU= X-Google-Smtp-Source: ABdhPJz2vUt3hhPmsQecYZf2VgwndgcBUEDQILC3K4F8ZVdDYhJwf1acRLNE6t6/jJ3rkGo29rT//A== X-Received: by 2002:a17:902:d2c9:b029:e1:8692:aa7c with SMTP id n9-20020a170902d2c9b02900e18692aa7cmr2226071plc.21.1614243142998; Thu, 25 Feb 2021 00:52:22 -0800 (PST) Received: from [192.168.88.245] (c-24-6-216-183.hsd1.ca.comcast.net. [24.6.216.183]) by smtp.gmail.com with ESMTPSA id 74sm5432737pfw.53.2021.02.25.00.52.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Feb 2021 00:52:21 -0800 (PST) From: Nadav Amit Message-Id: <64538CCF-AD11-43C2-9632-E054301F9E6D@gmail.com> Content-Type: multipart/signed; boundary="Apple-Mail=_0E5A07C0-7909-4A31-A67D-30FFA2DD5115"; protocol="application/pgp-signature"; micalg=pgp-sha256 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Subject: Re: [RFC 0/6] x86: prefetch_page() vDSO call Date: Thu, 25 Feb 2021 00:52:19 -0800 In-Reply-To: Cc: Linux-MM , LKML , Hugh Dickins , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Sean Christopherson , Andrew Morton , x86@kernel.org To: Peter Zijlstra References: <20210225072910.2811795-1-namit@vmware.com> X-Mailer: Apple Mail (2.3654.60.0.2.21) X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 60DC5407F8F3 X-Stat-Signature: x8m1uskz7usw4icucaqpmgis8atm8m19 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf02; identity=mailfrom; envelope-from=""; helo=mail-pl1-f170.google.com; client-ip=209.85.214.170 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614243130-904755 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: --Apple-Mail=_0E5A07C0-7909-4A31-A67D-30FFA2DD5115 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Feb 25, 2021, at 12:40 AM, Peter Zijlstra = wrote: >=20 > On Wed, Feb 24, 2021 at 11:29:04PM -0800, Nadav Amit wrote: >> From: Nadav Amit >>=20 >> 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. >>=20 >> Applications can use multiple threads and cores for this matter, by >> running one thread that prefetches the data (i.e., faults in the = data) >> and another that does the compute, but this scheme is inefficient. = Using >> mincore() can tell whether a page is mapped, but might not tell = whether >> the page is in the page-cache and does not fault in the data. >>=20 >> Introduce prefetch_page() vDSO-call to prefetch, i.e. fault-in memory >> asynchronously. The semantic of this call is: try to prefetch a page = of >> in a given address and return zero if the page is accessible = following >> the call. Start I/O operations to retrieve the page if such = operations >> are required and there is no high memory pressure that might = introduce >> slowdowns. >>=20 >> Note that as usual the page might be paged-out at any point and >> therefore, similarly to mincore(), there is no guarantee that the = page >> will be present at the time that the user application uses the data = that >> resides on the page. Nevertheless, it is expected that in the vast >> majority of the cases this would not happen, since prefetch_page() >> accesses the page and therefore sets the PTE access-bit (if it is >> clear). >>=20 >> The implementation is as follows. The vDSO code accesses the data, >> triggering a page-fault it is not present. The handler detects based = on >> the instruction pointer that this is an asynchronous-#PF, using the >> recently introduce vDSO exception tables. If the page can be brought >> without waiting (e.g., the page is already in the page-cache), the >> kernel handles the fault and returns success (zero). If there is = memory >> pressure that prevents the proper handling of the fault (i.e., = requires >> heavy-weight reclamation) it returns a failure. Otherwise, it starts = an >> I/O to bring the page and returns failure. >>=20 >> Compilers can be extended to issue the prefetch_page() calls when >> needed. >=20 > Interesting, but given we've been removing explicit prefetch from some > parts of the kernel how useful is this in actual use? I'm thinking = there > should at least be a real user and performance numbers with this = before > merging. Can you give me a reference to the =E2=80=9Cremoving explicit prefetch = from some parts of the kernel=E2=80=9D? I will work on an llvm/gcc plugin to provide some performance numbers. I wanted to make sure that the idea is not a complete obscenity first. --Apple-Mail=_0E5A07C0-7909-4A31-A67D-30FFA2DD5115 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEESJL3osl5Ymx/w9I1HaAqSabaD1oFAmA3ZUMACgkQHaAqSaba D1rCig//TIRdRCRBpIkezqG9RtBiN9wOTWkZrUiUySmoArI/tBwzTpJi14TO9Z3x RKTgzeztBk0YBAZ+bwqpRHg5xn3xBMzD12+E/X6rQc/TW5aKhV4PiQaA8zfGnL+M +KYFWzLU9vKPm0KRTD9KG4PCQbCISdNxw/knGvEqPVJHEDLHvZc/DamK8eW1E7kU W8HnJXEoivWdq+Csf1Al8XJCsOLnj+7rbLiWErVXsh71JJV7imPW7lIJfAdWvPQV O9bux93Xs8zW80YjQaOTIG0GTOWEuimKalL3ULOoyzst6zVp3k/dlut4jjRGwwK4 pc/KRe/o2+j2wcFQ4RZcSvsZbF3LFXcyCuXfoTuUEBnH0CG5I9s3Hu/ALOnMnhCo nQ8LUnBgKqdi5F4A8/vcoNKySZVaB6L44tmm6mz2R+nF6u6xO9zRVHUfK+O/tKQ7 u3240HrMThlAqewwJlKFOlvi/jyTPkN0Yul+X+poxhJARNkXozO6QmCIExR/I6EE uIR6INUbmBgyk3mThay+jL8m861M/qwmjPz99/hAUwFz+FnwDAleFooWU97vzWSK Tothgl199/oPmtyphtlvWmE4hKNK+a/DEgdVBlTBn8pOVxJJKmj9YoOlL3AsZru1 1kVC1Vd26a+iihb4VpJXrJKEuzSg9PsDAmYJ/Qc+6NlbDPtH1aI= =tmsY -----END PGP SIGNATURE----- --Apple-Mail=_0E5A07C0-7909-4A31-A67D-30FFA2DD5115--