From patchwork Mon Mar 18 20:03:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13595773 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 38557C54E5D for ; Mon, 18 Mar 2024 20:04:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=paSrHkCwwL/y5jsSHv+LOSa1LKSwfzZYfbcmh/TgfRU=; b=ZG701Yn7ToJFia HIpBkemA96WI2vMAJSDYZm1xDnoVKqVyEY/O3OZ1aP9ekrdPnbmQLnvBqGXUIDYXye1W+xSzc5NPa 18VtONxP8O2Ob6pcNicn2ivCKUmDaMPrKCaRiYV+xpq2PEXP2eln2F74EXGLc8VomqGonOL9rsWMX jkgehsgrCUhWNtpOkOi0WZM8r+tlmyHXyf4eW+5DbfQtqpISj4XskEiLy8jiwLwBgMCmMlX7VZcuG qyEaKRGl7oAJmj8uSFijxm+dOKkPcv+Co6qpBWzDsThKEXO1ETRPEjH4bSCjaqelC2E6IW0i4JTh0 ByeqN9iroUab50uPgpzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmJDq-00000009xL2-2e5I; Mon, 18 Mar 2024 20:04:38 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmJDS-00000009wx9-04Vp for linux-arm-kernel@lists.infradead.org; Mon, 18 Mar 2024 20:04:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710792252; 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=OThRyXZFMjugEtcpgf//pX/PpGcoxbD3wNFnQts0Kco=; b=hXBlPnLcptxIoQrB4kSJW1/+u3eLQlV3Gt5Ez4iTGDi25xjF2oXhpEtd4DU/McbM/yv4Ze qB9M76bya54d4Si2iiVwyfPooHsaZQIPeK9Xr4TMI8QWtGOkuLAyybXFLW5trULmU4MoWU dXnfEm/3fE437vajDLqlDuBP4QxO61I= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-283-8N6vhkoENp6dqFe95ccWIQ-1; Mon, 18 Mar 2024 16:04:11 -0400 X-MC-Unique: 8N6vhkoENp6dqFe95ccWIQ-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-430b4572a97so17522681cf.1 for ; Mon, 18 Mar 2024 13:04:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710792251; x=1711397051; 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=OThRyXZFMjugEtcpgf//pX/PpGcoxbD3wNFnQts0Kco=; b=BltrQZrAY7k1VaX6Bl6oxpT4g1U7hQW/bShAdu146Z5xe8MGwZUPgartPiukTK+fOh eoVAPaNmvhkpN/IlWwEHKBI244S+x2VLBE1XMogE6u+ahjNOKdYmjvNTYcrCppRszsYp dHFvp631zb3kX8LfWZu4bQrAT6Z/Espgkq14LJsCfex1VjMrD7ykS5LS6OrBwLtk+Huq CpibSdDMiU7mnkq7jyQq9gm+NXKmNUuiZWqjeGaZ/+GUkj5aL6agZC8U51t3ptuz/HJL lwxj0GHuwldxplq/izhqcKJJTS3QLWXMZf5WDy9iGG03ij3mKPzMjra0MtUP3gy8JiSF TlgQ== X-Forwarded-Encrypted: i=1; AJvYcCX1UC77LsBLLzGZ5alOc0Rf/rb+HLm2Qq7x85/bkansRRaMOlmjzN8V5ol+8JVjYI7XGKjxz3K6mIqJj6m7onPpEOpvb+OQwmJ6vG/2ZyuZtPwMGmw= X-Gm-Message-State: AOJu0YyogbIGvSsAIXvL0A3KGAdYYdiYWN/jptBK2IUtYsk03UAlErMU 4XgylMqtB6rbw5sDlJi4KBhLfVIDrJPozoP1mt38lR4MuoaS8c1WuUh533nvZJrd8VVJFv7mse2 FSCR9MZh7ffBzB6nal/vQOkU8y5wHOU2QVQR9d8U5f8dClbjpBLGRRafr3HUvrQn4yq6tfHE5 X-Received: by 2002:a05:622a:100b:b0:430:ace8:9801 with SMTP id d11-20020a05622a100b00b00430ace89801mr13041014qte.1.1710792250874; Mon, 18 Mar 2024 13:04:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE3lB75/Xyi/Yr3FGp4iv8P5rE4DSC0aUJAJLEw6DejnKFtl7A4ZV0qXSchssNp4WRDw4IDoQ== X-Received: by 2002:a05:622a:100b:b0:430:ace8:9801 with SMTP id d11-20020a05622a100b00b00430ace89801mr13040968qte.1.1710792250407; Mon, 18 Mar 2024 13:04:10 -0700 (PDT) Received: from x1n.. ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id hj10-20020a05622a620a00b0042ebbc1196fsm3484491qtb.87.2024.03.18.13.04.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 13:04:09 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Andrew Morton , x86@kernel.org, Muchun Song , Mike Rapoport , Matthew Wilcox , sparclinux@vger.kernel.org, Jason Gunthorpe , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , linux-arm-kernel@lists.infradead.org, peterx@redhat.com Subject: [PATCH v2 03/14] mm/gup: Check p4d presence before going on Date: Mon, 18 Mar 2024 16:03:53 -0400 Message-ID: <20240318200404.448346-4-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240318200404.448346-1-peterx@redhat.com> References: <20240318200404.448346-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240318_130414_179910_C23A31F9 X-CRM114-Status: GOOD ( 13.09 ) 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 From: Peter Xu Currently there should have no p4d swap entries so it may not matter much, however this may help us to rule out swap entries in pXd_huge() API, which will include p4d_huge(). The p4d_present() checks make it 100% clear that we won't rely on p4d_huge() for swap entries. Signed-off-by: Peter Xu --- mm/gup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 69a777f4fc5c..802987281b2f 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -776,7 +776,7 @@ static struct page *follow_p4d_mask(struct vm_area_struct *vma, p4dp = p4d_offset(pgdp, address); p4d = READ_ONCE(*p4dp); - if (p4d_none(p4d)) + if (!p4d_present(p4d)) return no_page_table(vma, flags); BUILD_BUG_ON(p4d_huge(p4d)); if (unlikely(p4d_bad(p4d))) @@ -3069,7 +3069,7 @@ static int gup_p4d_range(pgd_t *pgdp, pgd_t pgd, unsigned long addr, unsigned lo p4d_t p4d = READ_ONCE(*p4dp); next = p4d_addr_end(addr, end); - if (p4d_none(p4d)) + if (!p4d_present(p4d)) return 0; BUILD_BUG_ON(p4d_huge(p4d)); if (unlikely(is_hugepd(__hugepd(p4d_val(p4d))))) {