From patchwork Thu Mar 30 16:07:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13194493 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C4FFC761A6 for ; Thu, 30 Mar 2023 16:07:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 237806B0089; Thu, 30 Mar 2023 12:07:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 198EC6B008A; Thu, 30 Mar 2023 12:07:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 039146B008C; Thu, 30 Mar 2023 12:07:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E46836B0089 for ; Thu, 30 Mar 2023 12:07:26 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A923840F09 for ; Thu, 30 Mar 2023 16:07:26 +0000 (UTC) X-FDA: 80626044492.14.E635FAB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 6A8D8A0016 for ; Thu, 30 Mar 2023 16:07:24 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OAaB6PSf; spf=pass (imf25.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680192444; h=from:from:sender: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:dkim-signature; bh=yBXFNiQEy11weTKM7tK5TrNqKeG1r9RMGXvyXsqJW94=; b=njEcRTDD/D8Ccf/1wHb+1Wlu+eYCciBFn4PX/d6X2B0wlJpiVviUQxNImR0uAOk+5fbnSC qC/IvNKo9T6mFXmns1NXI+Z/Byb97clHkS46xKX4jOrUxnFsKp0j5mmp4PCHd0s3jbIIc4 LtJ+qyNls2258KLOHhVJ2OBThxpt5Ok= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OAaB6PSf; spf=pass (imf25.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680192444; a=rsa-sha256; cv=none; b=U9dC1lOwbOXgSli7nK9XZ0vvvzy2kDaDDcLQ6lIPEhMw7oZSI+YmBwz81HBCb3vvHKyeZY JeOlMVBMABRuAf+DAxorvFQGSuAKnkD9R0YAOHXXB01JGhc56rXSl9A+zsaHy+mFYMyga5 v/Aj/WycNzlSAkJqkwlXRxo/9CahfVc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680192443; 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=yBXFNiQEy11weTKM7tK5TrNqKeG1r9RMGXvyXsqJW94=; b=OAaB6PSffFN+77Ge/obT0E5dfZiDAe/4WhocH6aDW/KsFRlOerAHzx5oA4Pv8p+j4J0B39 8bp6TXoA5LILGEj3o7cgoVnsK+gwFVZ15sn+YFBxKJSo4iGDPFXkFplp57DTxd1E/XgWe/ /Ti0MkPI4Z9cWF4SG7au9f1mofE0AH4= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-JEQMdT9gNDWnYCZ5exj_gg-1; Thu, 30 Mar 2023 12:07:22 -0400 X-MC-Unique: JEQMdT9gNDWnYCZ5exj_gg-1 Received: by mail-qv1-f71.google.com with SMTP id p14-20020a0cc3ce000000b005e14204a86bso370711qvi.10 for ; Thu, 30 Mar 2023 09:07:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680192441; x=1682784441; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yBXFNiQEy11weTKM7tK5TrNqKeG1r9RMGXvyXsqJW94=; b=5BAKYrMraRSxTDzBwrK2vPv6VfXl0/Uh8m2peju1SEJ7A/eR9KrJJ9ybtoVk91XEdF Zj5CvFl2gM2nJkVVA8oUtyp0p/JvRBUUbBCNXomDOyGHVqn21/+3xeUzBpDeAAvJRDf+ x0uWxbFRdM4GBF+bFsN6CSdn9QLYcDNVznLgvFoEiUtzGfouEkgf8SFvJrsBCnknqyIF 9F6GZhyf6AxzBY1akB+ip8Qxvbpg6AtqDWsrIJP+n+b8mWGyrng5AYVVDUtsLHXoYMrR xqlDUm+vK0SH1kc7sqYwbXn8sB6HZ25PHHReVw3jkNP9Pq5iDYYwCmal7RAAyG8UhoSv fF0A== X-Gm-Message-State: AAQBX9dF7nxNhUh3mjbHul5onj9DJLIIhzA3AbNA9p1bG6jT9CAxjQ2n J2uQLez1Bcs0jCpAl4hzlGMeFDnLw+XfcQq5op+4BUO1Jl2MJwsc10XepxAXn2FwIwF53tcQDWN 3uzljslTJPccHKmqqR13W3+MYwVahbWtJR3IUNWlfq3q1EkrxJwgJgDUGk207DjvQSJok X-Received: by 2002:a05:6214:f67:b0:5e0:3825:9adb with SMTP id iy7-20020a0562140f6700b005e038259adbmr3997393qvb.2.1680192440746; Thu, 30 Mar 2023 09:07:20 -0700 (PDT) X-Google-Smtp-Source: AKy350agoyNKdIa8Z89k2xkNRJVMAlfupevmh3H7qWdAB3fR6lzQMsGdBqB1QpElcSem0cMxlH2SCg== X-Received: by 2002:a05:6214:f67:b0:5e0:3825:9adb with SMTP id iy7-20020a0562140f6700b005e038259adbmr3997336qvb.2.1680192440324; Thu, 30 Mar 2023 09:07:20 -0700 (PDT) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-40-70-52-229-124.dsl.bell.ca. [70.52.229.124]) by smtp.gmail.com with ESMTPSA id pr23-20020a056214141700b005dd8b934579sm5514594qvb.17.2023.03.30.09.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Mar 2023 09:07:19 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: David Hildenbrand , Andrew Morton , Andrea Arcangeli , peterx@redhat.com, Axel Rasmussen , Mike Kravetz , Leonardo Bras Soares Passos , Mike Rapoport , Nadav Amit Subject: [PATCH 11/29] selftests/mm: Drop test_uffdio_zeropage_eexist Date: Thu, 30 Mar 2023 12:07:17 -0400 Message-Id: <20230330160717.3107010-1-peterx@redhat.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230330155707.3106228-1-peterx@redhat.com> References: <20230330155707.3106228-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Stat-Signature: 57mzw1pm6uheishhpekeh6nsip7khwpe X-Rspam-User: X-Rspamd-Queue-Id: 6A8D8A0016 X-Rspamd-Server: rspam06 X-HE-Tag: 1680192444-916501 X-HE-Meta: U2FsdGVkX1+1ODl5zPg7+PtFZMbAZr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gN7PFelAKQvPzJBnHfqVHRNH61y2qSYRe+gCTfPZwRvaOXv1ewM6BBA8cdD+VSwIKKcuNl6S0Lfz14H0fEBacdon20wN90lCqzaVnNPnjOQLizUC/QOk6lm4ZwRQ1psXzJV6JN+UAeiPzVJeiaiesA/Vdm0LzJnPi1ema773WiONO9mSOaztBKP9Kftk+g+Ujw946eGAgSt6tgvYs3mXRzwMtIvwLDK0dDGFlVy8Raf4GGei2nl2/SsjaqKqmv2FUZgGafGMACDEMEjIH+VeR6HcVnCVYTik4XZhvAER05tkjMqsaiBWbwzwSnTz+pu7TGWjZc5UlgztdgthVTEO9R0ZdeTdYPtGFF2jYXHymIOjix/jmBqfbhVt82zlNnUOVQoNacFcnWcansgsqfZ/0H+xT+BI= 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: The idea was trying to flip this var in the alarm handler from time to time to test -EEXIST of UFFDIO_ZEROPAGE, but firstly it's only used in the zeropage test so probably only used once, meanwhile we passed "retry==false" so it'll never got tested anyway. Drop both sides so we always test UFFDIO_ZEROPAGE retries if has_zeropage is set (!hugetlb). One more thing to do is doing UFFDIO_REGISTER for the alias buffer too, because otherwise the test won't even pass! We were just lucky that this test never really got ran at all. Signed-off-by: Peter Xu Reviewed-by: Mike Kravetz Reviewed-by: David Hildenbrand Reviewed-by: Mike Rapoport (IBM) --- tools/testing/selftests/mm/userfaultfd.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/mm/userfaultfd.c b/tools/testing/selftests/mm/userfaultfd.c index d724f1c78847..3487ec0bfcc8 100644 --- a/tools/testing/selftests/mm/userfaultfd.c +++ b/tools/testing/selftests/mm/userfaultfd.c @@ -88,7 +88,6 @@ static bool test_dev_userfaultfd; /* exercise the test_uffdio_*_eexist every ALARM_INTERVAL_SECS */ #define ALARM_INTERVAL_SECS 10 static volatile bool test_uffdio_copy_eexist = true; -static volatile bool test_uffdio_zeropage_eexist = true; /* Whether to test uffd write-protection */ static bool test_uffdio_wp = true; /* Whether to test uffd minor faults */ @@ -1114,7 +1113,7 @@ static void retry_uffdio_zeropage(int ufd, } } -static int __uffdio_zeropage(int ufd, unsigned long offset, bool retry) +static int __uffdio_zeropage(int ufd, unsigned long offset) { struct uffdio_zeropage uffdio_zeropage; int ret; @@ -1138,11 +1137,8 @@ static int __uffdio_zeropage(int ufd, unsigned long offset, bool retry) if (res != page_size) { err("UFFDIO_ZEROPAGE unexpected size"); } else { - if (test_uffdio_zeropage_eexist && retry) { - test_uffdio_zeropage_eexist = false; - retry_uffdio_zeropage(ufd, &uffdio_zeropage, - offset); - } + retry_uffdio_zeropage(ufd, &uffdio_zeropage, + offset); return 1; } } else @@ -1153,7 +1149,7 @@ static int __uffdio_zeropage(int ufd, unsigned long offset, bool retry) static int uffdio_zeropage(int ufd, unsigned long offset) { - return __uffdio_zeropage(ufd, offset, false); + return __uffdio_zeropage(ufd, offset); } /* exercise UFFDIO_ZEROPAGE */ @@ -1177,6 +1173,13 @@ static int userfaultfd_zeropage_test(void) assert_expected_ioctls_present( uffdio_register.mode, uffdio_register.ioctls); + if (area_dst_alias) { + /* Needed this to test zeropage-retry on shared memory */ + uffdio_register.range.start = (unsigned long) area_dst_alias; + if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register)) + err("register failure"); + } + if (uffdio_zeropage(uffd, 0)) if (my_bcmp(area_dst, zeropage, page_size)) err("zeropage is not zero"); @@ -1763,7 +1766,6 @@ static void sigalrm(int sig) if (sig != SIGALRM) abort(); test_uffdio_copy_eexist = true; - test_uffdio_zeropage_eexist = true; alarm(ALARM_INTERVAL_SECS); }