Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3056506pxj; Mon, 10 May 2021 17:39:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/Dj68QvuHIepwQUpU3+eIyA5rg3zPoFDNp4udL24EEOIxlhXW1c5cjMNbE7+ayh3l+tWF X-Received: by 2002:a5e:880b:: with SMTP id l11mr19961802ioj.42.1620693543558; Mon, 10 May 2021 17:39:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620693543; cv=none; d=google.com; s=arc-20160816; b=kCiDO59n17L8kzYhx0+h0PcL/TKQSYuS9exlinuwn4wnx4XOCg0oGy432ztZVusJ/a QeW1iUzQxn31FkK2zGquQiLwKgfsGKx8yrOS/ZKwyALZr0jInFKRbpBVfuQo+Xa5+r7X cgyR7l2FSFzPPB0ktZ7wr5lNQfkyPhrKAJ9s/aw74EOj6S+rFcilnGsKjKqSPE4Kf/9R G3BZtWTYGZMAUHTvPNwrC0E4Lae0pvNPL8C5jw30uNw2T6IEVMKfz954nKpJOtx7L8zs lWPRa0CeIMuBGrtvJB8Fw5Vo4dgC88im6ubDs0NES7M4Iy81YOaiZYlsTa1Vwjgk1Q5P B/yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:mime-version :dkim-signature; bh=09JM7Ox7xZYPPFB9C47KgCoGB3BmJhJc+28H+wSrtLo=; b=vsNyb3TH+5DqKIssZKDU+VpXlzCZ4L+kv3eoo2kIgR+H1hrhxMlg60AFhx1b2t2cMh gOW9LU54U/USiyWxLrFNA8wGlnuA/UyhMqc7ufD/YaXpYuffzw/wj9LkxXvPzxKYPua/ g00r8MbgwWV/oV8z/3n84CG0DXAQzaEWr1+wszBd9rcSywKYzDYzki04/y+RFIBtMcKz gl6JXY2bFxM2qWRSRlOlzLxuNVvBukadSZ5feIXgW8ztC7K2JZG26XKTjyfkIKWSYgvc H9tdbpGK3OlMCoQY91IFFxUlj6W9ag+7e08stSYkEQb7eI88lPYTJCBmfmDh/+Csa6nq Nxcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pernos.co header.s=google header.b=E2Tks3il; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pernos.co Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y14si10576499ila.26.2021.05.10.17.38.50; Mon, 10 May 2021 17:39:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@pernos.co header.s=google header.b=E2Tks3il; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pernos.co Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229949AbhEKAjN (ORCPT + 99 others); Mon, 10 May 2021 20:39:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229628AbhEKAjL (ORCPT ); Mon, 10 May 2021 20:39:11 -0400 Received: from mail-vs1-xe2f.google.com (mail-vs1-xe2f.google.com [IPv6:2607:f8b0:4864:20::e2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59FC5C061574 for ; Mon, 10 May 2021 17:38:05 -0700 (PDT) Received: by mail-vs1-xe2f.google.com with SMTP id u188so1863685vsu.8 for ; Mon, 10 May 2021 17:38:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pernos.co; s=google; h=mime-version:from:date:message-id:subject:to:cc; bh=09JM7Ox7xZYPPFB9C47KgCoGB3BmJhJc+28H+wSrtLo=; b=E2Tks3il867yf5r40wJV4wl1jydz/BQ/jSXsJlEj+A3xBfxLoGfye8yNOpDoRQqY4j ljgkaXABcgrtDZ/OUzvG3H99tTrgsm2ZgpFgHBaNMCPlHgSLxQVf2/4B/MQvyf2CNiNa EyNZQnt2DDbL/XNCmvSmgCKcatkvqH4SYWJb4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=09JM7Ox7xZYPPFB9C47KgCoGB3BmJhJc+28H+wSrtLo=; b=kOOl6HFE5Y1EOPHoNzc1/8wFv1adDXwiIzPFYW03Go6+b8P8T1H0UoNONkjCy7p2Pi Y8MAFo52TxQh9RrH7Y6a1LXo8Jorfcl4a/DgqnyU9wQR2LhNMeSRvyij1M9TOqqc5pc4 afLZex59yzP+9BNSLJoRP2YLtOfZAF42hJ+IMvBuULX2LcTYi6WA1jJS2ivF5JJsN64r R/pPa5ZblXq4000L6PA5FEBXDX/MKJ0Jo+sc2p/ix8nvrILAsMJ7PNhBJUfkTqyN2brB Us95eWVeMUawh7d69maGvI4/pl9zvowj1FY/V8pSWkoSJSl94pxZffxzx4pu4buf3056 Vlpw== X-Gm-Message-State: AOAM532lSOvYNLpLLzPwk2VibEZPqTnvxPzlP1zvrHBMOoEodCo6c485 DQob5UGkX52tCt41n+uia8gcQc+s2LhWfIz4 X-Received: by 2002:a67:f2c7:: with SMTP id a7mr22519966vsn.4.1620693484299; Mon, 10 May 2021 17:38:04 -0700 (PDT) Received: from mail-vs1-f47.google.com (mail-vs1-f47.google.com. [209.85.217.47]) by smtp.gmail.com with ESMTPSA id f6sm2051585vsh.31.2021.05.10.17.38.03 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 May 2021 17:38:03 -0700 (PDT) Received: by mail-vs1-f47.google.com with SMTP id u188so1863661vsu.8 for ; Mon, 10 May 2021 17:38:03 -0700 (PDT) X-Received: by 2002:a67:f815:: with SMTP id l21mr5306470vso.34.1620693482885; Mon, 10 May 2021 17:38:02 -0700 (PDT) MIME-Version: 1.0 From: "Robert O'Callahan" Date: Tue, 11 May 2021 12:37:51 +1200 X-Gmail-Original-Message-ID: Message-ID: Subject: Userspace notifications for observing userfaultfd faults To: Andrea Arcangeli , Axel Rasmussen , Andrew Morton , Hugh Dickins , Peter Xu , Ingo Molnar Cc: Linux-MM , linux-kernel@vger.kernel.org, Kyle Huey Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For rr (https://rr-project.org) to support recording and replaying applications that use userfaultfd, we need to observe that a task we are controlling has blocked on a userfault. Currently this is very difficult to do, especially if a task blocks on a userfault on a page where some other task has already triggered a userfault, so no new userfaultfd event is generated. We also need to observe which page has been faulted on so we can determine when the fault has been serviced and the task is ready to run again. I've tried to find workarounds with existing APIs and it doesn't seem tractable. See https://github.com/rr-debugger/rr/issues/2852#issuecomment-837514946 for some thoughts about that. It seems to me that a sufficient API for us would be a new software perf event, e.g. PERF_COUNT_SW_USERFAULTS, with an associated PERF_SAMPLE_ADDR that would give us the address of the page. Does that sounds like a reasonable thing to add? Robert O'Callahan