Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1760883imm; Sat, 29 Sep 2018 03:34:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV61YCNOYfjtkZNBS3/lq6htrw+iVvWoJkgAD+ppzaD4EpUoTS1B3uVdnWJcbMPxZ9Gxs/Imd X-Received: by 2002:a17:902:1ab:: with SMTP id b40-v6mr2697575plb.82.1538217277890; Sat, 29 Sep 2018 03:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538217277; cv=none; d=google.com; s=arc-20160816; b=BAvRZrkQjFnZW+e7hskGK+iUk+8A0LAMLYjWrlKKC7CkbWuKMbCc8Jv/h5GJx09cRP Blr5tcXa+KAGuE7kwxTd0H0gV18UqeCxS0FBLS7JbNijTaYpKnSPrclzcXf2ilUJBiBO +TUbAJuubxiY6wabKEnhMRDiJYuHmL+AJCEEv16piUvPTjtI8dfxheDrFsoArCCJaxHE VtT6CgXLD+kbsZddWpVfuoUv3X+gehdR0dX50mEZfZc6Tky3RQB+6u9VYn/M+RvYnHm1 BqZ5cCPCjKZprNYbEa9y16f82m3wADIXdEh03EGqo01jahJE6HhEEThSxjEaTSzdp3Bb b9/w== 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; bh=5nwAsiSmWgcrrAKf8oSWzMK9W4bNJ4sPcyCsHHUcTbU=; b=zdbFgR6VDREjNvHnUDP/GvQWAhme/ZJRun7rxYce7xA+VBNWl6Lsj+rPRBgm0jh/Fx /sSQF0KBqlnPjkFsAsEXzyDh6MSkHhauhR37Q8/BXI/2dKc6USpnJe7+faiq7wyjmGd5 yvMppI59rpplJZmzgWysj03vj3zqcPXiomDslJco5/MNd/3i+g4jPva1x3TlMQIIDi4g s8m1/4L8+8ZiV/NSSxOqI4o8CYVLvbOoYaeaeYyoU7q1X45J/dQTIUJaIfXa+9Bo/0Vb HCEHMYxGSjQ6bc/h76O1Ej87wEgCp+b4uqM6nuft/21nLfpPJMWXiAQHQK8pUEvNnX8b /60g== 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 d11-v6si6813448pgd.342.2018.09.29.03.34.23; Sat, 29 Sep 2018 03:34:37 -0700 (PDT) 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 S1728026AbeI2RA7 (ORCPT + 99 others); Sat, 29 Sep 2018 13:00:59 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:53038 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727756AbeI2RA6 (ORCPT ); Sat, 29 Sep 2018 13:00:58 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8TATkQL042082 for ; Sat, 29 Sep 2018 06:33:03 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2mt5hvb78w-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 29 Sep 2018 06:33:02 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 29 Sep 2018 11:33:01 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Sat, 29 Sep 2018 11:32:56 +0100 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8TAWtoi57606184 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 29 Sep 2018 10:32:55 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 39D8542041; Sat, 29 Sep 2018 13:32:38 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F03FC42045; Sat, 29 Sep 2018 13:32:36 +0100 (BST) Received: from rapoport-lnx (unknown [9.148.207.35]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Sat, 29 Sep 2018 13:32:36 +0100 (BST) Date: Sat, 29 Sep 2018 13:32:52 +0300 From: Mike Rapoport To: Peter Xu Cc: linux-kernel@vger.kernel.org, Shuah Khan , Jerome Glisse , Mike Kravetz , linux-mm@kvack.org, Zi Yan , "Kirill A . Shutemov" , linux-kselftest@vger.kernel.org, Shaohua Li , Andrea Arcangeli , "Dr . David Alan Gilbert" , Andrew Morton Subject: Re: [PATCH 3/3] userfaultfd: selftest: recycle lock threads first References: <20180929084311.15600-1-peterx@redhat.com> <20180929084311.15600-4-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180929084311.15600-4-peterx@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 18092910-0012-0000-0000-000002B0265D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18092910-0013-0000-0000-000020E44CF8 Message-Id: <20180929103252.GC6429@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-09-29_06:,, 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=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809290111 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Sep 29, 2018 at 04:43:11PM +0800, Peter Xu wrote: > Now we recycle the uffd servicing threads earlier than the lock > threads. It might happen that when the lock thread is still blocked at > a pthread mutex lock while the servicing thread has already quitted for > the cpu so the lock thread will be blocked forever and hang the test > program. To fix the possible race, recycle the lock threads first. > > This never happens with current missing-only tests, but when I start to > run the write-protection tests (the feature is not yet posted upstream) > it happens every time of the run possibly because in that new test we'll > need to service two page faults for each lock operation. > > Signed-off-by: Peter Xu Acked-by: Mike Rapoport > --- > tools/testing/selftests/vm/userfaultfd.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c > index f79706f13ce7..a388675b15af 100644 > --- a/tools/testing/selftests/vm/userfaultfd.c > +++ b/tools/testing/selftests/vm/userfaultfd.c > @@ -623,6 +623,12 @@ static int stress(unsigned long *userfaults) > if (uffd_test_ops->release_pages(area_src)) > return 1; > > + > + finished = 1; > + for (cpu = 0; cpu < nr_cpus; cpu++) > + if (pthread_join(locking_threads[cpu], NULL)) > + return 1; > + > for (cpu = 0; cpu < nr_cpus; cpu++) { > char c; > if (bounces & BOUNCE_POLL) { > @@ -640,11 +646,6 @@ static int stress(unsigned long *userfaults) > } > } > > - finished = 1; > - for (cpu = 0; cpu < nr_cpus; cpu++) > - if (pthread_join(locking_threads[cpu], NULL)) > - return 1; > - > return 0; > } > > -- > 2.17.1 > -- Sincerely yours, Mike.