Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp465777lqt; Mon, 18 Mar 2024 13:05:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXSjT+v2it/CVOQaRt+9TFUm6OyW1QGrorX2ST+hwMq4rv/IDE4LXkwAoTdcOmbPWqHAzG/Rpk8lp4E28l8KBVQWA8UkW5cCRMBtmhYgw== X-Google-Smtp-Source: AGHT+IFrcG9ZMbMuLfNOpwXHwb1A1FNkBkImOtq2/64MG3ka6Fb9R9/x0rkxwPScLA2LlSOab+HH X-Received: by 2002:a17:906:abcf:b0:a46:d655:e4f5 with SMTP id kq15-20020a170906abcf00b00a46d655e4f5mr601516ejb.28.1710792305970; Mon, 18 Mar 2024 13:05:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710792305; cv=pass; d=google.com; s=arc-20160816; b=WL/7zVS8lWUX+nFW5X2P9C0tkGWfxqkXrCJuAb0976E9vxdGB6fTfRe016ptquEZlc ZgTae9R9+lm5Z1mGTy36Y2NH9dwdd4I7YLPIJEcskp3jLXAI4OQiIxK+CZZyKPvfWZkq J59BsLsP3HVy4TrTYXqtOvWhEMY8/CvwHR8W9TnzyxGx5qezY+kUcn262LImZETbO2cH rJ3X4TpZ7GGL80quK6F6Jwl4yHyHzergRtsWMQBYIiQZa7oTilFsI7XtQ5abisMTnXJX 3x3f8Nq1+2qlKfkvYllsKlgIwIPEMFsNrU4YTrDYGLG71MbwQWleDXLuiCrCg3nzxE1b v01A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=OThRyXZFMjugEtcpgf//pX/PpGcoxbD3wNFnQts0Kco=; fh=yQ5R9Xwbdb9sgJ4JDw2dbtafcs9T0Ak6Iyb4To4N+xc=; b=ugy0sJA2mUC+ZCjVCedMtnqAsqNqUHKgyYrDGbqh4EaK61oHwSxrnrGe937jQaWQKx Zch0CczeSpN2GM7e/7x++4l9kfvld9bRZDbAM9RZCSe4AGnJ0TETCJNiZ7qfR/cVlppx 2kTN+/mkDLByFw65l1f9nHcEIo8HPK+0Z6XnTqu8GGeb/FvroEV10nZoPYEDyW/ykovv kC/lSfi5cafzOZDhgLe873wLjm6z6KmepHOhg8lPMu9kaJLaLCEvZzKAuQ7u3Bd7d5s4 hJToeJCCCoZYRw2LQzOmhVVIXD9foPPY9Ez1TRabElodHacRtqQJVtLz9azYQgyWlt2x 6u4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CYpBgvBF; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-106599-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106599-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cw23-20020a170906c79700b00a46c7a4b5cdsi871499ejb.82.2024.03.18.13.05.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 13:05:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106599-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CYpBgvBF; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-106599-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106599-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B20161F24055 for ; Mon, 18 Mar 2024 20:05:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C2EF59B47; Mon, 18 Mar 2024 20:04:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CYpBgvBF" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 144445821B for ; Mon, 18 Mar 2024 20:04:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710792256; cv=none; b=WFuv9i1Tu15f1k17IOum8BN5HIziMojCv8YHe9X1FwEGUurK5JLbNNrfqN8J2pFbC5jQxVTYk6y900tX46SDbl928DTYEV5yL1+qYjlQ6+mecSJrhgdTrsUCMIncPeCe2jKtErfA4fbvRTtV9FSDQJzdALhhIHKxXBeepsKlDWU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710792256; c=relaxed/simple; bh=XKAmzhpmXEAjAsa42PYgBQQ2HzrzYrw3Lh5/ehBy8nY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J24YHZOnudDb8KLcqGVr0KwAXx6sV+cSvyFwFG9nyyvLRsZBG1A0Y67JZ9CmVmhTGnVpdIY/FQVSKo32Rz0Jix6jLx56pIGmWGwz7SUcp7S0O6AlTOYMivvQ8JA5ouXVO3+CKM3EmuzfdRUCPIN5sXCSi6muAdKHEKlEFyjgVqs= 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=CYpBgvBF; arc=none smtp.client-ip=170.10.133.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 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OThRyXZFMjugEtcpgf//pX/PpGcoxbD3wNFnQts0Kco=; b=CYpBgvBFBU7+pUOX2fRSsN+iwKKjs5LAFpibov9hLuYTaX6SyA6c4pIjn2RD12StG0eT3b +bh0VC7tgFbLc154GOo9pqtDWBSBwL+k2r5KylW+n7Ij96OjNTBBqvFZJQuOIet8jbFjpC sFoty/bJiHt5QJXYwXNd40P3BhAKpZE= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-20-qVsjrnXYP1CgWOBHWBTaWQ-1; Mon, 18 Mar 2024 16:04:11 -0400 X-MC-Unique: qVsjrnXYP1CgWOBHWBTaWQ-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-430b4572a97so17522751cf.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=jKe+zlehpdU6c+Vkm8FPxBNj2bnr2ymoN5IugdU3lhYAR/mATMz0qVeqnhVcT5WgOG cD88dyrlpAtzgyeplDzY5TP8Gr94Hu2nNoKpqaqSBCcJ09YBrUs1vrrCisM66lLCS6fi rEOHeBH4xJyR104ThqVtWlO5rRgZ/Bn3KhpPFjv/c1QGuqV5gJJJ8budvgD5370WEsfg F5oCMx04oc8RI5K0jwPpl/Rqg3GH/gg7wUrhkqUs6e9I6eZF62L79b88Wo27vIRRB0f9 Bkr/zcIAwhNx89MkZSP5r0owMUrqAtT05RGROKQiuFuu646gNX+YzO8yZZ4Zb1Zxivdz XBpg== X-Gm-Message-State: AOJu0Yw/2zd8vjFRbEiCBc25Swyt/cxvMRFI8Myyb0jeLLQ6PYxCOqdv P7jmTv37/VIlBnzQIO5n+PWTCYTdlIdRPfI3jrSBllDjyg4+rWUyLVXWvpgB/ch4yQnrooAWqrX Jm+LKSkGtVN9oxZTf5HJJvnp5iySQhG8WvXzBL15hIIb1ffv+QyJd0ggAhXriDtxGWCiNYxR5gG htz8+NW4IRuYD5qL4GT+TBcG06Ix8YJB20q2nQ9nqwt1M= X-Received: by 2002:a05:622a:100b:b0:430:ace8:9801 with SMTP id d11-20020a05622a100b00b00430ace89801mr13041024qte.1.1710792250936; Mon, 18 Mar 2024 13:04:10 -0700 (PDT) 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: linux-kernel@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