From patchwork Tue Dec 8 02:47:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11957467 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 C3383C4167B for ; Tue, 8 Dec 2020 02:47:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5F56B235F9 for ; Tue, 8 Dec 2020 02:47:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F56B235F9 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 DCE1C8D000C; Mon, 7 Dec 2020 21:47:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D2FA88D0001; Mon, 7 Dec 2020 21:47:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA9B48D000C; Mon, 7 Dec 2020 21:47:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0050.hostedemail.com [216.40.44.50]) by kanga.kvack.org (Postfix) with ESMTP id 9E5858D0001 for ; Mon, 7 Dec 2020 21:47:18 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 640D8362C for ; Tue, 8 Dec 2020 02:47:18 +0000 (UTC) X-FDA: 77568578556.07.blood74_1a17b00273e3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 48EC41803F9A9 for ; Tue, 8 Dec 2020 02:47:18 +0000 (UTC) X-HE-Tag: blood74_1a17b00273e3 X-Filterd-Recvd-Size: 5243 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Tue, 8 Dec 2020 02:47:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607395637; 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=JHm7VOf4vG5fW9dqcix1M4Ga8GJuy8GIXJPeBhURP8Y=; b=KDhX07LTWLwSOIEn/O2hkFYpEEiQRQpJhocpt86az03frrnTxMgAXHVNQ5bHzTf15eyt/r RmHIqKZ4v7KNKwQIvf8jmbtIuk6YE0vFjkZWoq/d0SnyHhKGv3XUhVcq+RQCRiS/JrOUKG 2y4ZMcPd1zn01YmuFtyoyzDRmKQeVlI= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-319-zOuJd2pLO-uIEh7ZhnrsAA-1; Mon, 07 Dec 2020 21:47:15 -0500 X-MC-Unique: zOuJd2pLO-uIEh7ZhnrsAA-1 Received: by mail-qk1-f199.google.com with SMTP id s9so14257977qks.2 for ; Mon, 07 Dec 2020 18:47:15 -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=JHm7VOf4vG5fW9dqcix1M4Ga8GJuy8GIXJPeBhURP8Y=; b=E07pepV+ek514Mx2Q2S/UgieBA/KYkaUAHEXp7+WvV6oBZTSlXCVUNbEjMhNgGWv9v wfZk3b9ar4d+3BY7U2Y7YO9m/DFJYp3bbbWbdvs18ldRw9jqehRcQjrYNAsWt13LUpnd nbQ/mQaHGYMUZ0vVe70V/G+HqG4Qaee8w0RH4lf7AAFB4dzrFVgZLlV/q1RK0bQrTelk W9zgdPhzR24KylIKpEW/hx/EFgM/pDRu3FLZYpZcphNfiZ+FLTiZGgmKF2vbWrzmUOZI pujsKfgMuuzE53zQ1rbSQMZJCaxVZgN7lOUFDpL4zo4A5GY9uFt+82AK0Dqfs+pDlNHH 0i3Q== X-Gm-Message-State: AOAM532dDjWFYLumPW+AX7YZJ92GblLYaIU3TlA11ZMsJ275ncCYkP3/ lmzwmVfjoyXKXonA7yUXHLdG9gfhH8JfSIJJtWVDPl/icUw4eYxyUVH7UsLumBRznQKMSA1AS6m cnrUkOtI1Dg4= X-Received: by 2002:ad4:524d:: with SMTP id s13mr24676864qvq.19.1607395634924; Mon, 07 Dec 2020 18:47:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBZN0PrBHURyXeqoNeBbqq9BCmFz5EFAExrc7GKN1qoYPwkrbI06U6+ZHVzQbzcNsGNsjMLQ== X-Received: by 2002:ad4:524d:: with SMTP id s13mr24676846qvq.19.1607395634725; Mon, 07 Dec 2020 18:47:14 -0800 (PST) Received: from localhost.localdomain ([142.126.83.202]) by smtp.gmail.com with ESMTPSA id n95sm13778744qte.43.2020.12.07.18.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 18:47:14 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Andrea Arcangeli , Andrew Morton , peterx@redhat.com, Mike Rapoport Subject: [PATCH 2/3] userfaultfd/selftests: Fix retval check for userfaultfd_open() Date: Mon, 7 Dec 2020 21:47:08 -0500 Message-Id: <20201208024709.7701-3-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201208024709.7701-1-peterx@redhat.com> References: <20201208024709.7701-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-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: userfaultfd_open() returns 1 for errors rather than negatives. Fix it on all the callers so when UFFDIO_API failed the test will bail out. Signed-off-by: Peter Xu --- 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 31f470d12d0b..f0647bfda366 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -993,7 +993,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; @@ -1038,7 +1038,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); @@ -1101,7 +1101,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); @@ -1170,7 +1170,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));