From patchwork Wed Mar 10 00:45:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12126797 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 23FA1C433DB for ; Wed, 10 Mar 2021 00:45:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9EEFB650A2 for ; Wed, 10 Mar 2021 00:45:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9EEFB650A2 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 968408D015E; Tue, 9 Mar 2021 19:45:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 942128D0148; Tue, 9 Mar 2021 19:45:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76AF28D015E; Tue, 9 Mar 2021 19:45:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0181.hostedemail.com [216.40.44.181]) by kanga.kvack.org (Postfix) with ESMTP id 5AB578D0148 for ; Tue, 9 Mar 2021 19:45:22 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 234F762FF for ; Wed, 10 Mar 2021 00:45:22 +0000 (UTC) X-FDA: 77902120884.21.8EF4524 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 642C4A0009D5 for ; Wed, 10 Mar 2021 00:45:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615337121; 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=XTxMrWeKH8O2DThEeOu5l9V9OGI2aOJZxvfxAe4SMMo=; b=OxsQ7hYNd/umVaBJOJSmgbcP4kEymdk7cVM1UE6TyUjqJf6bV9NckN2xUgPmoiznw77pQi CVoXZW5bIqA8EcjumMLbeQeXRlEC4WKz89BG347OQyO5zksNXcza9ePbAdxJLwO87romnY oC5xsvQOUMy5HnHPymoB5EXd7HFXSLg= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-145-PUMXxEpKMYuILkF7egEiUg-1; Tue, 09 Mar 2021 19:45:17 -0500 X-MC-Unique: PUMXxEpKMYuILkF7egEiUg-1 Received: by mail-qv1-f69.google.com with SMTP id h10so11501170qvf.19 for ; Tue, 09 Mar 2021 16:45:17 -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=XTxMrWeKH8O2DThEeOu5l9V9OGI2aOJZxvfxAe4SMMo=; b=V6oYM9I0mlbuLeZ5gmHysV3XuUW3TfIkCGjlTmyuyletgdyeQxVIle78eaM8W2XMe0 SXk8+vbN9u3C3ATK7ZhIOxK7+oxdgMKBc3Mmxhkeo0P06GgF1/Oq3tVhI2FQ4kh8Mot5 4jm3dWgxQFgdZRBvzixDw9xUaRdD2QiT+iCQnB5eQIpzYl4VFn4RqsGVQuCEm6JQR+Dh 65Qz0dHw9vVd//HWNrmPCzAAEeK8SsJE13ONYLwjOek59Du+ZOCFM0+L87d3Iy/dGY4M hcM/rk6tFV5YcG/cnWt2MgR60rlTXHeOwdm0oYS95mYLvEcMRTxwodmrxk77K7fTmzBA S3yg== X-Gm-Message-State: AOAM5326V4b3TZKzWeypqCYj/kEL0Pf/6wTmFNW1stHuI9/RkEkxLcjZ 38hhPce6rbm9B5cNRoOFdjvh20BWsVMZ8XT3uRYEdgooMpgnpRmkx7QkdkZ9xx0AmMwYgeEdT90 bP79pPXtHH0608gasK97yRMhp5KfR6mKAJSafzP3wzVV1zZ+sjliIbJq8DqIm X-Received: by 2002:a37:6f87:: with SMTP id k129mr374406qkc.470.1615337116868; Tue, 09 Mar 2021 16:45:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxa0LO98xbT0z77N8oNJ9fVqTLpx95rd6U3cRryCrA2lKn1tkBps+lK8jr+X/gNz4ENVt3L0A== X-Received: by 2002:a37:6f87:: with SMTP id k129mr374386qkc.470.1615337116594; Tue, 09 Mar 2021 16:45:16 -0800 (PST) Received: from xz-x1.redhat.com (bras-vprn-toroon474qw-lp130-25-174-95-95-253.dsl.bell.ca. [174.95.95.253]) by smtp.gmail.com with ESMTPSA id b27sm11418173qkl.102.2021.03.09.16.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 16:45:16 -0800 (PST) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Axel Rasmussen , Andrew Morton , peterx@redhat.com, Andrea Arcangeli , Nadav Amit Subject: [PATCH 3/5] userfaultfd/selftests: Dropping VERIFY check in locking_thread Date: Tue, 9 Mar 2021 19:45:09 -0500 Message-Id: <20210310004511.51996-4-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210310004511.51996-1-peterx@redhat.com> References: <20210310004511.51996-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-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 642C4A0009D5 X-Stat-Signature: jxcuura6opudt475sfsd77m9hbwdoyi4 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf07; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615337121-89063 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: It tries to check against all zeros and looped for quite a few times. However after that we'll verify the same page with count_verify, while count_verify can never be zero. So it means if it's a zero page we'll detect it anyways with below code. There's yet another place we conditionally check the fault flag - just do it unconditionally. Signed-off-by: Peter Xu --- tools/testing/selftests/vm/userfaultfd.c | 55 +----------------------- 1 file changed, 1 insertion(+), 54 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index 5cde062f07bc..cf0cd4cb327d 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -603,58 +603,6 @@ static void *locking_thread(void *arg) } else page_nr += 1; page_nr %= nr_pages; - - if (bounces & BOUNCE_VERIFY) { - count = *area_count(area_dst, page_nr); - if (!count) { - fprintf(stderr, - "page_nr %lu wrong count %Lu %Lu\n", - page_nr, count, - count_verify[page_nr]); - exit(1); - } - - - /* - * We can't use bcmp (or memcmp) because that - * returns 0 erroneously if the memory is - * changing under it (even if the end of the - * page is never changing and always - * different). - */ -#if 1 - if (!my_bcmp(area_dst + page_nr * page_size, zeropage, - page_size)) { - fprintf(stderr, - "my_bcmp page_nr %lu wrong count %Lu %Lu\n", - page_nr, count, count_verify[page_nr]); - exit(1); - } -#else - unsigned long loops; - - loops = 0; - /* uncomment the below line to test with mutex */ - /* pthread_mutex_lock(area_mutex(area_dst, page_nr)); */ - while (!bcmp(area_dst + page_nr * page_size, zeropage, - page_size)) { - loops += 1; - if (loops > 10) - break; - } - /* uncomment below line to test with mutex */ - /* pthread_mutex_unlock(area_mutex(area_dst, page_nr)); */ - if (loops) { - fprintf(stderr, - "page_nr %lu all zero thread %lu %p %lu\n", - page_nr, cpu, area_dst + page_nr * page_size, - loops); - if (loops > 10) - exit(1); - } -#endif - } - pthread_mutex_lock(area_mutex(area_dst, page_nr)); count = *area_count(area_dst, page_nr); if (count != count_verify[page_nr]) { @@ -786,8 +734,7 @@ static void uffd_handle_page_fault(struct uffd_msg *msg, stats->minor_faults++; } else { /* Missing page faults */ - if (bounces & BOUNCE_VERIFY && - msg->arg.pagefault.flags & UFFD_PAGEFAULT_FLAG_WRITE) { + if (msg->arg.pagefault.flags & UFFD_PAGEFAULT_FLAG_WRITE) { fprintf(stderr, "unexpected write fault\n"); exit(1); }