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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 DB3DCC54E58 for ; Mon, 18 Mar 2024 20:07:06 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DWL5jjHV; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hZxeXUD0; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Tz5VK438Wz3vcK for ; Tue, 19 Mar 2024 07:07:05 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DWL5jjHV; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hZxeXUD0; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=peterx@redhat.com; receiver=lists.ozlabs.org) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Tz5R433hLz3dCH for ; Tue, 19 Mar 2024 07:04:16 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710792253; 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=DWL5jjHVolwBuIeGnvdZeQ+W3bWwaF3eniNYkw+dnClS0HjM6d2nZMFy/P5ip7DIXm/4OQ bpxngUIj16VEzk3LavJFO1AJekil/+mEquPIbqnEOgYhZTCwZ3RRnb3fXKCWq97dHcLfUW PKsU/RiZYQPozWzUKJp3x5tczMF5jvU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710792254; 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=hZxeXUD0iXdRyMB2gqURGAYYXZyQqGvv/Daq488SDWgRKKWq+26o+cG71LqtEiULOqdI/Q LGLt6s8BqlIQ74G1Mjlh8DWZ7Swl4S2QgeK/yb5TL3lI2lWcBK8Y8qSkQFFpOMHdeSkCVY D7LALnI2EIv2C4g3+kPzjHKVqQQP2x8= 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-402-nPyg0pH3OW-VmIOL88_tSQ-1; Mon, 18 Mar 2024 16:04:11 -0400 X-MC-Unique: nPyg0pH3OW-VmIOL88_tSQ-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-430b4572a97so17522721cf.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=aXG/DRNMm2tSTCFiI5u6kzKtIkaIS9yA5hmDPmvrB4Q+8WZtrtrqYvegfrwW9HtRH9 +cDZxGwwyRI2eEql/mtR/aTsZ9ihbIlLaXPHVqvSmr27FtiDcKHbOZJPNbq5Km/YWUqP K8fQ7fxc03krZHyllRJ7z+JOerEATR9YXFR0UwTza6kvn5+KEW16Z0CxDD6NjSs9kwwp 4U7skDtTNhLx7F0ymAQjkoa75zYaEs+D7fbvHRXbDoF81TCNKmkI6MpTcWQOKAC07Dli bMsZubsOrs7pipYv6IvO+QcpCQcWz/js5mea9KStgVHvkJoBOQ2Xr8ugWih3Zc2PQeDs Xz4Q== X-Forwarded-Encrypted: i=1; AJvYcCWeJtgxTYfjG8/6aHMfO7CJ3TZq8pnYwx2FGxa3rBDeCo3S1ZCTCfwHHS1Gx+cP924lyrsCgkGlAF+b4funrK9krozqe6GjhsTkg4cdPA== X-Gm-Message-State: AOJu0YwrZXoerhuRfr8Csxr0kFsKy/QcQsPVxRuHxR3E6ELZG+RJqgee ldj091AnjgLt1pQNHXZ1TVXqjTo/9dYf3mHoRGzj7UYqCxAxIo6Qi7+n1tMJ9yK3hNa8XYBxL52 w9p5+AtUctpLQdyEsN+vkN8zl9gVzYJulkuD93HhZu6m+9m5Rkj7DblfT2IWFEt8= X-Received: by 2002:a05:622a:100b:b0:430:ace8:9801 with SMTP id d11-20020a05622a100b00b00430ace89801mr13041010qte.1.1710792250870; 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 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Muchun Song , x86@kernel.org, Matthew Wilcox , peterx@redhat.com, Jason Gunthorpe , sparclinux@vger.kernel.org, Andrew Morton , linuxppc-dev@lists.ozlabs.org, Mike Rapoport Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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))))) { -- 2.44.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1F0C57892 for ; Mon, 18 Mar 2024 20:04:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710792255; cv=none; b=qWDODkLIz1xYsbjuF+vMQbMIKaFlcLcKHVmP6Z7xonTsU5OXQJ6DkNlumHDui7r6PeUwAqstnSYo1M3CWaL79M2p6GtUjn8buOUB3ldutwrZAlQ2Da0pIdlnJ7LYll1/MvO92CTcGC3YXAl6SfrpM9JDnIGTm4CIpfCKG6TXF5I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710792255; c=relaxed/simple; bh=XKAmzhpmXEAjAsa42PYgBQQ2HzrzYrw3Lh5/ehBy8nY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l2FMpmC2HXgbFfWfIJxhYfxlgmvpUB4lXI605jZJz7wYlPn+tAPHAc0yUBnrgvDvAPZEB7ydKj6TThBVJUrug/unWthkOFYlO38SbrN39N2NR9M+C+Bv+mz3d7LiV+9lecaPnUwMGaVv0xrk3uDnSbDPNSHhnXDcispZdiQeK+8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=O6YS+vCA; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="O6YS+vCA" 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OThRyXZFMjugEtcpgf//pX/PpGcoxbD3wNFnQts0Kco=; b=O6YS+vCAwaEx3DbX7jUjOyUpYA5qU8uq6C2t9jQ4hk/DF4zvQPx8x458zFfgxxYK7h2/c0 UpQaWYxzcSi7nX5URdqZ/dZ2PI4D1IZfhUTbysr4qCkH5aPH9JrzepZs5F4gqjTpc2iTQc C8wF57vQnkyOvkPYqrAwKEWoUF5wuUA= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-283-o6QrPGEROv-OEEQc8BJATg-1; Mon, 18 Mar 2024 16:04:11 -0400 X-MC-Unique: o6QrPGEROv-OEEQc8BJATg-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-430b4572a97so17522651cf.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=Z/UPCyNvXHLQE6zWWOLhbVAlukoW2OZKgc3ep8/o/Oap+WYXSA20eq7v77snuoFBF2 pEOpeFnYFune/hThws18j6N68Iec/oKBAN4fgGnuhPV5N85dL6thLpWZjaORzkY8xPko bBbqtelmaagGDwHba1PYxt4wCeB0GJP3710zNw5XeFsn/2fPpfSyXrUqwwh9HCOv2TJl FIe8Bp1YMuVqwH6nyjVMZuT7HDlEAf80DCWYkd1UGrLqd6HYFP/3czRcrzS9fLQIZBzI ZGIl9/kFYADntDXp+KoM5msfeNczBNSdUF80hdUZE7oqJnCImMB1AS3FzSeN/GP8dT9D KwiA== X-Forwarded-Encrypted: i=1; AJvYcCXrLAHAJSgGeUTpiCWIL8rWWQvnZQ7bZQO46VXS2J4bzm70VGQd2YLpIiXDV8XIfReNIxa89GuBLOsik7jUAq97EziiQQx6vEwolw== X-Gm-Message-State: AOJu0Yw018aWSgK9UJR6JqWrKePVtysbGklYTvDiZzKQ0wJ3INVV3oMQ jGDAiXKcFDal1gCJqNS+bMqyPZyUTI577IL3EoCO/vlYnvav40gMFyerSTCe5j8RhG6e6twcFZM vFSq39TxJfTS1HNmt9V0njW1ZERAXnpAxY+bUBzCZSP7b1F/o5oy9X4rqZb0= X-Received: by 2002:a05:622a:100b:b0:430:ace8:9801 with SMTP id d11-20020a05622a100b00b00430ace89801mr13041017qte.1.1710792250879; 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> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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))))) { -- 2.44.0 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 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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))))) { -- 2.44.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel