Received: by 10.223.185.116 with SMTP id b49csp505673wrg; Sat, 3 Mar 2018 01:10:39 -0800 (PST) X-Google-Smtp-Source: AG47ELvaH4ifb8XV0Ou/L9SYnEZPcHQdrY5vi1/TdlOcWz+nJpheWJDSDbW3Agljv7mnh/2cSafg X-Received: by 2002:a17:902:b10b:: with SMTP id q11-v6mr7785857plr.275.1520068239253; Sat, 03 Mar 2018 01:10:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520068239; cv=none; d=google.com; s=arc-20160816; b=tpRoOWXzXtRNqXg8tMj6KwV8cOq85FOcE8lwsMsjcXBQ8UdQBi1ud9QsdHL3dPPymJ b6zftPO5FtwDNyitZSCCif6WQyc6hp4xnoQPPPjBkDIPQsWUf/EMu44t8C78uyN9wiux w1lwhbta8IvFdMwtYSoq+Dukgu1L1/zcdVD7kO4d//Z/2IF1RAA3B8YqBSiYnHi23c3K EYDDc4kVg5tdCyfg9IEx3UUM09Cnr1me5dKFl+ohDdwIQN5zvW/1pjaZlClWS8HK3Cfq lZbX2617LmWAb+4bKBdtHMGW/lZLKDvTPe2Ev5EF0yFykDQkUJqkvWD0qzhXr/NX5yQC w5fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:subject:cc:to:from:date :arc-authentication-results; bh=LOkYPZHLtQfUURIMI3GOyXrgJ+0tycJRG5oxW9b4eRs=; b=rzhKE6YlseexPEfVbUUUiLq17OxmtB3g16WULQfJT960Jal4nqxEU5yKaJ5yRG5pIa om8N2DSOtBTQsEvfwukg9nvaqyLt03Yr+qdtXLm7BpPbS4qxOof2c1TgdURcwVpSCXGm FLbib8Lg7PCVfOJJkRwNuuJFvXFHZqNwlSq/dIbSpLkC3ycO1YZ8M87IpaKCgRX/w/fm YlI2KG9B6/Yx47lZkelUQURwm9r03+KC18SpF4EVQDDEQUU1lWL/Q5yMiSisPCyU50bZ cNluSDn6F44KtnaBFSjclQ//Z7t4q8+qC7lt6/wz4gwMUmwPy3eUqsU8sEgHSqrEHCZ4 io5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d67si6368772pfe.49.2018.03.03.01.10.23; Sat, 03 Mar 2018 01:10:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751896AbeCCJJm (ORCPT + 99 others); Sat, 3 Mar 2018 04:09:42 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51898 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751568AbeCCJJl (ORCPT ); Sat, 3 Mar 2018 04:09:41 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2398sYx095439 for ; Sat, 3 Mar 2018 04:09:41 -0500 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gfpxwjs5k-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Sat, 03 Mar 2018 04:09:40 -0500 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 3 Mar 2018 09:09:38 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sat, 3 Mar 2018 09:09:31 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2399VcS1573300; Sat, 3 Mar 2018 09:09:31 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E7BCBA4040; Sat, 3 Mar 2018 09:02:31 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1DE66A4053; Sat, 3 Mar 2018 09:02:31 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.205.166]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Sat, 3 Mar 2018 09:02:31 +0000 (GMT) Date: Sat, 3 Mar 2018 11:09:28 +0200 From: Mike Rapoport To: Andrew Morton Cc: Andrea Arcangeli , Pavel Emelyanov , linux-mm , linux-api , lkml , crml Subject: Re: [PATCH 0/3] userfaultfd: non-cooperative: syncronous events References: <1519719592-22668-1-git-send-email-rppt@linux.vnet.ibm.com> <20180302153849.d9d7b9a873755c6f5e883d0d@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180302153849.d9d7b9a873755c6f5e883d0d@linux-foundation.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 18030309-0012-0000-0000-000005B83CBF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18030309-0013-0000-0000-0000193448C4 Message-Id: <20180303090926.GA14011@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-03_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803030114 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 02, 2018 at 03:38:49PM -0800, Andrew Morton wrote: > On Tue, 27 Feb 2018 10:19:49 +0200 Mike Rapoport wrote: > > > Hi, > > > > These patches add ability to generate userfaultfd events so that their > > processing will be synchronized with the non-cooperative thread that caused > > the event. > > > > In the non-cooperative case userfaultfd resumes execution of the thread > > that caused an event when the notification is read() by the uffd monitor. > > In some cases, like, for example, madvise(MADV_REMOVE), it might be > > desirable to keep the thread that caused the event suspended until the > > uffd monitor had the event handled to avoid races between the thread that > > caused the and userfaultfd ioctls. > > > > Theses patches extend the userfaultfd API with an implementation of > > UFFD_EVENT_REMOVE_SYNC that allows to keep the thread that triggered > > UFFD_EVENT_REMOVE until the uffd monitor would not wake it explicitly. > > "might be desirable" is a bit weak. It might not be desirable, too ;) > > _Is_ it desirable? What are the use-cases and what is the end-user > benefit? It _is_ desirable :) With asynchronous UFFD_EVENT_REMOVE, the faulting thread continues before the uffd monitor had chance to process the event and the memory accesses or layout modifications of faulting thread race with the monitor processing of the UFFD_EVENT_REMOVE. Moreover, for multithreaded uffd monitor there could be also uffdio_{copy,zeropage} in flight that will also race with those memory accesses. I have elaborate description of the patch 3 in this series. -- Sincerely yours, Mike.