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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 101C9C3DA4A for ; Fri, 9 Aug 2024 18:01:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:In-Reply-To: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4vBISjU3wc8bbFt9cGZRVmI4aFRJJnxKYVQ2bi1B1P4=; b=NmsKtpyRzVCXhcFoccmEigu3JB dpmjaBE0HXi0sMIENWmjX8CnsUCfz2AqTRG3aJ7kf/1f/fnvwqwWxjrAWW1P6NmdHSZcDLhIfHO1Q 4NbYheZbsiLaH/SbzVC7xTIBDG3gEWI6IEX+LqLy2/XQF5tPfLZoLgpyrM3W43n6wgKTPRx0WpWLT f+7yZvveAaX3XqYWu3Vq1Nf18N81DUXm/XI5q9FOhLsdgr35/pRefovA+W4t0TvVIFb+JWRRfmoHB d+9+Tq0uCTnzDnCYzgiUMO4IyB8LkgqwgIwNpzlKamk5j0XQ9r2YUVcilBvXGEw0ecXDFWa9O9Sz1 tUoNTzwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scTvF-0000000C999-3AgY; Fri, 09 Aug 2024 18:01:06 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1scSxv-0000000C0gn-3Tl3 for linux-arm-kernel@lists.infradead.org; Fri, 09 Aug 2024 16:59:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723222786; 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=4vBISjU3wc8bbFt9cGZRVmI4aFRJJnxKYVQ2bi1B1P4=; b=H3dnOSgN8i2J+E0H+DdeE3dz0h9otkeLD89l+9za+Y1rhr0+WVZcQ4YPVnKm2yIAe12l5f +7xCR672tqqTW/VN1CHxYhGIyhZpSoaA7QQMTzgkt4K6wtL47w7zCzGpDLAPSc8LuTks1+ R3Pu9OZOMYg16MmeuLPmVJVyKfqsbhI= Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-508-I2QY85rYO-WpzlaqHGSglA-1; Fri, 09 Aug 2024 12:59:45 -0400 X-MC-Unique: I2QY85rYO-WpzlaqHGSglA-1 Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-3d93859d818so125321b6e.1 for ; Fri, 09 Aug 2024 09:59:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723222784; x=1723827584; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=4vBISjU3wc8bbFt9cGZRVmI4aFRJJnxKYVQ2bi1B1P4=; b=Q+q0wyIWMZn18DiZZzoNVkKCyTiUxFHpyDP6UNYM4B2MBGuM9tIJmzpOR8TQ1pYIh+ fRe+PB0l84KC5Ut+8dyZVHQbvlVbURzRbUh7r1SWxdUNESuHVxe0c4nddqw3sgcrH/Gi yQIAJP6oi0P9PZZFXWyzxZzbd+i+6JhdgTcxPSbizozYQw7m3FtP5GRwCMtHf7gQvGKb ZW2rnlsY6wqHumQC40k67lpUiVDM5+l4ax+B+qQAvolE6zXvPZH7Oz/SaYUdM9ZDFiVn 9e1XPw+M4+sQgczHiAiBed+FLkM4Arcs7nuz3rOeDTnVXEEhp6itnW0nco2GuZuaeEjb oQ/Q== X-Forwarded-Encrypted: i=1; AJvYcCV5Z4rXYkv+3EDVp5syA/AZtG8ex890Q4DbtMHYKhEo6IynfbW3VVe9gi95IgL/wr8QewkHN9jrbHZhFfKXmskU@lists.infradead.org X-Gm-Message-State: AOJu0Yya6OAx+MMcROVl4+8+MBMRaGuLOW0tdpCTMq7+2Zf/rkkBvWZu 88C2ZzjqBG1q1J8ThC16sSLQxefQAoJ74Ks2Rupb107klwjImVL/59TIS7mi+qAjaD6d4DBz4H9 H9KAMk36YK+DPFairWLb7FQ/JDGe8BhEMh+kTjsy1a4rxOkUnQJ519U907gM95zC7VTJOOPot X-Received: by 2002:a05:6358:e498:b0:1ac:ee25:ea01 with SMTP id e5c5f4694b2df-1b176f25c65mr138665855d.2.1723222784502; Fri, 09 Aug 2024 09:59:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhzrEIAv0YtSNyCDkni9NvGO/yGcX0KWO+ywGAIyNJzMZXEzyIqhBTcGWxs3CX0V3QMBcTvQ== X-Received: by 2002:a05:6358:e498:b0:1ac:ee25:ea01 with SMTP id e5c5f4694b2df-1b176f25c65mr138663855d.2.1723222784120; Fri, 09 Aug 2024 09:59:44 -0700 (PDT) Received: from x1n (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb9c79ba4asm78773856d6.36.2024.08.09.09.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 09:59:43 -0700 (PDT) Date: Fri, 9 Aug 2024 12:59:40 -0400 From: Peter Xu To: David Hildenbrand Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sean Christopherson , Oscar Salvador , Jason Gunthorpe , Axel Rasmussen , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Will Deacon , Gavin Shan , Paolo Bonzini , Zi Yan , Andrew Morton , Catalin Marinas , Ingo Molnar , Alistair Popple , Borislav Petkov , Thomas Gleixner , kvm@vger.kernel.org, Dave Hansen , Alex Williamson , Yan Zhao Subject: Re: [PATCH 05/19] mm/gup: Detect huge pfnmap entries in gup-fast Message-ID: References: <20240809160909.1023470-1-peterx@redhat.com> <20240809160909.1023470-6-peterx@redhat.com> <67d734e4-86ea-462b-b389-6dc14c0b66f9@redhat.com> MIME-Version: 1.0 In-Reply-To: <67d734e4-86ea-462b-b389-6dc14c0b66f9@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240809_095947_961764_FB1DDAEF X-CRM114-Status: GOOD ( 24.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Aug 09, 2024 at 06:23:53PM +0200, David Hildenbrand wrote: > On 09.08.24 18:08, Peter Xu wrote: > > Since gup-fast doesn't have the vma reference, teach it to detect such huge > > pfnmaps by checking the special bit for pmd/pud too, just like ptes. > > > > Signed-off-by: Peter Xu > > --- > > mm/gup.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/mm/gup.c b/mm/gup.c > > index d19884e097fd..a49f67a512ee 100644 > > --- a/mm/gup.c > > +++ b/mm/gup.c > > @@ -3038,6 +3038,9 @@ static int gup_fast_pmd_leaf(pmd_t orig, pmd_t *pmdp, unsigned long addr, > > if (!pmd_access_permitted(orig, flags & FOLL_WRITE)) > > return 0; > > + if (pmd_special(orig)) > > + return 0; > > + > > if (pmd_devmap(orig)) { > > if (unlikely(flags & FOLL_LONGTERM)) > > return 0; > > @@ -3082,6 +3085,9 @@ static int gup_fast_pud_leaf(pud_t orig, pud_t *pudp, unsigned long addr, > > if (!pud_access_permitted(orig, flags & FOLL_WRITE)) > > return 0; > > + if (pud_special(orig)) > > + return 0; > > + > > if (pud_devmap(orig)) { > > if (unlikely(flags & FOLL_LONGTERM)) > > return 0; > > In gup_fast_pte_range() we check after checking pte_devmap(). Do we want to > do it in a similar fashion here, or is there a reason to do it differently? IIUC they should behave the same, as the two should be mutual exclusive so far. E.g. see insert_pfn(): if (pfn_t_devmap(pfn)) entry = pte_mkdevmap(pfn_t_pte(pfn, prot)); else entry = pte_mkspecial(pfn_t_pte(pfn, prot)); It might change for sure if Alistair move on with the devmap work, though.. these two always are processed together now, so I hope that won't add much burden which series will land first, then we may need some care on merging them. I don't expect anything too tricky in merge if that was about removal of the devmap bits. > > Acked-by: David Hildenbrand Thanks, I'll take this one first. -- Peter Xu