From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f70.google.com (mail-pg0-f70.google.com [74.125.83.70]) by kanga.kvack.org (Postfix) with ESMTP id 2080E6B039F for ; Mon, 3 Apr 2017 05:33:13 -0400 (EDT) Received: by mail-pg0-f70.google.com with SMTP id m66so136723587pga.15 for ; Mon, 03 Apr 2017 02:33:13 -0700 (PDT) Received: from mailout3.w1.samsung.com (mailout3.w1.samsung.com. [210.118.77.13]) by mx.google.com with ESMTPS id z78si13777284pfi.308.2017.04.03.02.33.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 03 Apr 2017 02:33:12 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0ONT008CCUJ89760@mailout3.w1.samsung.com> for linux-mm@kvack.org; Mon, 03 Apr 2017 10:33:08 +0100 (BST) From: Alexey Perevalov Subject: [PATCH v3] Illuminate thread id to user space Date: Mon, 03 Apr 2017 12:32:35 +0300 Message-id: <1491211956-6095-1-git-send-email-a.perevalov@samsung.com> References: Sender: owner-linux-mm@kvack.org List-ID: To: Andrea Arcangeli , linux-mm@kvack.org Cc: Alexey Perevalov , rppt@linux.vnet.ibm.com, mike.kravetz@oracle.com, dgilbert@redhat.com Hi Andrea, This is third version of the patch. Modifications since previous versions: (v3 -> v2) - type of ptid now is __u32. As you suggested. (v2 -> v1) - process thread id is provided only when it was requested with UFFD_FEATURE_THREAD_ID bit. - pid from namespace is provided, so locking thread's gettid in namespace and msg.arg.pagefault.ptid will be equal. This patch is based on git://git.kernel.org/pub/scm/linux/kernel/git/andrea/aa.git userfault branch. HEAD commit is "userfaultfd: switch to exclusive wakeup for blocking reads" Alexey Perevalov (1): userfaultfd: provide pid in userfault msg fs/userfaultfd.c | 8 ++++++-- include/uapi/linux/userfaultfd.h | 8 +++++++- 2 files changed, 13 insertions(+), 3 deletions(-) -- 2.7.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f72.google.com (mail-pg0-f72.google.com [74.125.83.72]) by kanga.kvack.org (Postfix) with ESMTP id 43DBA6B03A0 for ; Mon, 3 Apr 2017 05:33:23 -0400 (EDT) Received: by mail-pg0-f72.google.com with SMTP id m1so136562115pgd.13 for ; Mon, 03 Apr 2017 02:33:23 -0700 (PDT) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com. [210.118.77.12]) by mx.google.com with ESMTPS id m63si13773237pld.36.2017.04.03.02.33.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 03 Apr 2017 02:33:22 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0ONT004N3UJJKX60@mailout2.w1.samsung.com> for linux-mm@kvack.org; Mon, 03 Apr 2017 10:33:19 +0100 (BST) From: Alexey Perevalov Subject: [PATCH v3] userfaultfd: provide pid in userfault msg Date: Mon, 03 Apr 2017 12:32:36 +0300 Message-id: <1491211956-6095-2-git-send-email-a.perevalov@samsung.com> In-reply-to: <1491211956-6095-1-git-send-email-a.perevalov@samsung.com> References: <1491211956-6095-1-git-send-email-a.perevalov@samsung.com> Sender: owner-linux-mm@kvack.org List-ID: To: Andrea Arcangeli , linux-mm@kvack.org Cc: Alexey Perevalov , rppt@linux.vnet.ibm.com, mike.kravetz@oracle.com, dgilbert@redhat.com It could be useful for calculating downtime during postcopy live migration per vCPU. Side observer or application itself will be informed about proper task's sleep during userfaultfd processing. Process's thread id is being provided when user requeste it by setting UFFD_FEATURE_THREAD_ID bit into uffdio_api.features. Signed-off-by: Alexey Perevalov --- fs/userfaultfd.c | 8 ++++++-- include/uapi/linux/userfaultfd.h | 8 +++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 24fd7e0..14c30d4 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -180,7 +180,8 @@ static inline void msg_init(struct uffd_msg *msg) static inline struct uffd_msg userfault_msg(unsigned long address, unsigned int flags, - unsigned long reason) + unsigned long reason, + unsigned int features) { struct uffd_msg msg; msg_init(&msg); @@ -204,6 +205,8 @@ static inline struct uffd_msg userfault_msg(unsigned long address, * write protect fault. */ msg.arg.pagefault.flags |= UFFD_PAGEFAULT_FLAG_WP; + if (features & UFFD_FEATURE_THREAD_ID) + msg.arg.pagefault.ptid = task_pid_vnr(current); return msg; } @@ -408,7 +411,8 @@ int handle_userfault(struct vm_fault *vmf, unsigned long reason) init_waitqueue_func_entry(&uwq.wq, userfaultfd_wake_function); uwq.wq.private = current; - uwq.msg = userfault_msg(vmf->address, vmf->flags, reason); + uwq.msg = userfault_msg(vmf->address, vmf->flags, reason, + ctx->features); uwq.ctx = ctx; uwq.waken = false; diff --git a/include/uapi/linux/userfaultfd.h b/include/uapi/linux/userfaultfd.h index 819e235..ff8d0d2 100644 --- a/include/uapi/linux/userfaultfd.h +++ b/include/uapi/linux/userfaultfd.h @@ -24,7 +24,8 @@ UFFD_FEATURE_EVENT_REMOVE | \ UFFD_FEATURE_EVENT_UNMAP | \ UFFD_FEATURE_MISSING_HUGETLBFS | \ - UFFD_FEATURE_MISSING_SHMEM) + UFFD_FEATURE_MISSING_SHMEM | \ + UFFD_FEATURE_THREAD_ID) #define UFFD_API_IOCTLS \ ((__u64)1 << _UFFDIO_REGISTER | \ (__u64)1 << _UFFDIO_UNREGISTER | \ @@ -83,6 +84,7 @@ struct uffd_msg { struct { __u64 flags; __u64 address; + __u32 ptid; } pagefault; struct { @@ -158,6 +160,9 @@ struct uffdio_api { * UFFD_FEATURE_MISSING_SHMEM works the same as * UFFD_FEATURE_MISSING_HUGETLBFS, but it applies to shmem * (i.e. tmpfs and other shmem based APIs). + * + * UFFD_FEATURE_THREAD_ID pid of the page faulted task_struct will + * be returned, if feature is not requested 0 will be returned. */ #define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1<<0) #define UFFD_FEATURE_EVENT_FORK (1<<1) @@ -166,6 +171,7 @@ struct uffdio_api { #define UFFD_FEATURE_MISSING_HUGETLBFS (1<<4) #define UFFD_FEATURE_MISSING_SHMEM (1<<5) #define UFFD_FEATURE_EVENT_UNMAP (1<<6) +#define UFFD_FEATURE_THREAD_ID (1<<7) __u64 features; __u64 ioctls; -- 2.7.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f72.google.com (mail-pg0-f72.google.com [74.125.83.72]) by kanga.kvack.org (Postfix) with ESMTP id C85356B039F for ; Mon, 3 Apr 2017 05:38:44 -0400 (EDT) Received: by mail-pg0-f72.google.com with SMTP id 68so135242233pgj.23 for ; Mon, 03 Apr 2017 02:38:44 -0700 (PDT) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com. [210.118.77.12]) by mx.google.com with ESMTPS id u59si13781731plb.138.2017.04.03.02.38.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 03 Apr 2017 02:38:43 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0ONT009IJUSGWD60@mailout2.w1.samsung.com> for linux-mm@kvack.org; Mon, 03 Apr 2017 10:38:40 +0100 (BST) Subject: Re: [PATCH v3] please don't see patch set From: Alexey Perevalov Message-id: <63dd9e34-3ae9-e320-60a5-a5619dee402b@samsung.com> Date: Mon, 03 Apr 2017 12:38:35 +0300 MIME-version: 1.0 In-reply-to: <1491211956-6095-1-git-send-email-a.perevalov@samsung.com> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit References: <1491211956-6095-1-git-send-email-a.perevalov@samsung.com> Sender: owner-linux-mm@kvack.org List-ID: To: Andrea Arcangeli , linux-mm@kvack.org Cc: rppt@linux.vnet.ibm.com, mike.kravetz@oracle.com, dgilbert@redhat.com I'm so sorry, commit message in patch is wrong. I'll resend On 04/03/2017 12:32 PM, Alexey Perevalov wrote: > Hi Andrea, > > This is third version of the patch. Modifications since previous versions: > (v3 -> v2) > - type of ptid now is __u32. As you suggested. > > (v2 -> v1) > - process thread id is provided only when it was requested with > UFFD_FEATURE_THREAD_ID bit. > - pid from namespace is provided, so locking thread's gettid in namespace > and msg.arg.pagefault.ptid will be equal. > > This patch is based on > git://git.kernel.org/pub/scm/linux/kernel/git/andrea/aa.git userfault branch. > HEAD commit is "userfaultfd: switch to exclusive wakeup for blocking reads" > > > Alexey Perevalov (1): > userfaultfd: provide pid in userfault msg > > fs/userfaultfd.c | 8 ++++++-- > include/uapi/linux/userfaultfd.h | 8 +++++++- > 2 files changed, 13 insertions(+), 3 deletions(-) > -- Best regards, Alexey Perevalov -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f72.google.com (mail-pg0-f72.google.com [74.125.83.72]) by kanga.kvack.org (Postfix) with ESMTP id 8276B6B0397 for ; Mon, 3 Apr 2017 05:42:44 -0400 (EDT) Received: by mail-pg0-f72.google.com with SMTP id n5so136954489pgd.19 for ; Mon, 03 Apr 2017 02:42:44 -0700 (PDT) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com. [210.118.77.11]) by mx.google.com with ESMTPS id v5si13784510pgv.254.2017.04.03.02.42.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 03 Apr 2017 02:42:43 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0ONT00187UZ4U370@mailout1.w1.samsung.com> for linux-mm@kvack.org; Mon, 03 Apr 2017 10:42:40 +0100 (BST) Subject: Re: [PATCH v3] please don't see patch set From: Alexey Perevalov Message-id: <166e50fa-c55c-d54d-161d-acaececca59e@samsung.com> Date: Mon, 03 Apr 2017 12:42:37 +0300 MIME-version: 1.0 In-reply-to: <63dd9e34-3ae9-e320-60a5-a5619dee402b@samsung.com> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit References: <1491211956-6095-1-git-send-email-a.perevalov@samsung.com> <63dd9e34-3ae9-e320-60a5-a5619dee402b@samsung.com> Sender: owner-linux-mm@kvack.org List-ID: To: Andrea Arcangeli , linux-mm@kvack.org Cc: Mike Kravetz , rppt@linux.vnet.ibm.com It's all correct with commit message, something was wrong with my email client. Sorry again ). On 04/03/2017 12:38 PM, Alexey Perevalov wrote: > I'm so sorry, commit message in patch is wrong. > > I'll resend > > On 04/03/2017 12:32 PM, Alexey Perevalov wrote: >> Hi Andrea, >> >> This is third version of the patch. Modifications since previous >> versions: >> (v3 -> v2) >> - type of ptid now is __u32. As you suggested. >> >> (v2 -> v1) >> - process thread id is provided only when it was requested with >> UFFD_FEATURE_THREAD_ID bit. >> - pid from namespace is provided, so locking thread's gettid in >> namespace >> and msg.arg.pagefault.ptid will be equal. >> >> This patch is based on >> git://git.kernel.org/pub/scm/linux/kernel/git/andrea/aa.git userfault >> branch. >> HEAD commit is "userfaultfd: switch to exclusive wakeup for blocking >> reads" >> >> >> Alexey Perevalov (1): >> userfaultfd: provide pid in userfault msg >> >> fs/userfaultfd.c | 8 ++++++-- >> include/uapi/linux/userfaultfd.h | 8 +++++++- >> 2 files changed, 13 insertions(+), 3 deletions(-) >> > > -- Best regards, Alexey Perevalov -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk0-f197.google.com (mail-qk0-f197.google.com [209.85.220.197]) by kanga.kvack.org (Postfix) with ESMTP id 7C41D6B0038 for ; Tue, 4 Apr 2017 15:04:24 -0400 (EDT) Received: by mail-qk0-f197.google.com with SMTP id p68so34255902qkf.20 for ; Tue, 04 Apr 2017 12:04:24 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id r51si15826482qta.118.2017.04.04.12.04.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Apr 2017 12:04:23 -0700 (PDT) Date: Tue, 4 Apr 2017 21:04:19 +0200 From: Andrea Arcangeli Subject: Re: [PATCH v3] userfaultfd: provide pid in userfault msg Message-ID: <20170404190419.GA5081@redhat.com> References: <1491211956-6095-1-git-send-email-a.perevalov@samsung.com> <1491211956-6095-2-git-send-email-a.perevalov@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1491211956-6095-2-git-send-email-a.perevalov@samsung.com> Sender: owner-linux-mm@kvack.org List-ID: To: Alexey Perevalov Cc: linux-mm@kvack.org, rppt@linux.vnet.ibm.com, mike.kravetz@oracle.com, dgilbert@redhat.com Hello Alexey, v3 looks great to me. Reviewed-by: Andrea Arcangeli On top of v3 I think we could add this to make it more obvious to the developer tpid isn't necessarily there by just looking at the data structure. This is purely cosmetical, so feel free to comment if you disagree. I'm also fine to add an anonymous union later if a new usage for those bytes emerges (ABI side doesn't change anything which is why this could be done later as well, only the API changes here but then I doubt we'd break the API later for this, so if we want pagefault.feat.* it probably should be done right now). Thanks, Andrea From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f197.google.com (mail-pf0-f197.google.com [209.85.192.197]) by kanga.kvack.org (Postfix) with ESMTP id D89916B03C4 for ; Wed, 5 Apr 2017 08:42:26 -0400 (EDT) Received: by mail-pf0-f197.google.com with SMTP id s22so6030840pfs.0 for ; Wed, 05 Apr 2017 05:42:26 -0700 (PDT) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com. [210.118.77.12]) by mx.google.com with ESMTPS id h7si20540146pgn.97.2017.04.05.05.42.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 05 Apr 2017 05:42:26 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0ONX00E5ESMMDG00@mailout2.w1.samsung.com> for linux-mm@kvack.org; Wed, 05 Apr 2017 13:42:22 +0100 (BST) Subject: Re: [PATCH v3] userfaultfd: provide pid in userfault msg From: Alexey Perevalov Message-id: Date: Wed, 05 Apr 2017 15:42:18 +0300 MIME-version: 1.0 In-reply-to: <20170404190419.GA5081@redhat.com> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit References: <1491211956-6095-1-git-send-email-a.perevalov@samsung.com> <1491211956-6095-2-git-send-email-a.perevalov@samsung.com> <20170404190419.GA5081@redhat.com> Sender: owner-linux-mm@kvack.org List-ID: To: Andrea Arcangeli Cc: linux-mm@kvack.org, rppt@linux.vnet.ibm.com, mike.kravetz@oracle.com, dgilbert@redhat.com On 04/04/2017 10:04 PM, Andrea Arcangeli wrote: > Hello Alexey, > > v3 looks great to me. > > Reviewed-by: Andrea Arcangeli > > On top of v3 I think we could add this to make it more obvious to the > developer tpid isn't necessarily there by just looking at the data > structure. > > This is purely cosmetical, so feel free to comment if you > disagree. Why not, I agree with this change. > > I'm also fine to add an anonymous union later if a new usage for those > bytes emerges (ABI side doesn't change anything which is why this > could be done later as well, only the API changes here but then I > doubt we'd break the API later for this, so if we want pagefault.feat.* > it probably should be done right now). > > Thanks, > Andrea > > >From 901951f5a0456aa07d4fb1231cf2b1d352beb36f Mon Sep 17 00:00:00 2001 > From: Andrea Arcangeli > Date: Tue, 4 Apr 2017 20:50:54 +0200 > Subject: [PATCH 1/1] userfaultfd: provide pid in userfault msg - add feat > union > > No ABI change, but this will make it more explicit to software that > ptid is only available if requested by passing UFFD_FEATURE_THREAD_ID > to UFFDIO_API. The fact it's a union will also self document it > shouldn't be taken for granted there's a tpid there. > > Signed-off-by: Andrea Arcangeli > --- > include/uapi/linux/userfaultfd.h | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/include/uapi/linux/userfaultfd.h b/include/uapi/linux/userfaultfd.h > index ff8d0d2..524b860 100644 > --- a/include/uapi/linux/userfaultfd.h > +++ b/include/uapi/linux/userfaultfd.h > @@ -84,7 +84,9 @@ struct uffd_msg { > struct { > __u64 flags; > __u64 address; > - __u32 ptid; > + union { > + __u32 ptid; > + } feat; > } pagefault; > > struct { > > > > -- Best regards, Alexey Perevalov -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org