From patchwork Sun Apr 28 19:01:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13646094 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 BA6EAC4345F for ; Sun, 28 Apr 2024 19:02:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 33C876B0087; Sun, 28 Apr 2024 15:02:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2ED436B0088; Sun, 28 Apr 2024 15:02:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18CA46B0089; Sun, 28 Apr 2024 15:02:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E9A486B0087 for ; Sun, 28 Apr 2024 15:02:01 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 76C89161551 for ; Sun, 28 Apr 2024 19:02:01 +0000 (UTC) X-FDA: 82059860442.10.F5719F7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 5ABA54000B for ; Sun, 28 Apr 2024 19:01:59 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Axk6keNv; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714330919; 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=TChkYNJLokf0R7TU3fj1Jd4fvD6sn29Wrs03bf1LQhQ=; b=Pb5EQMThzQERtohfcBesrEAwWCnpcjaAxRZJrLe2lLT8UTBwED0ju+tMyRS+P6x+9qtWT/ unfYn1OG1S+CULrqaYjzqQAQ3E+iGQgH2R6N6/EZsLsm2JdKhC2vV+18juo9Ppmm7fvGQF tQbmwKq9hkq2aTGJXePZ7oPcd+IqPeQ= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Axk6keNv; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714330919; a=rsa-sha256; cv=none; b=CvYnamLCoD8tLIIa8+vrASrq1n4onOQogrVxlmla78Qy7dNh20G5zNSl20p4/NbhFQouPA zwC3OeBnE0cupgmQt7d/zgkNb4sF7hnECt4ULKcKxBZ7phoaNN1/tYZI0bfgiFkGRUA7Ek mimeNB4vjlS4+Hr9HVFe1JA7FqEGi5Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714330918; 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=TChkYNJLokf0R7TU3fj1Jd4fvD6sn29Wrs03bf1LQhQ=; b=Axk6keNvXKEbIba4UfZYVs0EImo7LuSWyQJok2oAAnhJA5JZTgj4Cm5/YDlwOAXvhp72uJ VjYgsQ5cthy7flGvlgpj8GF9T9JGrtNRYRnjA23w+kbdnwX3tvVP4OmiPwAGozauF4tcHW nMyKjz0MkkS330rRfiAs3oIJ4JpkIYQ= Received: from mail-oo1-f69.google.com (mail-oo1-f69.google.com [209.85.161.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-650-hBm7PAVTOyKJJQgv8-bOzg-1; Sun, 28 Apr 2024 15:01:57 -0400 X-MC-Unique: hBm7PAVTOyKJJQgv8-bOzg-1 Received: by mail-oo1-f69.google.com with SMTP id 006d021491bc7-5aa6ba70bcbso1352289eaf.1 for ; Sun, 28 Apr 2024 12:01:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714330916; x=1714935716; 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=TChkYNJLokf0R7TU3fj1Jd4fvD6sn29Wrs03bf1LQhQ=; b=uR+a9UHiyTIi9oJs3WbMPncOD2sIb7JwiZMEMlRM1oi1U62wac7FlYjW8tHrRbdO03 MAoin28ptDiC5+U7w8W0Cl9Qk6+ohLjhpi/KuOuOCNOecayqgGq/eisFaOg4sHPwiG10 xCWL+gBsw90jEt2R5xHfBT0rzmx/DhsRJSiMOqESuA6fNxKXPI4pQUFFN0SHozC96Sxy noKveGuqMF+OkDjYMfQwWXMoH8iP1qh/qeoMt5HqwYqLZavV15ExT9fkGjFqszcnHXH6 kxVvvULNngkMQHxrD/rAaiHDy+WEcAV/b5uVF7/cMP18ahrfL6XFUoebsQcdFKvRTR+i SGog== X-Forwarded-Encrypted: i=1; AJvYcCWdETT4NqfvsGkCxk98r3xgrnn/tg0uPs+jlYqlFV0uatgipYuCa3ztB1beQ0DNpnwqBLAuaqYLPBnYSTltcq/0DZE= X-Gm-Message-State: AOJu0YyLU3USWIKLE+U8IJD6wGRgokzbyLLjBbXOdfA9Pu/ZWY4xClSP +bczp6knnseCFmi84JYc5kLeHXF+jYYtafV3C9fy+4t63ubCV+5bNmPuvyp4nrOJyX4MBPKiAMp HdwZKEpz7gYhUDY1eiblnSdAVR7rej8rENBSLhrm2GrQMXIzV X-Received: by 2002:a05:6830:7193:b0:6ed:ffd4:f871 with SMTP id el19-20020a056830719300b006edffd4f871mr5375190otb.0.1714330916157; Sun, 28 Apr 2024 12:01:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGbfCPhcOZyAaf7bBZJaTYiO0a8lHR2gVf15VHmfKPjl2t1+bRyODyi0XieC0TmXGWNmTdCnA== X-Received: by 2002:a05:6830:7193:b0:6ed:ffd4:f871 with SMTP id el19-20020a056830719300b006edffd4f871mr5375155otb.0.1714330915677; Sun, 28 Apr 2024 12:01:55 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id oo8-20020a05620a530800b0078d693c0b4bsm9818152qkn.135.2024.04.28.12.01.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 12:01:55 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Christophe Leroy , peterx@redhat.com, David Hildenbrand , Andrew Morton , "Aneesh Kumar K . V" , Lorenzo Stoakes , John Hubbard , linuxppc-dev@lists.ozlabs.org, Muchun Song , Jason Gunthorpe Subject: [PATCH 2/2] mm/selftests: Don't prefault in gup_longterm tests Date: Sun, 28 Apr 2024 15:01:51 -0400 Message-ID: <20240428190151.201002-3-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240428190151.201002-1-peterx@redhat.com> References: <20240428190151.201002-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 5ABA54000B X-Stat-Signature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Jh+HhMO+ksgK3TpQUdknU5/VHbpKxcs4a0rKszvV5E8aUBjBxFiwhw/20AkzCKWX6qHm7Cne+50JSG2HAqkFNmHT3F69nEqLL60gDY9T/UZv1MC5HrV9z1ZACqKHb1xiD/2inP88r2OtIu0Rk7lqirKNRmN9QrWXWqMBV+XC0H8O0orkOFGXxkqPx0XXYXCr+job6+1UsAf2rBJp1k/xtm+10kRfuPdGr06fNJj1qqSId+5chPHXw7QPZamSoj6/NyZZBwUidF9wmN+3jUBfYi0PtDlyl0udYuJMP3peDxDNs7gk8egJMydwn7i/ezGv/QGg3A8ZMvqlT1jtkPATOeJDnuOt2t57gBu6ylorPVh6hoMNntExduoUwkK8o398ExHq9fhSrcfQXPQP9jnz7JiKnHb4sJ3KEmevBPmfP/U35eL8H1xY6a3yP+WTU 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: List-Subscribe: List-Unsubscribe: Prefault, especially with RW, makes the GUP test too easy, and may not yet reach the core of the test. For example, R/O longterm pins will just hit, pte_write()==true for whatever cases, the unsharing logic won't be ever tested. This patch remove the prefault. This tortures more code paths at least to cover the unshare care for R/O longterm pins, in which case the first R/O GUP attempt will fault in the page R/O first, then the 2nd will go through the unshare path, checking whether an unshare is needed. Cc: David Hildenbrand Signed-off-by: Peter Xu --- tools/testing/selftests/mm/gup_longterm.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/mm/gup_longterm.c b/tools/testing/selftests/mm/gup_longterm.c index ad168d35b23b..488e32186246 100644 --- a/tools/testing/selftests/mm/gup_longterm.c +++ b/tools/testing/selftests/mm/gup_longterm.c @@ -119,10 +119,16 @@ static void do_test(int fd, size_t size, enum test_type type, bool shared) } /* - * Fault in the page writable such that GUP-fast can eventually pin - * it immediately. + * Explicitly avoid pre-faulting in the page, this can help testing + * more code paths. + * + * Take example of an upcoming R/O pin test, if we RW prefault the + * page, such pin will directly skip R/O unsharing and the longterm + * pin will success mostly always. When not prefaulted, R/O + * longterm pin will first fault in a RO page, then the 2nd round + * it'll go via the unshare check. Otherwise those paths aren't + * covered. */ - memset(mem, 0, size); switch (type) { case TEST_TYPE_RO: