From patchwork Thu Mar 4 16:31:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12116575 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 2C275C433DB for ; Thu, 4 Mar 2021 16:31:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BC6FD64F43 for ; Thu, 4 Mar 2021 16:31:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC6FD64F43 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 036136B000D; Thu, 4 Mar 2021 11:31:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 00CC56B0023; Thu, 4 Mar 2021 11:31:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D78CF6B0024; Thu, 4 Mar 2021 11:31:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0062.hostedemail.com [216.40.44.62]) by kanga.kvack.org (Postfix) with ESMTP id BA9E36B000D for ; Thu, 4 Mar 2021 11:31:54 -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 7A8C3180C7170 for ; Thu, 4 Mar 2021 16:31:54 +0000 (UTC) X-FDA: 77882733348.14.EA2726A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 13A15E0011FF for ; Thu, 4 Mar 2021 16:31:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614875509; 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=p9IaoeJsCRUG1LLipzY/Smbk9hrubLxR/AALEDsivN8=; b=fax4GG7qORGgVc5nUFSlogWww9iQ3FtpMP/UK8iLPCPSNyCU0Xf5x721gutLkKnE/pn+Dy a3OS95BA9ycm1KXf3YVPTbTwV5hVr9NJN9ZsMIwpgJ65bX7vSYoI7zZfVc5r5cJaDdqLKe RaWyj9hcpTs08u8NMMMngSNDFpnUkAs= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-561-EWfmw9usPm--uLXxaghmqw-1; Thu, 04 Mar 2021 11:31:46 -0500 X-MC-Unique: EWfmw9usPm--uLXxaghmqw-1 Received: by mail-qv1-f72.google.com with SMTP id h12so16804125qvm.9 for ; Thu, 04 Mar 2021 08:31:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p9IaoeJsCRUG1LLipzY/Smbk9hrubLxR/AALEDsivN8=; b=T9Zf9HwPViNwoAnCRZZ8smTq2p9gD3rhbs7UXpRPSjsSvPmMQRVWfE4UhI514I85GE dJfnlV+3ZlzGFhAVMOHJIlxgJ3XgBrPrOHzpwkV5OC/CJ0D/62gD+yaiMbx64WB0lzp5 O4yFxADRx1FLNwYU0LRVpcGDqBIr3+DvgICagEd1Vemd2VvWKfiROAsJ2o0puOJmKlJ+ JDOeosp+xv7tJuzIsVjsfnOKBZn1NeXwagwRlCpLLSG2IpUr9HT5j3b5Tzf7RoOZDeCH 5cp8Jax0ziRRsRmllPlx3mJ6vQzzgjtaAPglNRCNsZ6a4CBcJuZddUSZHvuXXCfNmMHz 40zg== X-Gm-Message-State: AOAM530IUZGyWJ3mg26yc9xMLCb6wJ3U7TKgkH6iWjVRholhx+MhYAIO OC40qxtqsoxWkkjZImT5polbXilcQ/CFsyUbuTRDTkIgE9rvvp3qjDWV44QNiEAWBzxv/4L2BsS BLKWFx4kxHGg= X-Received: by 2002:a0c:b9a2:: with SMTP id v34mr4525201qvf.17.1614875505656; Thu, 04 Mar 2021 08:31:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwSsP+FFMDB/tnZzXdHZPnv+zAKYJ770BYZdyp3Xn0vfNLHMmlKp8dtkSsQcoMvksDc0fVEbA== X-Received: by 2002:a0c:b9a2:: with SMTP id v34mr4525179qvf.17.1614875505427; Thu, 04 Mar 2021 08:31:45 -0800 (PST) Received: from xz-x1.redhat.com (bras-vprn-toroon474qw-lp130-25-174-95-95-253.dsl.bell.ca. [174.95.95.253]) by smtp.gmail.com with ESMTPSA id r2sm51753qti.4.2021.03.04.08.31.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 08:31:44 -0800 (PST) From: Peter Xu To: linux-man@vger.kernel.org Cc: Alejandro Colomar , Nadav Amit , Andrea Arcangeli , linux-kernel@vger.kernel.org, Michael Kerrisk , Mike Rapoport , Axel Rasmussen , Andrew Morton , Linux MM Mailing List , peterx@redhat.com Subject: [PATCH v2 1/4] userfaultfd.2: Add UFFD_FEATURE_THREAD_ID docs Date: Thu, 4 Mar 2021 11:31:37 -0500 Message-Id: <20210304163140.543171-2-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210304163140.543171-1-peterx@redhat.com> References: <20210304163140.543171-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Stat-Signature: y63sc7ttp43ktyn4nhupgprzocr59ezs X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 13A15E0011FF Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf30; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614875509-356515 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: UFFD_FEATURE_THREAD_ID is supported since Linux 4.14. Signed-off-by: Peter Xu --- man2/userfaultfd.2 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/man2/userfaultfd.2 b/man2/userfaultfd.2 index e7dc9f813..0cd426a8a 100644 --- a/man2/userfaultfd.2 +++ b/man2/userfaultfd.2 @@ -77,6 +77,13 @@ When the last file descriptor referring to a userfaultfd object is closed, all memory ranges that were registered with the object are unregistered and unread events are flushed. .\" +.PP +Since Linux 4.14, userfaultfd page fault message can selectively embed faulting +thread ID information into the fault message. One needs to enable this feature +explicitly using the +.BR UFFD_FEATURE_THREAD_ID +feature bit when initializing the userfaultfd context. By default, thread ID +reporting is diabled. .SS Usage The userfaultfd mechanism is designed to allow a thread in a multithreaded program to perform user-space paging for the other threads in the process. @@ -229,6 +236,9 @@ struct uffd_msg { struct { __u64 flags; /* Flags describing fault */ __u64 address; /* Faulting address */ + union { + __u32 ptid; /* Thread ID of the fault */ + } feat; } pagefault; struct { /* Since Linux 4.11 */ @@ -358,6 +368,9 @@ otherwise it is a read fault. .\" UFFD_PAGEFAULT_FLAG_WP is not yet supported. .RE .TP +.I pagefault.feat.pid +The thread ID that triggered the page fault. +.TP .I fork.ufd The file descriptor associated with the userfault object created for the child created by