Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp305423imm; Tue, 24 Jul 2018 19:50:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc0Mili6SFqfzChU9UqLWNV6Yt4w7qXbKvVY5H8ihtkoUzCNK/9w+dzWkOTauBn21XF9QmP X-Received: by 2002:a62:f0d:: with SMTP id x13-v6mr20004866pfi.123.1532487026646; Tue, 24 Jul 2018 19:50:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532487026; cv=none; d=google.com; s=arc-20160816; b=Dmv9fpXmF4zFitALxhK2r33oVotDTlhSE54dIXE/Fl0Xduk8kc05TVOwWhd9LPQbt1 Nn3Xg6L/bF/QHwM2CeCiVsui5Z539HeBEyv4t7uM6l6HjFsooFUqtMR6Fgt6UBGWyLOP 69M4/f0qHLiPOGUXSZv/3rcYJH20YvysJWJby8PTGZnB/Z7pux0oCLn7GhXV5b7m8hBe Ls1Kb483beKjuj/YrGjXFz7bJwpbNu5JcfyIwGT4Tmw83l4LuRRvzG5ppv9OTDLXE+2L eJNgcdFU+dU01r3+R9Br4eVBvaS3xY8RVV3dBUtAg2jjdr4rYue+cEo3W6Jisu/V3Cgh BQgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=GYC4zi7kCPpXnyd37QWDy8z6s/fPyPdwloOsc5DhMFI=; b=FJyNa5Y3yQdw3QAFW0TvsPkrGQ6YVZRpehoN/zj6V/nsXDPmVcnuYMz9bNCTmsxH0A /6DgTdSx+vNSHK549BUsUl0pgP/nxNohDXvlE7JWjnOpjQc7hVkv0saYvEAhZL6cqwUT 9lUMAgsZ4Vdj8n/SpDF6agAOAS9a+Hpcozhe4qdT8KvlzHGLwpJq1gs5GV34Rv7asxm9 QhxVnMTWvqoYCjx6eT7hVaAeQOPvRi1osvci5hckcdXFKfRVFwLsy5mzKktxv3psVQhi DxZhSOdRRzLDZki/gYMyeWn8zETZ6i6XOkanU+0JycV397nNasnKX0IsEbj9xSSVXQXe MZYw== 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 i62-v6si13080335pfc.217.2018.07.24.19.50.11; Tue, 24 Jul 2018 19:50:26 -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 S1728179AbeGYD6v (ORCPT + 99 others); Tue, 24 Jul 2018 23:58:51 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52656 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727353AbeGYD6v (ORCPT ); Tue, 24 Jul 2018 23:58:51 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6P2mfrd126487 for ; Tue, 24 Jul 2018 22:49:21 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 2keatc4335-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 24 Jul 2018 22:49:20 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 24 Jul 2018 20:44:20 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 24 Jul 2018 20:44:18 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6P2iHpu11862414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 24 Jul 2018 19:44:17 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 89D9578060; Tue, 24 Jul 2018 20:44:17 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A2E6C7805E; Tue, 24 Jul 2018 20:44:15 -0600 (MDT) Received: from morokweng.localdomain.com (unknown [9.85.159.138]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 24 Jul 2018 20:44:15 -0600 (MDT) From: Thiago Jung Bauermann To: linux-kselftest@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Shuah Khan , Andrea Arcangeli , Mike Rapoport , Prakash Sangappa , Thiago Jung Bauermann Subject: [PATCH 1/3] userfaultfd: selftest: Fix checking of userfaultfd_open() result Date: Tue, 24 Jul 2018 23:42:07 -0300 X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180725024209.32586-1-bauerman@linux.ibm.com> References: <20180725024209.32586-1-bauerman@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18072502-0016-0000-0000-0000090CFFBA X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009424; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01065718; UDB=6.00547467; IPR=6.00843577; MB=3.00022308; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-25 02:44:19 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18072502-0017-0000-0000-00003FC04DED Message-Id: <20180725024209.32586-2-bauerman@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-24_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1806210000 definitions=main-1807250028 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the userfaultfd test is run on a kernel with CONFIG_USERFAULTFD=n, it will report that the system call is not available yet go ahead and continue anyway: # ./userfaultfd anon 30 1 nr_pages: 480, nr_pages_per_cpu: 120 userfaultfd syscall not available in this kernel bounces: 0, mode:, register failure This is because userfaultfd_open() returns 0 on success and 1 on error but all callers assume that it returns < 0 on error. Since the convention of the test as a whole is the one used by userfault_open(), fix its callers instead. Now the test behaves correctly: # ./userfaultfd anon 30 1 nr_pages: 480, nr_pages_per_cpu: 120 userfaultfd syscall not available in this kernel Signed-off-by: Thiago Jung Bauermann --- tools/testing/selftests/vm/userfaultfd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index 7b8171e3128a..e4099afe7557 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -859,7 +859,7 @@ static int userfaultfd_zeropage_test(void) if (uffd_test_ops->release_pages(area_dst)) return 1; - if (userfaultfd_open(0) < 0) + if (userfaultfd_open(0)) return 1; uffdio_register.range.start = (unsigned long) area_dst; uffdio_register.range.len = nr_pages * page_size; @@ -902,7 +902,7 @@ static int userfaultfd_events_test(void) features = UFFD_FEATURE_EVENT_FORK | UFFD_FEATURE_EVENT_REMAP | UFFD_FEATURE_EVENT_REMOVE; - if (userfaultfd_open(features) < 0) + if (userfaultfd_open(features)) return 1; fcntl(uffd, F_SETFL, uffd_flags | O_NONBLOCK); @@ -961,7 +961,7 @@ static int userfaultfd_sig_test(void) return 1; features = UFFD_FEATURE_EVENT_FORK|UFFD_FEATURE_SIGBUS; - if (userfaultfd_open(features) < 0) + if (userfaultfd_open(features)) return 1; fcntl(uffd, F_SETFL, uffd_flags | O_NONBLOCK); @@ -1027,7 +1027,7 @@ static int userfaultfd_stress(void) if (!area_dst) return 1; - if (userfaultfd_open(0) < 0) + if (userfaultfd_open(0)) return 1; count_verify = malloc(nr_pages * sizeof(unsigned long long));