From patchwork Mon Apr 12 23:27:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12199047 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 6CCDBC43462 for ; Mon, 12 Apr 2021 23:28:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1496261287 for ; Mon, 12 Apr 2021 23:28:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1496261287 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 D350A8D0003; Mon, 12 Apr 2021 19:28:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE50E8D0001; Mon, 12 Apr 2021 19:28:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD31D8D0003; Mon, 12 Apr 2021 19:28:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0194.hostedemail.com [216.40.44.194]) by kanga.kvack.org (Postfix) with ESMTP id A21358D0001 for ; Mon, 12 Apr 2021 19:28:03 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 5F59A878D for ; Mon, 12 Apr 2021 23:28:03 +0000 (UTC) X-FDA: 78025305246.12.06F33A1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id F1A0F130 for ; Mon, 12 Apr 2021 23:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618270082; 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=qk6kQznMv60g5JnSrTctErm3V3ADaN3762t2H988t2A=; b=ZDNTLtAbPwJpksXgR8rcZX1Tr4e14jlM2bMBOoO+Mk81AJgXb0sWaWHyr5EJ5wIXhqhu64 ZPrDITmhcNWMGtXr29VvA9rDY/zHHZ2cry3kIegMMmovS4PuAiNzC4wUCTk46vUvem41aF KDsNBNNib50QcT7KuVF8l/1xRfObf4g= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-508-fjUW4irhMLmx80TN9Eo3Iw-1; Mon, 12 Apr 2021 19:28:01 -0400 X-MC-Unique: fjUW4irhMLmx80TN9Eo3Iw-1 Received: by mail-qv1-f72.google.com with SMTP id s8so8961654qve.16 for ; Mon, 12 Apr 2021 16:28:01 -0700 (PDT) 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=qk6kQznMv60g5JnSrTctErm3V3ADaN3762t2H988t2A=; b=QshlftesgOIfZysrKdlvWANVyl0AjKIa+BSdRShUg/8pWMOHAOaga3e17rzx3oq8nQ yqHKNZfAdkcBNoJvv1gZAiM0uqOz/PfoARRpPtqVLXgoLWl1LrGEPLEiAsVjdr/YPBaR n8jWONAXD+w4m67pUdt6gfqe/KkHkNNsFID7i3NTEn+MjhTk0MQBj5kvtnV3mq6oeWJS lAKozxp5DTJu+Jin9JLRqFZth8Nz97MS3DYC88AvPdY97wHx46OoiLu5DKPiOvF+0TT/ IA93rTALkb3u05VONtdjGBnJatRPA8AiDs0Wb8FEy4y8Y6ZAGu+3iJhkqqqdA/+gRheE TQsQ== X-Gm-Message-State: AOAM5325bclRs7rtsLBCpvV51kh/Nz/zR57r42TQYCRCDlNnyVYsCLgt k6k6jHO2JRIHHoBUtQHLXwiUvWWGBBrDNdyfqinhX7YGZfjMrpnIMIwXbIa9MJ/NFPY2HBWzeqU fcBn3nDOHZ1dWhhhPHFeGwlXjopVVTFMhcW5bHBjX3uRSv39jHjIlgnkUWeM8 X-Received: by 2002:ac8:5244:: with SMTP id y4mr3412667qtn.175.1618270080365; Mon, 12 Apr 2021 16:28:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylMZ4q6vaw/BA+In5/xrgFfhle5RcKCcC0k84sArZg1TaCw816VTI+r8JyxhmY4Q2GrOr/jg== X-Received: by 2002:ac8:5244:: with SMTP id y4mr3412647qtn.175.1618270080076; Mon, 12 Apr 2021 16:28:00 -0700 (PDT) Received: from xz-x1.redhat.com (bras-base-toroon474qw-grc-88-174-93-75-154.dsl.bell.ca. [174.93.75.154]) by smtp.gmail.com with ESMTPSA id y29sm8958925qtm.13.2021.04.12.16.27.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 16:27:59 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Andrea Arcangeli , peterx@redhat.com, Andrew Morton , Mike Rapoport , Axel Rasmussen Subject: [PATCH v2 3/5] userfaultfd/selftests: Dropping VERIFY check in locking_thread Date: Mon, 12 Apr 2021 19:27:51 -0400 Message-Id: <20210412232753.1012412-4-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210412232753.1012412-1-peterx@redhat.com> References: <20210412232753.1012412-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: rspam03 X-Rspamd-Queue-Id: F1A0F130 X-Stat-Signature: fkjuny55gr3ri18upsdeit7e6oudnx5k Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf12; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=170.10.133.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618270077-189272 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. Reviewed-by: Axel Rasmussen 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 5cae66e27171..387b9360ae64 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -430,58 +430,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]) { @@ -613,8 +561,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); }