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 6F68EC433EF for ; Tue, 12 Apr 2022 19:53:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DCBBC6B0072; Tue, 12 Apr 2022 15:53:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D7A016B0073; Tue, 12 Apr 2022 15:53:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C1AB56B0074; Tue, 12 Apr 2022 15:53:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id AFC4E6B0072 for ; Tue, 12 Apr 2022 15:53:57 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 7BFBE122588 for ; Tue, 12 Apr 2022 19:53:57 +0000 (UTC) X-FDA: 79349277714.01.310FA4E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf30.hostedemail.com (Postfix) with ESMTP id EDE5C80003 for ; Tue, 12 Apr 2022 19:53:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649793236; 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=Ktu/FmbfdAxFSlIYnoKvOmDiTJHsefITneobmc6G+mM=; b=YPctwdO0NOyq5PvBu7HQ4eprtsDe0sfvJavZPGzdmVT9RbJGCrK38Mghjl1ZOYjui6P/0H DzyLDUOZhS76kDNxwLP7rEeJQL9F2X7c/35VhlZykDLY741gUSJXGdXMNx5M5rY31G4FD9 9YJgM5d18sezJRLqrO4slV1k5p//8oI= Received: from mail-il1-f200.google.com (mail-il1-f200.google.com [209.85.166.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-48-7Sdj20DeN7mFBzfdCKLP5A-1; Tue, 12 Apr 2022 15:53:53 -0400 X-MC-Unique: 7Sdj20DeN7mFBzfdCKLP5A-1 Received: by mail-il1-f200.google.com with SMTP id g7-20020a92c7c7000000b002ca31b0b53cso13393925ilk.2 for ; Tue, 12 Apr 2022 12:53:53 -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=Ktu/FmbfdAxFSlIYnoKvOmDiTJHsefITneobmc6G+mM=; b=sE5GnrBHoDLd7GhiuJ1h64awXIraWQEQxbkefW66T5MeacCFDzhlABPaJJyQ14DjUq EEnZahN/E7ITdJjFXDIZKPSF/dzP83Bor7NbPcOUcBnLe0u3vTVu0466WCoVJpKM8AiG 61Ef/WxvKxzcr2cPQKzHlWA+8mSO8z2PCqsoL+66QyBJ/5dh4t1DWjEoRlk/PfSn9mlM iAJXumNr00FrEfV+Bbb4kq6PJyhJhPzh8TfnVqM00VgDLsi5LTNuJm8NUxrW5HUuN4IR rPbo5l12f9QORidX9dbEKlmxZrXKi7kUIfcTX/lRkbOpbwu7/uD04/6lpPx9RktBtdzN hSYA== X-Gm-Message-State: AOAM531VtcciVpKL4yYe7EqqZXq5JgwQ40SDfR0IfzKCEVpUe/nG/LaL QI87DA1kopsH4wmj6FZNkMYceiBuhOyUEv9hwd5BV2xWurzj7AztT8ZBmAjyVB0czJ4Ijakke00 veSjFr4tPuAc= X-Received: by 2002:a05:6638:d51:b0:326:4f60:f2c4 with SMTP id d17-20020a0566380d5100b003264f60f2c4mr1666122jak.211.1649793232581; Tue, 12 Apr 2022 12:53:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKhc8KBBIu03VM32gpa8Lhg+/5hy0VZsV9Ah94tlicv6v7mtbET3C3fQCFaTOhFxemxsAnjw== X-Received: by 2002:a05:6638:d51:b0:326:4f60:f2c4 with SMTP id d17-20020a0566380d5100b003264f60f2c4mr1666114jak.211.1649793232373; Tue, 12 Apr 2022 12:53:52 -0700 (PDT) Received: from xz-m1.local (cpec09435e3e0ee-cmc09435e3e0ec.cpe.net.cable.rogers.com. [99.241.198.116]) by smtp.gmail.com with ESMTPSA id d16-20020a056e020bf000b002ca51236f60sm15162919ilu.9.2022.04.12.12.53.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 12:53:52 -0700 (PDT) Date: Tue, 12 Apr 2022 15:53:50 -0400 From: Peter Xu To: Alistair Popple Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Mike Kravetz , Nadav Amit , Matthew Wilcox , Mike Rapoport , David Hildenbrand , Hugh Dickins , Jerome Glisse , "Kirill A . Shutemov" , Andrea Arcangeli , Andrew Morton , Axel Rasmussen Subject: Re: [PATCH v8 02/23] mm: Teach core mm about pte markers Message-ID: References: <20220405014646.13522-1-peterx@redhat.com> <20220405014833.14015-1-peterx@redhat.com> <87a6crawzy.fsf@nvdebian.thelocal> MIME-Version: 1.0 In-Reply-To: <87a6crawzy.fsf@nvdebian.thelocal> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YPctwdO0; spf=none (imf30.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: EDE5C80003 X-Stat-Signature: m1j5rpc18ac8rcf15x58erja7s6u9rin X-HE-Tag: 1649793236-171427 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: Hi, Alistair, On Tue, Apr 12, 2022 at 11:22:01AM +1000, Alistair Popple wrote: > I've been reviewing existing pte_none() call sites and noticed the following: > > From khugepaged_scan_pmd(): > > pte_t pteval = *_pte; > if (is_swap_pte(pteval)) { > if (++unmapped <= khugepaged_max_ptes_swap) { > /* > * Always be strict with uffd-wp > * enabled swap entries. Please see > * comment below for pte_uffd_wp(). > */ > if (pte_swp_uffd_wp(pteval)) { > result = SCAN_PTE_UFFD_WP; > goto out_unmap; > } > continue; > } else { > result = SCAN_EXCEED_SWAP_PTE; > count_vm_event(THP_SCAN_EXCEED_SWAP_PTE); > goto out_unmap; > } > } > if (pte_none(pteval) || is_zero_pfn(pte_pfn(pteval))) { > if (!userfaultfd_armed(vma) && > ++none_or_zero <= khugepaged_max_ptes_none) { > continue; > } else { > result = SCAN_EXCEED_NONE_PTE; > count_vm_event(THP_SCAN_EXCEED_NONE_PTE); > goto out_unmap; > } > } > > I think the above could encounter a marker PTE right? So the behviour would be > wrong in that case. As I understand things the is_swap_pte() path will be taken > rather than pte_none() but in the absence of any special handling shouldn't > marker PTE's mostly be treated as pte_none() here? > > I think you need to s/pte_none/pte_none_mostly/ here and swap the order of > conditionals around. Isn't khugepaged_scan_pmd() only for anonymous? The shmem side is covered by khugepaged_scan_file(), imho. We definitely don't want to collapse shmem vma ranges that has uffd-wp registered, and that's actually handled explicilty in "mm/khugepaged: Don't recycle vma pgtable if uffd-wp registered". Please feel free to have a look. Thanks, -- Peter Xu