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 18C06C433EF for ; Mon, 9 May 2022 16:41:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 536796B0072; Mon, 9 May 2022 12:41:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E64A6B0073; Mon, 9 May 2022 12:41:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35F866B0074; Mon, 9 May 2022 12:41:48 -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 230846B0072 for ; Mon, 9 May 2022 12:41:48 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E9AAB11EA for ; Mon, 9 May 2022 16:41:47 +0000 (UTC) X-FDA: 79446771054.12.DC562A7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 6F5B1C004F for ; Mon, 9 May 2022 16:41:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652114507; 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=46wpjVCZhJPBmgWeRQ9uBt+Od81o8qIGqdyqzSCTbIU=; b=CfYRbUZOLL4AVttH800v/rdS2NTJfXGEV8oSGBrfAeTNo2KKdymK3dVjnHhLLtuB6PfGew Ub6mfjCSBXJCOqbunShcQFRaHfZk7dXNuMDqCFR2k+YJvAGOTD4gyOL0OptvVsShJYI2yz vG7/fh+TVlNTBlW2e7LHsO7QgyKBr4w= 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-258-XwCkMEUPMped7dkStqDkKA-1; Mon, 09 May 2022 12:41:44 -0400 X-MC-Unique: XwCkMEUPMped7dkStqDkKA-1 Received: by mail-il1-f200.google.com with SMTP id k6-20020a056e02156600b002cf4afa295bso7900561ilu.8 for ; Mon, 09 May 2022 09:41:44 -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=46wpjVCZhJPBmgWeRQ9uBt+Od81o8qIGqdyqzSCTbIU=; b=Ko5M5jMOcgNkd1gTYJSiz5xoTiEKQZP0YgJkffhyGe28QiNxEkg1YWdTbssFku7I5q 3LPBEr6WtLHcQ/622Zr7x7f2jcJF21VzRhcpz//xVIZJ5L4/W2kaQvBzUDbOMwVyQntf h8FjlcS/ZQUhmB9mMi4Q8wEjI3wF7JafVXSFaqrF4nR0a9b0TuCC8cgjM6x7Q422n9E9 m3+2qRyUyK3wxcFcnJUcQaMfvNVLePNHuTd5rIZzOoFb5rXz8rW6N69PhCkLrwG+EVZA iN93AV4L29ImMAVL7XFazMo4gJgIYs61uHB4twh5MtYpk0zuuFrNleP7wL2iJWztmJNp ZDCw== X-Gm-Message-State: AOAM532tZg6Mq4yacF52TVYEZmykQgESQ+GFCM54vP7Wu2LO7qdQCL9r ztBk9Ddhz8WxNYNhAK1G8fq7+JF8SBRuL0Vpz9JSbuPT/K90brcEpUssbfABWn+Q2uF8fieSAG4 VicERKiDyxug= X-Received: by 2002:a05:6e02:164e:b0:2cf:82bc:6c76 with SMTP id v14-20020a056e02164e00b002cf82bc6c76mr6451780ilu.95.1652114503282; Mon, 09 May 2022 09:41:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxE3U4JsTh97DMqQwaSKR+J9MOnj5nTpGNATaHacf1CibJGqYaNUSWSiHqNy5VvKai+5PTu/Q== X-Received: by 2002:a05:6e02:164e:b0:2cf:82bc:6c76 with SMTP id v14-20020a056e02164e00b002cf82bc6c76mr6451741ilu.95.1652114503011; Mon, 09 May 2022 09:41:43 -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 x26-20020a6bfe1a000000b0065a48a57f6dsm3633311ioh.40.2022.05.09.09.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 09:41:42 -0700 (PDT) Date: Mon, 9 May 2022 12:41:38 -0400 From: Peter Xu To: Mike Kravetz Cc: Gerald Schaefer , Baolin Wang , akpm@linux-foundation.org, catalin.marinas@arm.com, will@kernel.org, tsbogend@alpha.franken.de, James.Bottomley@HansenPartnership.com, deller@gmx.de, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, ysato@users.sourceforge.jp, dalias@libc.org, davem@davemloft.net, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 3/3] mm: rmap: Fix CONT-PTE/PMD size hugetlb issue when unmapping Message-ID: References: <20220429220214.4cfc5539@thinkpad> <20220502160232.589a6111@thinkpad> <48a05075-a323-e7f1-9e99-6c0d106eb2cb@linux.alibaba.com> <20220503120343.6264e126@thinkpad> <927dfbf4-c899-b88a-4d58-36a637d611f9@oracle.com> MIME-Version: 1.0 In-Reply-To: <927dfbf4-c899-b88a-4d58-36a637d611f9@oracle.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 6F5B1C004F X-Stat-Signature: qo8tshhnxqg17nb8gwf6kw7augztz7fd Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CfYRbUZO; spf=none (imf10.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-HE-Tag: 1652114486-729761 X-Bogosity: Ham, tests=bogofilter, spamicity=0.001068, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, May 06, 2022 at 12:07:13PM -0700, Mike Kravetz wrote: > On 5/3/22 03:03, Gerald Schaefer wrote: > > On Tue, 3 May 2022 10:19:46 +0800 > > Baolin Wang wrote: > >> On 5/2/2022 10:02 PM, Gerald Schaefer wrote: [...] > >> Please see previous code, we'll use the original pte value to check if > >> it is uffd-wp armed, and if need to mark it dirty though the hugetlbfs > >> is set noop_dirty_folio(). > >> > >> pte_install_uffd_wp_if_needed(vma, address, pvmw.pte, pteval); > > > > Uh, ok, that wouldn't work on s390, but we also don't have > > CONFIG_PTE_MARKER_UFFD_WP / HAVE_ARCH_USERFAULTFD_WP set, so > > I guess we will be fine (for now). > > > > Still, I find it a bit unsettling that pte_install_uffd_wp_if_needed() > > would work on a potential hugetlb *pte, directly de-referencing it > > instead of using huge_ptep_get(). > > > > The !pte_none(*pte) check at the beginning would be broken in the > > hugetlb case for s390 (not sure about other archs, but I think s390 > > might be the only exception strictly requiring huge_ptep_get() > > for de-referencing hugetlb *pte pointers). We could have used is_vm_hugetlb_page(vma) within the helper so as to properly use either generic pte or hugetlb version of pte fetching. We may want to conditionally do set_[huge_]pte_at() too at the end. I could prepare a patch for that even if it's not really anything urgently needed. I assume that won't need to block this patchset since we need the pteval for pte_dirty() check anyway and uffd-wp definitely needs it too. Thanks, -- Peter Xu