From mboxrd@z Thu Jan 1 00:00:00 1970 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 6386CC43334 for ; Fri, 22 Jul 2022 14:37:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B151B6B0072; Fri, 22 Jul 2022 10:37:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC2CB6B0073; Fri, 22 Jul 2022 10:37:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93CA96B0074; Fri, 22 Jul 2022 10:37:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8160B6B0072 for ; Fri, 22 Jul 2022 10:37:54 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5B70AC0C62 for ; Fri, 22 Jul 2022 14:37:54 +0000 (UTC) X-FDA: 79714990068.04.78678B3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 86EC51C00A6 for ; Fri, 22 Jul 2022 14:37:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658500672; 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: in-reply-to:in-reply-to:references:references; bh=ohc3kb+5sh97VKjw963CFQ/bL+NxbyXfHznntP09rEk=; b=duZXX0QauSCX3kCjs0MhGy36wYS0HGgP3RjVpYbe4rU5uEFUJJTZzQu9hr/3XZ98YQ8wKd yqmYpsGsLuWrijuLUeJhBaRINBwFB8PKRbidwUgEQOLV7InA2GWErM1zh724zidePUYv5G q2SUE2TDgg2EXJcpS01NyLzNHS/Jh5g= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-528-TD9HZ1lyO_ql_OPd2mlMMA-1; Fri, 22 Jul 2022 10:37:50 -0400 X-MC-Unique: TD9HZ1lyO_ql_OPd2mlMMA-1 Received: by mail-qk1-f199.google.com with SMTP id i15-20020a05620a404f00b006b55998179bso3842505qko.4 for ; Fri, 22 Jul 2022 07:37:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ohc3kb+5sh97VKjw963CFQ/bL+NxbyXfHznntP09rEk=; b=O4OQ5MEupAsIUQCrqk8YCrn7bTnTuftEOjsA6YM2mF9HD2ExWyh4Hoh+PczaoKOhJ5 d7LKhW6QbLQihUDmchFYMdne/qT8ZOGrzAoMjPvooGoN1T/3ZZO2lxFrpluq2gsHjWfe PXRf8InHkGYwrU2DqYfHnac8rCYihr17tK7bVvO4aRhKYWEZ6dHm9gEE7nME4xgiiVzn 5JVTGDkT5Z0cGzpjAHoVQBBeybc9eIRPqrIe7ZNpbnAsj80AkAScqodK7X2GL6nnHeQR 20vVdnC2ZXK+q/AP+Hz4sPqYOIE6jm0zYNHaGcpcj57VRXNTW7RWOg66VgSOUNRTviNu LmbQ== X-Gm-Message-State: AJIora94Gq6Jwxxbp4azwFOiWw3MHudIt7CHsJdYSB89GJlozRp5D2uM n+215rPm8oHKICzRss0odckYHWHm4nM4HAEZnSkDZ7Dh7mmfimhbztFoMnYPH2nZduBCbtNy8Qy Q+wuoCNhcdmg= X-Received: by 2002:a05:6214:2a8b:b0:474:12b7:cbd0 with SMTP id jr11-20020a0562142a8b00b0047412b7cbd0mr28545qvb.71.1658500670498; Fri, 22 Jul 2022 07:37:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tjxyA5msGHb80FzFz76BDJQcSuhv9BvR1xBTaQaopVX7yJzNRtqri01j3/12Fwzi/+ng4GWQ== X-Received: by 2002:a05:6214:2a8b:b0:474:12b7:cbd0 with SMTP id jr11-20020a0562142a8b00b0047412b7cbd0mr28522qvb.71.1658500670279; Fri, 22 Jul 2022 07:37:50 -0700 (PDT) Received: from xz-m1.local (bras-base-aurron9127w-grc-35-70-27-3-10.dsl.bell.ca. [70.27.3.10]) by smtp.gmail.com with ESMTPSA id y8-20020a05620a44c800b006b5c5987ff2sm3834567qkp.96.2022.07.22.07.37.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 07:37:49 -0700 (PDT) Date: Fri, 22 Jul 2022 10:37:48 -0400 From: Peter Xu To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Nadav Amit , Andrew Morton , Andrea Arcangeli Subject: Re: [PATCH v3 2/3] selftests: soft-dirty: Add test for mprotect Message-ID: References: <20220721183338.27871-1-peterx@redhat.com> <20220721183338.27871-3-peterx@redhat.com> <8fbbd68f-267c-1e0d-a578-7da4551c4c19@redhat.com> <8fd4d9fa-7370-3d97-20d0-a4dfed914600@redhat.com> <5d6c745e-219c-3abf-a30d-b3fb8e8e752c@redhat.com> MIME-Version: 1.0 In-Reply-To: <5d6c745e-219c-3abf-a30d-b3fb8e8e752c@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658500673; a=rsa-sha256; cv=none; b=ENZ+KVcgj2/KW6+F2DAEkBjcWkRvrJf+Vu4cjlvwWoGvKkeFYZ+S0Pvl/vQGxzk3q51aS5 y74TBFqRLwofbTR3uCRGMxqiORSqanO6V+TXWn+x5KWb2kSAOdRIhkm0tP0A9VL0J+o+Fh W4dvdqkiTLi6nE564CF0RZ1FGnhvVGo= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=duZXX0Qa; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf20.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658500673; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ohc3kb+5sh97VKjw963CFQ/bL+NxbyXfHznntP09rEk=; b=MYBZ5ABwCi0dTqkJ9QgX9WNy/CZ8ddZvSlXp9leWVqJIKTElJ5Cg8HVr2ivSYZMUu14Eq1 hWY+siOi8MPWD/CJLR77OQipSErlz+b+qX+bxc1wYdNt6qgJROHCcWAvuF5o1zcVFMvYWZ vbDcFzdY3gGeCmbV82v4Q3uFcR5BNuU= X-Rspamd-Server: rspam12 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=duZXX0Qa; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf20.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com X-Rspam-User: X-Stat-Signature: ufec7t6f7jpdxnxoj7tfgdsktf58741w X-Rspamd-Queue-Id: 86EC51C00A6 X-HE-Tag: 1658500672-473116 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: On Fri, Jul 22, 2022 at 04:07:47PM +0200, David Hildenbrand wrote: > On 22.07.22 16:00, David Hildenbrand wrote: > > On 22.07.22 15:44, Peter Xu wrote: > >> On Fri, Jul 22, 2022 at 09:17:34AM +0200, David Hildenbrand wrote: > >>> On 21.07.22 20:33, Peter Xu wrote: > >>>> Add two soft-diryt test cases for mprotect() on both anon or file. > >>> > >>> s/soft-diryt/soft-dirty/ > >> > >> Fixed. > >> > >>> > >>>> > >>>> Signed-off-by: Peter Xu > >>>> --- > >>>> tools/testing/selftests/vm/soft-dirty.c | 69 ++++++++++++++++++++++++- > >>>> 1 file changed, 68 insertions(+), 1 deletion(-) > >>>> > >>>> diff --git a/tools/testing/selftests/vm/soft-dirty.c b/tools/testing/selftests/vm/soft-dirty.c > >>>> index 08ab62a4a9d0..7d93906aa43f 100644 > >>>> --- a/tools/testing/selftests/vm/soft-dirty.c > >>>> +++ b/tools/testing/selftests/vm/soft-dirty.c > >>>> @@ -121,13 +121,78 @@ static void test_hugepage(int pagemap_fd, int pagesize) > >>>> free(map); > >>>> } > >>>> > >>>> +static void test_mprotect(int pagemap_fd, int pagesize, bool anon) > >>>> +{ > >>>> + const char *type[] = {"file", "anon"}; > >>>> + const char *fname = "./soft-dirty-test-file"; > >>>> + int test_fd; > >>>> + char *map; > >>> > >>> Instead of fname, unlink, open, close, unlink you can use a tmpfile > >>> > >>> FILE *file; > >>> > >>> file = tmpfile(); > >>> if (!file) { > >>> ksft_test_result_fail("tmpfile() failed\n"); > >>> return; > >>> } > >>> test_fd = fileno(file); > >> > >> Note that tmpfile() should by default fetch from /tmp which is very > >> possibly a tmpfs afaict. It's tricky in this special test case since I > >> don't think tmpfs can trigger this bug (shmem doesn't define page_mkwrite). > >> > > > > I don't think we need that? SOFTDIRTY tracking enabled should be > > sufficient, or what am I missing? > > > > I think you're right that it doesn't work with tmpfile. I do wonder why, > because I'd have thought that it's sufficient for > vma_wants_writenotify() to return "1" due to the > vma_soft_dirty_enabled() check. I can't say I know the whole rational of this, but I think it's below that will start to return 0 already before the soft-dirty check: if (pgprot_val(vm_page_prot) != pgprot_val(vm_pgprot_modify(vm_page_prot, vm_flags))) return 0; in vma_wants_writenotify(). -- Peter Xu