From patchwork Wed Mar 13 21:47:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1911874 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=fqNvRhhE; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=gandalf.ozlabs.org; envelope-from=srs0=o0gs=kt=vger.kernel.org=sparclinux+bounces-657-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tw3yl3jThz1ydl for ; Thu, 14 Mar 2024 08:47:43 +1100 (AEDT) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Tw3yh0ZyDz4wcr for ; Thu, 14 Mar 2024 08:47:40 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4Tw3yh0Rp4z4wcs; Thu, 14 Mar 2024 08:47:40 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: gandalf.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=fqNvRhhE; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=sparclinux+bounces-657-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Tw3yg5D3nz4wcr for ; Thu, 14 Mar 2024 08:47:39 +1100 (AEDT) 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7B920285838 for ; Wed, 13 Mar 2024 21:47:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2821257863; Wed, 13 Mar 2024 21:47:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fqNvRhhE" X-Original-To: sparclinux@vger.kernel.org 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 59A5156440 for ; Wed, 13 Mar 2024 21:47:25 +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=1710366448; cv=none; b=m69i0wsyWPXLnuuO548gLSzIm2FA8IXR8x0Vd+wbhixnKg2E0mgUhPNNcscvo0iM2LJ8SwQEkG762xfWbDkGmapd+y1kjzIfSEDVyZnpcN7Ube+YPD/z/8ITzLq+jacnjrzOO5UE0Jibpd55MdnjmK+Kr06NpEyZ4ufGvtxOt20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710366448; c=relaxed/simple; bh=0Lswo5GE77ATHQ8L+dlMWa1yM2evkibSoyq3AnC70nY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lQCjabtMzsRtSMqXaLwXjAaRb+9lBNcI1XeM9AmaHsLudE82lzV8BpFFcR2s09VZawPTyK/oph4gGICO1UBupKClAJKcUoLEqt92eGriew3RXItbt/osSMConl000qTL9YtDafrELAI7wjzWgsYGWUjDllCm18hU758JgxoqHlY= 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=fqNvRhhE; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710366445; 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=o8evz9V3UX8qsNtRrNT6H/1m1GM34KP8FDwkI2vjQ2A=; b=fqNvRhhErD7r4aqpHDkLwaMtGa2Y+PGhRbj7cxmqWyP5AaL0cnZ3v6xyAVUxZec+OOCRbS tEG7pM1v6TStprIv5bcwOLL4jbqilmmWPXhQ1MZbbJ/TU1D9IXmyf7eEwqlYrX3ZWo+Jeb VT6FtXhUNgalPxnZt8aYCCZkvS1dNXE= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-97-uIkWHXfUPiiSVDO7dUlYEw-1; Wed, 13 Mar 2024 17:47:24 -0400 X-MC-Unique: uIkWHXfUPiiSVDO7dUlYEw-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-69120b349c9so1131476d6.1 for ; Wed, 13 Mar 2024 14:47:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710366443; x=1710971243; 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=o8evz9V3UX8qsNtRrNT6H/1m1GM34KP8FDwkI2vjQ2A=; b=vi18g/KbKKQY6cv1wg/tRQQkg6kcdIDoi2N7/ccCn5F/GOePKe0624QH5NqfLFoTC5 QyHB6l3KEkGYnVt9+fZSGMvTsDQ3CCXgVpNJW7JxJXptewvRQLJpm3t5tepH7omPWU1s e6arZIqy4UXrInzb2z9aC9Y5VAVpHBmyaC6UT2FNOkPxp388xkEWvPBm3/vewf0x49BY QUbPMRnx4CeQYxGk5qPd13AsN1pR3aF59nhwpOWVXV1SKgMBVCOoYZJCIIl0lMTnNOoC CEJgeppIaAZUS4HAB0fJ8yPTu0wThX+CKBda++MZWPq727FYh7zbHh+08fc/Ot62umHJ x+dA== X-Forwarded-Encrypted: i=1; AJvYcCWwApuJ9tl3KSLM/Wfpip0zYN3Zjm8tXGVGdibPUHeJJF5acVwNXnkw6MnbKMKj1hwCbqJ1zZqzceP2yfXLk2Yo5mFv+RBFlaiJ4w== X-Gm-Message-State: AOJu0Yw/46srV+OBKCalQScmyMfbb/tPYfEM3ktNoD51KkCrms/kBQ51 lkTqD45Kq7tBVdeJoLOqx4NviJYikOzt4XAZ6wx0OF8mT8KbxlY/1le7SuD76W9bQvNEfLeI7hn DTioUrk+TBR2AN8ye2Byv0m/8iM+qvoJej2UBrR7ZK8E4T8DfGgLeIK5xqg9lbBgY2LU= X-Received: by 2002:a05:6214:1743:b0:690:27a:e6 with SMTP id dc3-20020a056214174300b00690027a00e6mr5703628qvb.5.1710366443330; Wed, 13 Mar 2024 14:47:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGB+0sslZT/w15j/K+m+SJUdgZVImDODUje9EjvSi+lJj4JWIjdAUo0kKWd9JJ6p81zVpsztA== X-Received: by 2002:a05:6214:1743:b0:690:27a:e6 with SMTP id dc3-20020a056214174300b00690027a00e6mr5703604qvb.5.1710366442877; Wed, 13 Mar 2024 14:47:22 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id dv10-20020ad44eea000000b0069111c5cdd4sm60114qvb.100.2024.03.13.14.47.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 14:47:22 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org, Matthew Wilcox , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , x86@kernel.org, peterx@redhat.com, Mike Rapoport , Muchun Song , sparclinux@vger.kernel.org, Jason Gunthorpe , Alistair Popple Subject: [PATCH 01/13] mm/hmm: Process pud swap entry without pud_huge() Date: Wed, 13 Mar 2024 17:47:07 -0400 Message-ID: <20240313214719.253873-2-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313214719.253873-1-peterx@redhat.com> References: <20240313214719.253873-1-peterx@redhat.com> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Peter Xu Swap pud entries do not always return true for pud_huge() for all archs. x86 and sparc (so far) allow it, but all the rest do not accept a swap entry to be reported as pud_huge(). So it's not safe to check swap entries within pud_huge(). Check swap entries before pud_huge(), so it should be always safe. This is the only place in the kernel that (IMHO, wrongly) relies on pud_huge() to return true on pud swap entries. The plan is to cleanup pXd_huge() to only report non-swap mappings for all archs. Cc: Alistair Popple Reviewed-by: Jason Gunthorpe Signed-off-by: Peter Xu --- mm/hmm.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/mm/hmm.c b/mm/hmm.c index 277ddcab4947..c95b9ec5d95f 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -424,7 +424,7 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned long start, unsigned long end, walk->action = ACTION_CONTINUE; pud = READ_ONCE(*pudp); - if (pud_none(pud)) { + if (!pud_present(pud)) { spin_unlock(ptl); return hmm_vma_walk_hole(start, end, -1, walk); } @@ -435,11 +435,6 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned long start, unsigned long end, unsigned long *hmm_pfns; unsigned long cpu_flags; - if (!pud_present(pud)) { - spin_unlock(ptl); - return hmm_vma_walk_hole(start, end, -1, walk); - } - i = (addr - range->start) >> PAGE_SHIFT; npages = (end - addr) >> PAGE_SHIFT; hmm_pfns = &range->hmm_pfns[i]; From patchwork Wed Mar 13 21:47:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1911876 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=PuWK7MIB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=gandalf.ozlabs.org; envelope-from=srs0=w7i5=kt=vger.kernel.org=sparclinux+bounces-658-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tw3zD14M7z1ydl for ; Thu, 14 Mar 2024 08:48:08 +1100 (AEDT) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Tw3zD0bSTz4wcg for ; Thu, 14 Mar 2024 08:48:08 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4Tw3zD0W3Jz4wc9; Thu, 14 Mar 2024 08:48:08 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: gandalf.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=PuWK7MIB; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=sparclinux+bounces-658-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Tw3zC4Lnwz4wcg for ; Thu, 14 Mar 2024 08:48:07 +1100 (AEDT) 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 978421C21F31 for ; Wed, 13 Mar 2024 21:48:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A618C59B6A; Wed, 13 Mar 2024 21:47:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PuWK7MIB" X-Original-To: sparclinux@vger.kernel.org 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 E817157324 for ; Wed, 13 Mar 2024 21:47:27 +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=1710366449; cv=none; b=reXVZd+cSlnV/k7tQ0QuEH/9gvFMGUAQf4csPqQ5jJ94Hp0BL+/q+bakLRZupFTzdOGSQDRem3Yq8t7N0z38poF6/u6BlDwvaxnZZKBk5JoDLAVU3lY7q2G7/Tqi35N2w4Hjj6/hhydEBdIm0BtALHH1jADxra9i5V4CYmKdrJ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710366449; c=relaxed/simple; bh=PJKzqnHG6HtyEXo/aXT9kPop7Tc4xiPLd1rW13UePCc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lzT6Pf2svwh94moCu/Wr+zBWdGcqKXQQdKiDS3vUNROIEB1piKb9m4pH4HIUZcDpv/KeSqDJSn6vS0Gl9ApX7m5HxIEIA7sTDYwsg3xGyeq8hbnwIj4olanxLXJYOWjZGbibFqB6UEVJGZVKEfw/k6EAivYYOa3HXO4P/lAx5gw= 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=PuWK7MIB; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710366447; 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=3D9LYre9es5Pr/ZmF0ksBqg/v+REJVkPqwZxeVyu2sc=; b=PuWK7MIBXf4+FuojOVhCcZzf7yzEgNJeu2GCPF83ym29z8M56Y6klqHxX0b1u80K00UTnp C8I8MnQYMMFSIBqFASVZxZLmZVIXlqjh+HYierlbLlroPnhEBOyN1SpzoXuW8nZ6xZLJs/ VipUxUKmSYGNfsMjiLKiNW21yiuZggk= Received: from mail-oa1-f69.google.com (mail-oa1-f69.google.com [209.85.160.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-357-L9mqp6ENNVWLXBftdbSdyg-1; Wed, 13 Mar 2024 17:47:25 -0400 X-MC-Unique: L9mqp6ENNVWLXBftdbSdyg-1 Received: by mail-oa1-f69.google.com with SMTP id 586e51a60fabf-22206c445fcso134269fac.1 for ; Wed, 13 Mar 2024 14:47:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710366444; x=1710971244; 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=3D9LYre9es5Pr/ZmF0ksBqg/v+REJVkPqwZxeVyu2sc=; b=lg0Y4ZuuJ7L57F4mV1sGXmGVdQVmj2ww7k4HmAdPks3J9PfYvxPXvtwj1pkEPOW+1w OhlcOvP3+Xi43D/11QQPmURVp5io/L8HvTfsIu6iCqqshTRmftuxH1Ym6rVA7JF7PL06 SIjEH3PHMaSTQrA0Or9aFQmYsafSGPOs1VqWjt/BXURZRJjhrCZWjkHotDN+6E2OVNHU yUVb0Qe4Nov7UpLBUvprQzku2CYo2O/z7fufcStT5uePJJQ2VVzPquiTBJP863tZV6aM 5fULmcmXDVM7n2rryfQcUdJSeMg/4qvYPYcFVWlzTiaH3ebRhtwbSmphO9gza7i7rbAs F+zw== X-Forwarded-Encrypted: i=1; AJvYcCWt2p/49ckx5PYjFjfuxpam7P5Pdzyl8N/1U2GvwZfFCz0e48vgvl5URL0CswuBXHUCVzV6vRX3XZSXteLn1QmjPjEB1GuJjdV1AQ== X-Gm-Message-State: AOJu0YwNhMt+eWP3gUkdit0TJG7jNqizqlJTkHQHvnTbcHQH9W3jqYD3 VoTlFY9FxgTivPwOHLdzEOBHVot2CEjHb5zzcPChUDa+m/VQeJ7Ej11pXaO4rWQRLovcFKYU+sP KuKLs/5Kz0NORqhv7dt5IIK3nNioK3zeLmrifghDNqzcyrLqwI8ABRxsS+Wc= X-Received: by 2002:a05:6870:548b:b0:221:8fd1:21d9 with SMTP id f11-20020a056870548b00b002218fd121d9mr65923oan.1.1710366444689; Wed, 13 Mar 2024 14:47:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGsHUgdlv9jd2gJ8jFSi5EgQlUb7Ps0TGhERhhMFfAJj348C9AzYnG5IHJKnziXpPDsCb1mgQ== X-Received: by 2002:a05:6870:548b:b0:221:8fd1:21d9 with SMTP id f11-20020a056870548b00b002218fd121d9mr65901oan.1.1710366444348; Wed, 13 Mar 2024 14:47:24 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id dv10-20020ad44eea000000b0069111c5cdd4sm60114qvb.100.2024.03.13.14.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 14:47:23 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org, Matthew Wilcox , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , x86@kernel.org, peterx@redhat.com, Mike Rapoport , Muchun Song , sparclinux@vger.kernel.org, Jason Gunthorpe Subject: [PATCH 02/13] mm/gup: Cache p4d in follow_p4d_mask() Date: Wed, 13 Mar 2024 17:47:08 -0400 Message-ID: <20240313214719.253873-3-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313214719.253873-1-peterx@redhat.com> References: <20240313214719.253873-1-peterx@redhat.com> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Peter Xu Add a variable to cache p4d in follow_p4d_mask(). It's a good practise to make sure all the following checks will have a consistent view of the entry. Signed-off-by: Peter Xu --- mm/gup.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index df83182ec72d..69a777f4fc5c 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -772,16 +772,17 @@ static struct page *follow_p4d_mask(struct vm_area_struct *vma, unsigned int flags, struct follow_page_context *ctx) { - p4d_t *p4d; + p4d_t *p4dp, p4d; - p4d = p4d_offset(pgdp, address); - if (p4d_none(*p4d)) + p4dp = p4d_offset(pgdp, address); + p4d = READ_ONCE(*p4dp); + if (p4d_none(p4d)) return no_page_table(vma, flags); - BUILD_BUG_ON(p4d_huge(*p4d)); - if (unlikely(p4d_bad(*p4d))) + BUILD_BUG_ON(p4d_huge(p4d)); + if (unlikely(p4d_bad(p4d))) return no_page_table(vma, flags); - return follow_pud_mask(vma, address, p4d, flags, ctx); + return follow_pud_mask(vma, address, p4dp, flags, ctx); } /** From patchwork Wed Mar 13 21:47:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1911877 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=UY4cbn0r; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=gandalf.ozlabs.org; envelope-from=srs0=3afe=kt=vger.kernel.org=sparclinux+bounces-659-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tw3zN0lyRz1ydl for ; Thu, 14 Mar 2024 08:48:16 +1100 (AEDT) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Tw3zN0WJNz4wck for ; Thu, 14 Mar 2024 08:48:16 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4Tw3zN0Sb6z4wcr; Thu, 14 Mar 2024 08:48:16 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: gandalf.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=UY4cbn0r; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.48.161; helo=sy.mirrors.kernel.org; envelope-from=sparclinux+bounces-659-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [147.75.48.161]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Tw3zN0LR0z4wck for ; Thu, 14 Mar 2024 08:48:15 +1100 (AEDT) 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 29189B21C29 for ; Wed, 13 Mar 2024 21:48:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7A3755A0F6; Wed, 13 Mar 2024 21:47:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UY4cbn0r" X-Original-To: sparclinux@vger.kernel.org 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 C0B2159150 for ; Wed, 13 Mar 2024 21:47:28 +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=1710366450; cv=none; b=pi98WRdrWo1Nb9WVmb/tqgGUYFSCSjwWO+fB3VjxNHfiRlSft40wfhM+iLxSDcL9pOJOe8HZiBoqHZpVLA1cpqjJFu/bEaqT+qJWFp96PdKrYT1fFDqslba9dLefTatF2nhoUWQy96Cq/mLNdol8KGnMe+pl5KgCgfvgIb2EFm0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710366450; c=relaxed/simple; bh=XKAmzhpmXEAjAsa42PYgBQQ2HzrzYrw3Lh5/ehBy8nY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MgBkuJ8ogexyvA1I6VzvxwlLhTs22oJpES5jV25+AoHoJ1uX6msX3Z2Q+9o9Z95dGkjIjW3W4SrABbvrmWhhQCW3ZRJSL+fbD9Hy2KhknxwA9ViH1LXUdUPZYYapAEeLN2zr6lM0nZkR0x9JtAlRsSHtf2RpuQ365nZsRlyHuhE= 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=UY4cbn0r; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710366447; 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=UY4cbn0roYv30RDpTReEcyjCDf5I+4gS0nRH3HY7jnKWAaL0CV9Hs+THIQWDhWQWKFe7Ym M6YL6OZKVB5I2CxmTD2NuDo5UaWbaSCXUCzhPM53LI9pxr/BjRZsck+uwUlcl6Ubt3U95+ AUh1Juq1BPN53tXeOTVEz+baEf1Jkh4= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-159-PKQ78KtLM42F-wvr9o-ckg-1; Wed, 13 Mar 2024 17:47:26 -0400 X-MC-Unique: PKQ78KtLM42F-wvr9o-ckg-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-690b5ad0e61so1037346d6.0 for ; Wed, 13 Mar 2024 14:47:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710366446; x=1710971246; 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=wsE1yktiivEtf7Halo4dtaF0SdObT+IpuSHykHX2cvjzJtyS7TNlBEqa7uErQBnpeF XVtCRtYGnTqZjaLg21o8xKW4zlBzZp2BcNkjWupFif5dEjXZYNh1DNYckiM7K/6ShmFY DG2IdPKDOCdz3bjs7xxHqeySCBS0y3BXF76BHBE3bOmbGRY33HkKIwFD1//fFCQ3XN2U PXAaXRvZFyk+x0+VWgBY6Ys9kjG1Nph2IABrkwVqXqJM1bgw00ru1SYfEtXgNgo75vvd c0o56pX+wgjeH/Bo7FxbVVHTdfwR4LVKv7k51aX7+6TukEFGGfL/JFuZAU5MEpPRwrUO amHA== X-Forwarded-Encrypted: i=1; AJvYcCUGx1AjBgZDM+v8NtNcEFq6reT3U0f+WHPjNv+/J5lxrig6eTLO+prR7hv3EADyuRT4Ox4WhFsQNqtZH/fYFAmkHuMn/p/ZZ0/aLQ== X-Gm-Message-State: AOJu0Yy3IwNCyyGw62i55UaVYvIK81E2Hl/UwvMmY1+hWfcyH0Y0fIa2 eDEuUYX1u+05m9hvzBoGap75mvbuLW7AUASvGEAjEJdPu7JkxHemvytksMTIMvMa8bZh+yC46Hj OxQqlGJ2Y6NOsrnyLKrINBGj5Gen1ygCwykvr1u3eYj8gty1sFLV5nPy9hzE= X-Received: by 2002:a0c:f508:0:b0:690:b02c:2a5f with SMTP id j8-20020a0cf508000000b00690b02c2a5fmr13464374qvm.4.1710366446022; Wed, 13 Mar 2024 14:47:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXIxC5CVGnx+p2qd8ZmV2KZnCoGCjWGy3mEq+yzfnYrTYJ2FsP7C7aom0bl0ipU8C23yK/Aw== X-Received: by 2002:a0c:f508:0:b0:690:b02c:2a5f with SMTP id j8-20020a0cf508000000b00690b02c2a5fmr13464349qvm.4.1710366445605; Wed, 13 Mar 2024 14:47:25 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id dv10-20020ad44eea000000b0069111c5cdd4sm60114qvb.100.2024.03.13.14.47.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 14:47:25 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org, Matthew Wilcox , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , x86@kernel.org, peterx@redhat.com, Mike Rapoport , Muchun Song , sparclinux@vger.kernel.org, Jason Gunthorpe Subject: [PATCH 03/13] mm/gup: Check p4d presence before going on Date: Wed, 13 Mar 2024 17:47:09 -0400 Message-ID: <20240313214719.253873-4-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313214719.253873-1-peterx@redhat.com> References: <20240313214719.253873-1-peterx@redhat.com> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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))))) { From patchwork Wed Mar 13 21:47:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1911879 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=YeQc9kMI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=gandalf.ozlabs.org; envelope-from=srs0=pbd9=kt=vger.kernel.org=sparclinux+bounces-660-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tw3zt6cl8z1ydl for ; Thu, 14 Mar 2024 08:48:42 +1100 (AEDT) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Tw3zt67Ssz4wcg for ; Thu, 14 Mar 2024 08:48:42 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4Tw3zt64pXz4wnr; Thu, 14 Mar 2024 08:48:42 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: gandalf.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=YeQc9kMI; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.48.161; helo=sy.mirrors.kernel.org; envelope-from=sparclinux+bounces-660-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [147.75.48.161]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Tw3zt60Fsz4wcg for ; Thu, 14 Mar 2024 08:48:42 +1100 (AEDT) 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6A9E4B221C0 for ; Wed, 13 Mar 2024 21:48:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 52E255BAD7; Wed, 13 Mar 2024 21:47:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YeQc9kMI" X-Original-To: sparclinux@vger.kernel.org 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 734E75A4E0 for ; Wed, 13 Mar 2024 21:47:30 +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=1710366453; cv=none; b=iptQwPxC7OV/XzUI2OJZPLXRO/Lr8Jtc8giSHglGzJXwnD3SIQJSwmB1W+flfvpC+aUfIn4FHSXtzqWZQmses5phXkgqI1e/RR20uu62ij3gvBC6twj1jDFaT8F7CiATID9yWZoe3VVFjulr0Xy1uP2mYGUPVQ21PeBLh9R1wvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710366453; c=relaxed/simple; bh=xsXv+igcIa2LD7vY6Lm1s+FcdmOPBabwjo2Ma8p3Wuc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N2JzxgVq9rTeMTh46F+4FkezAa2iR4D4zX7bEoyMqFEq8mLLQCyaGi0W5dk+QHp6YZSIF4iIUCEGBFINkpHA37NXu45dZAvyrsI4+c8HdV2P+TtCNdVk02436a9DRG/ZnJWAd9nChtS9af3J89YLvDSIm67m90/osr9CvVSWsLw= 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=YeQc9kMI; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710366449; 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=vtZJyICZEGrBJHpYWSu5beimQ7UmPGzVa4S5UCB/Dcs=; b=YeQc9kMIJnzFU21uNz/0XHapVQ9Ht6kAArhV6nFscCO+u4Lyrd/27NENelJ4Y9/ALASmOm mUtqIW2Q16T8MFmN3O4retQ4Kj3oRXPdyJxA3kgi+kOWh5ncoPkYkqdeNzVy7JWXF9ZpZN 7YdzHxsHD1HBpRIkZGAXFhBMPufFmPs= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-503-CfyRBOPCMEGfWcZb8xYazw-1; Wed, 13 Mar 2024 17:47:28 -0400 X-MC-Unique: CfyRBOPCMEGfWcZb8xYazw-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-690b5ad0e61so1037476d6.0 for ; Wed, 13 Mar 2024 14:47:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710366447; x=1710971247; 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=vtZJyICZEGrBJHpYWSu5beimQ7UmPGzVa4S5UCB/Dcs=; b=JnmK74NKCuNz7t0tdB8n7Xi5wq4dYxmz9x02rKHn2EK4nVe8rioAEyJ3vHhOOjdtBJ 0HeDZ26K5Jf9lSHVPUKLOvOoxVxYAbPXrU6x77ZoNXlu+ovzAUrYlqIRqE0QXds3uFtU E/87G/Ks9JAiyG9gXhzOrzPNrGURHNX+Bp39FaVZOQnAMrL8zt1iPGJ3ql5QjnoPSqDO aDFxD1DOACZxAXIbKH1pUjpjMwAHjcd57hMD0PUHj6c67+ACxHziHgF15c/xM5Jpuiaa kwr4dpJ7TT11lTf7kW0kNb9xFlsgkuy51azZ4KrGUdwDlwxYJndCIpLGtnqI4uRXfmky Z6Mw== X-Forwarded-Encrypted: i=1; AJvYcCV4zhNCkHgrwTnc/q0DQ1qbpteVwkqHiQtvcAAo3muHUG5YZ42pUiKJ7wWoQQP3/ZG2rrLzwP7n/piGrSYJmHPs76cQX/BRHPV7Hw== X-Gm-Message-State: AOJu0YxdjPzY1ILBYH0qx/ZWGLcDGehH2WXtejduloXexSTVnGe3jQqf QmzN3ZzLbCiCXb2m4XYfmmSgbqlgfOZ5RK4HXh7NtERh04LtER8WStb1INeGIZxToOahPRpvmyQ wL7nP+2mZyzmV3LnDE+a0yVwgJqDA6OwRrvREDUp0mMzhqjB/aueoY7xRfgA= X-Received: by 2002:a0c:f508:0:b0:690:b02c:2a5f with SMTP id j8-20020a0cf508000000b00690b02c2a5fmr13464422qvm.4.1710366447570; Wed, 13 Mar 2024 14:47:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHIi4iLkgKJ4BRvvEEi/kkT0r+z7XC1hachuRmolyjwCQk4v8XzYiXmWJ7FNVheaziOarzFKQ== X-Received: by 2002:a0c:f508:0:b0:690:b02c:2a5f with SMTP id j8-20020a0cf508000000b00690b02c2a5fmr13464414qvm.4.1710366447219; Wed, 13 Mar 2024 14:47:27 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id dv10-20020ad44eea000000b0069111c5cdd4sm60114qvb.100.2024.03.13.14.47.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 14:47:26 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org, Matthew Wilcox , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , x86@kernel.org, peterx@redhat.com, Mike Rapoport , Muchun Song , sparclinux@vger.kernel.org, Jason Gunthorpe , Naoya Horiguchi , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen Subject: [PATCH 04/13] mm/x86: Change pXd_huge() behavior to exclude swap entries Date: Wed, 13 Mar 2024 17:47:10 -0400 Message-ID: <20240313214719.253873-5-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313214719.253873-1-peterx@redhat.com> References: <20240313214719.253873-1-peterx@redhat.com> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Peter Xu This patch partly reverts below commits: 3a194f3f8ad0 ("mm/hugetlb: make pud_huge() and follow_huge_pud() aware of non-present pud entry") cbef8478bee5 ("mm/hugetlb: pmd_huge() returns true for non-present hugepage") Right now, pXd_huge() definition across kernel is unclear. We have two groups that think differently on swap entries: - x86/sparc: Allow pXd_huge() to accept swap entries - all the rest: Doesn't allow pXd_huge() to accept swap entries This is so confusing. Since the sparc helpers seem to be added in 2016, which is after x86's (2015), so sparc could have followed a trend. x86 proposed such swap handling in 2015 to resolve hugetlb swap entries hit in GUP, but now GUP guards swap entries with !pXd_present() in all layers so we should be safe. We should define this API properly, one way or another, rather than keep them defined differently across archs. Gut feeling tells me that pXd_huge() shouldn't include swap entries, and it turns out that I am not the only one thinking so, the question was raised when the current pmd_huge() for x86 was proposed by Ville Syrjälä: https://lore.kernel.org/all/Y2WQ7I4LXh8iUIRd@intel.com/ I might also be missing something obvious, but why is it even necessary to treat PRESENT==0+PSE==0 as a huge entry? It is also questioned when Jason Gunthorpe reviewed the other patchset on swap entry handlings: https://lore.kernel.org/all/20240221125753.GQ13330@nvidia.com/ Revert its meaning back to original. It shouldn't have any functional change as we should be ready with guards on !pXd_present() explicitly everywhere. Note that I also dropped the "#if CONFIG_PGTABLE_LEVELS > 2", it was there probably because it was breaking things when 3a194f3f8ad0 was proposed, according to the report here: https://lore.kernel.org/all/Y2LYXItKQyaJTv8j@intel.com/ Now we shouldn't need that. Instead of reverting to _PAGE_PSE raw check, leverage pXd_leaf(). Cc: Naoya Horiguchi Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: x86@kernel.org Signed-off-by: Peter Xu --- arch/x86/mm/hugetlbpage.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c index 5804bbae4f01..8362953a24ce 100644 --- a/arch/x86/mm/hugetlbpage.c +++ b/arch/x86/mm/hugetlbpage.c @@ -20,29 +20,19 @@ #include /* - * pmd_huge() returns 1 if @pmd is hugetlb related entry, that is normal - * hugetlb entry or non-present (migration or hwpoisoned) hugetlb entry. - * Otherwise, returns 0. + * pmd_huge() returns 1 if @pmd is hugetlb related entry. */ int pmd_huge(pmd_t pmd) { - return !pmd_none(pmd) && - (pmd_val(pmd) & (_PAGE_PRESENT|_PAGE_PSE)) != _PAGE_PRESENT; + return pmd_leaf(pmd); } /* - * pud_huge() returns 1 if @pud is hugetlb related entry, that is normal - * hugetlb entry or non-present (migration or hwpoisoned) hugetlb entry. - * Otherwise, returns 0. + * pud_huge() returns 1 if @pud is hugetlb related entry. */ int pud_huge(pud_t pud) { -#if CONFIG_PGTABLE_LEVELS > 2 - return !pud_none(pud) && - (pud_val(pud) & (_PAGE_PRESENT|_PAGE_PSE)) != _PAGE_PRESENT; -#else - return 0; -#endif + return pud_leaf(pud); } #ifdef CONFIG_HUGETLB_PAGE From patchwork Wed Mar 13 21:47:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1911880 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=LB8wzJ78; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=gandalf.ozlabs.org; envelope-from=srs0=xb4c=kt=vger.kernel.org=sparclinux+bounces-661-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tw3zw3dR7z1ydl for ; Thu, 14 Mar 2024 08:48:44 +1100 (AEDT) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Tw3zw39Ryz4wcg for ; Thu, 14 Mar 2024 08:48:44 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4Tw3zw36XTz4wcr; Thu, 14 Mar 2024 08:48:44 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: gandalf.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=LB8wzJ78; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=sparclinux+bounces-661-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Tw3zw0psJz4wcg for ; Thu, 14 Mar 2024 08:48:44 +1100 (AEDT) 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CD8E228A993 for ; Wed, 13 Mar 2024 21:48:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6718F5C606; Wed, 13 Mar 2024 21:47:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LB8wzJ78" X-Original-To: sparclinux@vger.kernel.org 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 9577E5A78A for ; Wed, 13 Mar 2024 21:47:31 +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=1710366453; cv=none; b=JnO53qmVTtmikF8DVflhzsHX095inAbuOaqQUlmWkNhULAkg7AOB08DRdd9s8sDL6cd85kB+H9glu7gegjS6vPZsUvkLG8IxHmWhtfHMS+CSUZ0e06t0gBEbxuqug0Y8vEo52wnQi1lmFMfpjv/vrqhH2Xb4i3Mn5Oj39GTr04o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710366453; c=relaxed/simple; bh=iHHSvsdkBOFub0mcOT/89y75sePdz9RiRVPlZT5QMlQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ve/eBDzQ2fw5Sadps3RDxCWdSG925K1BBoCfUW5d3b9fUtX7douC3NGxlHOjNp7PQ+yrGetP5E3fhj3C3QcSQsjCKItxYDc7a6C/zGJW48yoC0DzyiumNMOq2CG8DvjwQ3W8QKJrAtXSrHB+vsvyF/WB3YCHyoBvEWGjHndmDX4= 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=LB8wzJ78; 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=1710366450; 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=dXyJDuJosTa0kFBnhKvW1aqbtapsaxz0OHU+bPr+fnc=; b=LB8wzJ78SlFuj+V7wiruUtcK0Vzk5PHrJ5e3qM6DdeFc9ECKcrK9pJsCD7dAIRUQI3HvIa eZID2Y5Wbv/DQnjP3Xuuv8BRAtMeGEnNY1R/9pgGHH4RFAqEuAkFcyYNAY1HOrfWFpp81w MH5Ptbtnyl/w/iiETFNhLF/KGt0IsbI= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-388-k5CjuGDLMLCpu-n3mx7eqA-1; Wed, 13 Mar 2024 17:47:29 -0400 X-MC-Unique: k5CjuGDLMLCpu-n3mx7eqA-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6818b8cb840so989036d6.1 for ; Wed, 13 Mar 2024 14:47:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710366449; x=1710971249; 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=dXyJDuJosTa0kFBnhKvW1aqbtapsaxz0OHU+bPr+fnc=; b=lcwJttYkI5DtnIQBP0Fm7cKaJMWTM81MnTveRUakO3g/QbSlq9EWjbhYDXtCvACBnq 1HP89OyK4TsFkNpD1j/4+BghwyD4t3oJ71rOoC2mtVMQpsy23O6/fd6CWrM9+cMnDlFI homf8Yb3mVx17VaoRFYTvt0UdlksFYxHPx0fVzEcD5T1MoGFpow1by3S/d3J+2N4ZIf1 GnkD17ABk8Anu1PMPdWKQWUNlS8EJpn+K6FR/kdJy3Lc2tJTBWlNzaU8j8YK50z/cBFq 9DmtZ/A4f1WoVRjzvd4GryHl563Ux4h1LYHUL8ZqcZ1F1s4PfzilrMy068tr9QkMVcAU G2og== X-Forwarded-Encrypted: i=1; AJvYcCWrgUbKPYY6yRqqDiulrGNxAhwgmKvcihEzjY0/5NXz8g3fRCnsLV/YTn8TOzrLizAqVeSa+zKxGTVgSemSRngL7oJ22YgWWLznsg== X-Gm-Message-State: AOJu0YwbWm4wOs0R1XSJfAsof8+5TwI3Npa8RULtpkwZDgNPqJ8L06Pa tDxoKAFRWqW+1u2G4ggysaF5L9VeJuraYAeV00wRN8FChccuOj3qqQYwyO2yyP7p3TmH8NmCY+4 N6yeDw+0vpKYacuF4H+dHIFNsfF5ELVLDMnqMjDRVMiiGzoUKXt1OyGsQfSU= X-Received: by 2002:a05:6214:aa7:b0:690:d74d:7e6d with SMTP id ew7-20020a0562140aa700b00690d74d7e6dmr2881504qvb.3.1710366448978; Wed, 13 Mar 2024 14:47:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELbWWxNSgYU6xiV6giMb0Xazy3M+lqNjbyiI8S6tM3m0hmfGtXABqH+Dtrq87Nz5UyrTDJQA== X-Received: by 2002:a05:6214:aa7:b0:690:d74d:7e6d with SMTP id ew7-20020a0562140aa700b00690d74d7e6dmr2881487qvb.3.1710366448612; Wed, 13 Mar 2024 14:47:28 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id dv10-20020ad44eea000000b0069111c5cdd4sm60114qvb.100.2024.03.13.14.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 14:47:28 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org, Matthew Wilcox , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , x86@kernel.org, peterx@redhat.com, Mike Rapoport , Muchun Song , sparclinux@vger.kernel.org, Jason Gunthorpe , "David S . Miller" , Andreas Larsson Subject: [PATCH 05/13] mm/sparc: Change pXd_huge() behavior to exclude swap entries Date: Wed, 13 Mar 2024 17:47:11 -0400 Message-ID: <20240313214719.253873-6-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313214719.253873-1-peterx@redhat.com> References: <20240313214719.253873-1-peterx@redhat.com> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Peter Xu Please refer to the previous patch on the reasoning for x86. Now sparc is the only architecture that will allow swap entries to be reported as pXd_huge(). After this patch, all architectures should forbid swap entries in pXd_huge(). Cc: David S. Miller Cc: Andreas Larsson Cc: sparclinux@vger.kernel.org Signed-off-by: Peter Xu --- arch/sparc/mm/hugetlbpage.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c index b432500c13a5..d31c2cec35c9 100644 --- a/arch/sparc/mm/hugetlbpage.c +++ b/arch/sparc/mm/hugetlbpage.c @@ -409,14 +409,12 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, int pmd_huge(pmd_t pmd) { - return !pmd_none(pmd) && - (pmd_val(pmd) & (_PAGE_VALID|_PAGE_PMD_HUGE)) != _PAGE_VALID; + return pmd_leaf(pmd);; } int pud_huge(pud_t pud) { - return !pud_none(pud) && - (pud_val(pud) & (_PAGE_VALID|_PAGE_PUD_HUGE)) != _PAGE_VALID; + return pud_leaf(pud); } static void hugetlb_free_pte_range(struct mmu_gather *tlb, pmd_t *pmd, From patchwork Wed Mar 13 21:47:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1911881 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=N1m7E5Et; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=gandalf.ozlabs.org; envelope-from=srs0=z6uf=kt=vger.kernel.org=sparclinux+bounces-662-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tw40D2RT2z1ydl for ; Thu, 14 Mar 2024 08:49:00 +1100 (AEDT) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Tw40D1ymjz4wck for ; Thu, 14 Mar 2024 08:49:00 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4Tw40D1wBKz4wcr; Thu, 14 Mar 2024 08:49:00 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: gandalf.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=N1m7E5Et; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=sparclinux+bounces-662-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Tw40D1q5xz4wck for ; Thu, 14 Mar 2024 08:49:00 +1100 (AEDT) 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D50FBB22278 for ; Wed, 13 Mar 2024 21:48:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D10F5D8EE; Wed, 13 Mar 2024 21:47:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="N1m7E5Et" X-Original-To: sparclinux@vger.kernel.org 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 698F25C611 for ; Wed, 13 Mar 2024 21:47:33 +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=1710366455; cv=none; b=m+vw6gELXN8NP7BUHtzWcNDxnv/CtIVdyAucRit+11WV9NA8JSLEoV1k5h/O+1Zgif1viEpY7V5+FXQ+HVW2qqQk2TXjvsEkoJ5fFDUaUmfEoKbfCl2W1XyrQYYH54l8Iuh9SaUkPZlSO8bdPJ+nI8a7I+7w2tuuLGOnpgxKXac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710366455; c=relaxed/simple; bh=udgt5BojDZ8EVWkeL4uhl2LfvjHvU9M2T020easV1nc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i8cI9zjZ7G9Lcolr8HGnntdneiC2bD5uC9v9CrBvAFCxCjUqS1I43JxAIidUFsZ+ED036Fm2nTRvnpklr7MOeWym+dGc92S1yb7qHUW4Zi5vlOLb57KHfNKcGt/bMSm53rS/wCvrrb+kUSVdw3cyyKVmDd1LLAXPoP6e5Y3jEeY= 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=N1m7E5Et; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710366452; 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=PXv9WADGZnpW9LG755UO1HRR+yBh/xYRmZG+iRDILn4=; b=N1m7E5EtoD45RmFLL1vaVjkpqyolkGFwfJo7NpA8diw6gJMRPPpWuSLArHe1r/2JcFPz7H McUh9aC6+ZCxTe2oru++pBkikRyuKCNTRmGG7lMq86TgKxVmml/QLBUcJoGYR/9167nn7c ecCecrp7oGvrLCyOCUrc5eTB/vgo64g= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-477-rbQePjr7N7ykC6fvUkhgyA-1; Wed, 13 Mar 2024 17:47:31 -0400 X-MC-Unique: rbQePjr7N7ykC6fvUkhgyA-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6818b8cb840so989196d6.1 for ; Wed, 13 Mar 2024 14:47:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710366450; x=1710971250; 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=PXv9WADGZnpW9LG755UO1HRR+yBh/xYRmZG+iRDILn4=; b=FOO20EWN31q6TX78knuH4Tq1JS/OFe6cSu3UrH2AVEQELU5gCiFU8PjUj5Z9TVTYRc Z9HOj6dPPkpfihcSu8/k+mGLBlijPpA6g3RyXYR+oKCjmku+EP/GdQKuDOc7NjaUUylD DcZ8UyepGiasoj9nOtSsdlp1od9YKz/SdFQ12F13l8IXq+SE2/kiqjemPA/Pve2tjpvO A7tPvHrGUwuIrf+ZE+8DCUKryUJQZoL3fbyLtHQcCGxSkRbHVsWh4nLdOt5fC5f0mAfj Ue3C6tiMD5OAQnZYXwp+S0tPHjiY4LUYQoIvolVSDJz/w3At8vp0ZQwSJOAYww/JdyA8 WGDQ== X-Forwarded-Encrypted: i=1; AJvYcCWK3YXzZX0AB5J8/Z1Cmb6C3G/WIW0ogJsIwt/69ImrC6pnXkfnijWPuqPOwL/d3EAtc5ws5TTqRmW+9NPntIxlFXQilSACuz1fOg== X-Gm-Message-State: AOJu0YyUOsHozyLvNORPDHd5utNXVKSWJlC7/AHGELkZPBf50MLFGCyd oiAOv9Pozdu28bRMrTDwQNFtPf3ppO6aGzwiICc2Q4ioszmV3eNA6bgcI5ap6QkUyy71NvzbozE DyE4iD/svBRp6YMVt6tiTyq8S6RGnghdBCVPVoBJEvhzT6mOOii1Z0i+bOSA= X-Received: by 2002:a05:6214:ca1:b0:690:ca31:f070 with SMTP id s1-20020a0562140ca100b00690ca31f070mr2870213qvs.2.1710366450569; Wed, 13 Mar 2024 14:47:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7R1Abf8N+n3Ay4Ttv5JPf4Xs41/taFQJ/1rB/5tSFgWpT6oJW7WbEayo47shzOXV0M53hEQ== X-Received: by 2002:a05:6214:ca1:b0:690:ca31:f070 with SMTP id s1-20020a0562140ca100b00690ca31f070mr2870205qvs.2.1710366450230; Wed, 13 Mar 2024 14:47:30 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id dv10-20020ad44eea000000b0069111c5cdd4sm60114qvb.100.2024.03.13.14.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 14:47:29 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org, Matthew Wilcox , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , x86@kernel.org, peterx@redhat.com, Mike Rapoport , Muchun Song , sparclinux@vger.kernel.org, Jason Gunthorpe , Russell King , Shawn Guo , Krzysztof Kozlowski , Bjorn Andersson , Arnd Bergmann , Konrad Dybcio , Fabio Estevam Subject: [PATCH 06/13] mm/arm: Use macros to define pmd/pud helpers Date: Wed, 13 Mar 2024 17:47:12 -0400 Message-ID: <20240313214719.253873-7-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313214719.253873-1-peterx@redhat.com> References: <20240313214719.253873-1-peterx@redhat.com> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Peter Xu It's already confusing that ARM 2-level v.s. 3-level defines SECT bit differently on pmd/puds. Always use a macro which is much clearer. Cc: Russell King Cc: Shawn Guo Cc: Krzysztof Kozlowski Cc: Bjorn Andersson Cc: Arnd Bergmann Cc: Konrad Dybcio Cc: Fabio Estevam Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Peter Xu --- arch/arm/include/asm/pgtable-2level.h | 4 ++-- arch/arm/include/asm/pgtable-3level-hwdef.h | 1 + arch/arm/include/asm/pgtable-3level.h | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h index b0a262566eb9..4245c2e74720 100644 --- a/arch/arm/include/asm/pgtable-2level.h +++ b/arch/arm/include/asm/pgtable-2level.h @@ -213,8 +213,8 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr) #define pmd_pfn(pmd) (__phys_to_pfn(pmd_val(pmd) & PHYS_MASK)) -#define pmd_leaf(pmd) (pmd_val(pmd) & 2) -#define pmd_bad(pmd) (pmd_val(pmd) & 2) +#define pmd_leaf(pmd) (pmd_val(pmd) & PMD_TYPE_SECT) +#define pmd_bad(pmd) pmd_leaf(pmd) #define pmd_present(pmd) (pmd_val(pmd)) #define copy_pmd(pmdpd,pmdps) \ diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h index 2f35b4eddaa8..e7b666cf0060 100644 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h @@ -14,6 +14,7 @@ * + Level 1/2 descriptor * - common */ +#define PUD_TABLE_BIT (_AT(pmdval_t, 1) << 1) #define PMD_TYPE_MASK (_AT(pmdval_t, 3) << 0) #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0) #define PMD_TYPE_TABLE (_AT(pmdval_t, 3) << 0) diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h index 4b1d9eb3908a..e7aecbef75c9 100644 --- a/arch/arm/include/asm/pgtable-3level.h +++ b/arch/arm/include/asm/pgtable-3level.h @@ -112,7 +112,7 @@ #ifndef __ASSEMBLY__ #define pud_none(pud) (!pud_val(pud)) -#define pud_bad(pud) (!(pud_val(pud) & 2)) +#define pud_bad(pud) (!(pud_val(pud) & PUD_TABLE_BIT)) #define pud_present(pud) (pud_val(pud)) #define pmd_table(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) == \ PMD_TYPE_TABLE) @@ -137,7 +137,7 @@ static inline pmd_t *pud_pgtable(pud_t pud) return __va(pud_val(pud) & PHYS_MASK & (s32)PAGE_MASK); } -#define pmd_bad(pmd) (!(pmd_val(pmd) & 2)) +#define pmd_bad(pmd) (!(pmd_val(pmd) & PMD_TABLE_BIT)) #define copy_pmd(pmdpd,pmdps) \ do { \ From patchwork Wed Mar 13 21:47:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1911883 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=ZJhpHYXK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=gandalf.ozlabs.org; envelope-from=srs0=bxzh=kt=vger.kernel.org=sparclinux+bounces-663-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tw40T5D9Hz1ydl for ; Thu, 14 Mar 2024 08:49:13 +1100 (AEDT) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Tw40T4msHz4wnr for ; Thu, 14 Mar 2024 08:49:13 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4Tw40T4kB1z4wck; Thu, 14 Mar 2024 08:49:13 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: gandalf.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=ZJhpHYXK; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.80.249; helo=am.mirrors.kernel.org; envelope-from=sparclinux+bounces-663-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [147.75.80.249]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Tw40T0dr6z4wnr for ; Thu, 14 Mar 2024 08:49:13 +1100 (AEDT) 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 974C81F242E8 for ; Wed, 13 Mar 2024 21:49:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5ED245EE69; Wed, 13 Mar 2024 21:47:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZJhpHYXK" X-Original-To: sparclinux@vger.kernel.org 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 4D9E55D732 for ; Wed, 13 Mar 2024 21:47:34 +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=1710366457; cv=none; b=Hu4vY0J2QBnuOZqDzUqH6CavB6eN2J00ZIa0Zx/6AiLKwcaGSdxEKDbeTNOQjLI7PG3ZB3djylKleLw+cBlBQFpv9dJTCkEOBJBjkvTbr6hCEOMuOyNCMC6H7uCf26BJbpOzlvq2Nvo6/FoZQbrp8VM1bXFvTYeb0F+rgXMfmq0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710366457; c=relaxed/simple; bh=5RHxSgtdvJKVCp5Pr7PrdSJPxWg3TC/UA6xoLVOm0PY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PF2PuJSW3ALBLEOjaTno9npWPwFnKKnz1rMz759Yx+/+qMJCP9j5Yr1CMDjZqxjbZQW4+QLwDOLyvwOarOiNfHOwdeVAb+zWs/d2z78/QQNhH7tmf5U5G/ctKhGARTmFIbXjkLPTpjGn5fu69R1vvPKyMhJRYyN0Nzi9gSOrm2c= 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=ZJhpHYXK; 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=1710366454; 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=4C+lWpN1qDfU+nymiqOVXkY7IqPiijqTb8F5rFjpmTU=; b=ZJhpHYXKVjrATAR8XHea/x7zYtAkLc2gejiIqLzppBqOFVON1ZgRUuNaSvpf8iKklzLiRY pQpZH4pHu1dLfvfvolCeKVdZjPGRNglmsxs6+gh+dQczRQMabTBTrmXPrEi2l9XSuvZnIP 51btbbN7ZUPOH7oMA+3d03nloMd319g= Received: from mail-ua1-f70.google.com (mail-ua1-f70.google.com [209.85.222.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-414-CWsnkFddPMi2HQXGQLtwrQ-1; Wed, 13 Mar 2024 17:47:32 -0400 X-MC-Unique: CWsnkFddPMi2HQXGQLtwrQ-1 Received: by mail-ua1-f70.google.com with SMTP id a1e0cc1a2514c-7da965e700fso36736241.1 for ; Wed, 13 Mar 2024 14:47:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710366452; x=1710971252; 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=4C+lWpN1qDfU+nymiqOVXkY7IqPiijqTb8F5rFjpmTU=; b=sggDAO1kMGIjCaruWdGNJZoN/TJDbMoqk+bDfOslUxcYgCshKKRnOaNg95qZEohdYV 1cdNSvlbnKGGy4f4FKp1N1JJLfxy7f1FSEyDI10vIoX+liLH+wWogTypHeFsBeiiesjH 75B52cFwrwtLW82R7yKSpQ4MTMYh1UxWlLsQXjhOZsIK37DrbuEadkqJF9+ADbjofZ2V dIUv8FJ+xqmKdG4HxajjENraey5tNBZuUf9dz1r/VG5RsWnGNFsgdX6AEEDqnPh2hkNB 6HyVFUNBJnVdkPhyX4ovIcpMDvnsceRYJXc9R5V7lotMlJh8Cz42xZUCpF29YKv+CdTC UjwQ== X-Forwarded-Encrypted: i=1; AJvYcCW9C1p4WWpLrP4dQhWwuHyGnJfKgUmoBrDnjLWChwqaCPsTJXT+uRrfBO22LOkzw89bJTUd5UAhF8c6cPlCpBF4QZkidGY7Ck6gIg== X-Gm-Message-State: AOJu0Yz7J8QmOLo2FZZzC1TRG9ZWi07OLTj+Md1XXz3UQSC/oTvBbMy9 BPe2kcNueVZmOBoFnV6EfGZPVU0OL4Vm0HZRmEq5MMNAYKFR1Y2nXFEEqVejULPHuPmhj/JCpRg 0bzt1VzWZz2tiJrRGDnL+a/w4bLeDKX2CGbnoKqBo6HQXdu+FnGtKtrLY5Sc= X-Received: by 2002:a05:6102:22c3:b0:474:974a:9262 with SMTP id a3-20020a05610222c300b00474974a9262mr178624vsh.2.1710366452190; Wed, 13 Mar 2024 14:47:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHbMJFgovzI2kAdigpD7SPTonoPokqIJ0+3R0neH2rsizaH6LOW92IcmRgIzS4nmmpWup5Ig== X-Received: by 2002:a05:6102:22c3:b0:474:974a:9262 with SMTP id a3-20020a05610222c300b00474974a9262mr178595vsh.2.1710366451805; Wed, 13 Mar 2024 14:47:31 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id dv10-20020ad44eea000000b0069111c5cdd4sm60114qvb.100.2024.03.13.14.47.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 14:47:31 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org, Matthew Wilcox , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , x86@kernel.org, peterx@redhat.com, Mike Rapoport , Muchun Song , sparclinux@vger.kernel.org, Jason Gunthorpe , Russell King , Shawn Guo , Krzysztof Kozlowski , Bjorn Andersson , Arnd Bergmann , Konrad Dybcio , Fabio Estevam Subject: [PATCH 07/13] mm/arm: Redefine pmd_huge() with pmd_leaf() Date: Wed, 13 Mar 2024 17:47:13 -0400 Message-ID: <20240313214719.253873-8-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313214719.253873-1-peterx@redhat.com> References: <20240313214719.253873-1-peterx@redhat.com> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Peter Xu Most of the archs already define these two APIs the same way. ARM is more complicated in two aspects: - For pXd_huge() it's always checking against !PXD_TABLE_BIT, while for pXd_leaf() it's always checking against PXD_TYPE_SECT. - SECT/TABLE bits are defined differently on 2-level v.s. 3-level ARM pgtables, which makes the whole thing even harder to follow. Luckily, the second complexity should be hidden by the pmd_leaf() implementation against 2-level v.s. 3-level headers. Invoke pmd_leaf() directly for pmd_huge(), to remove the first part of complexity. This prepares to drop pXd_huge() API globally. When at it, drop the obsolete comments - it's outdated. Cc: Russell King Cc: Shawn Guo Cc: Krzysztof Kozlowski Cc: Bjorn Andersson Cc: Arnd Bergmann Cc: Konrad Dybcio Cc: Fabio Estevam Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Peter Xu --- arch/arm/mm/hugetlbpage.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/arm/mm/hugetlbpage.c b/arch/arm/mm/hugetlbpage.c index dd7a0277c5c0..c2fa643f6bb5 100644 --- a/arch/arm/mm/hugetlbpage.c +++ b/arch/arm/mm/hugetlbpage.c @@ -18,11 +18,6 @@ #include #include -/* - * On ARM, huge pages are backed by pmd's rather than pte's, so we do a lot - * of type casting from pmd_t * to pte_t *. - */ - int pud_huge(pud_t pud) { return 0; @@ -30,5 +25,5 @@ int pud_huge(pud_t pud) int pmd_huge(pmd_t pmd) { - return pmd_val(pmd) && !(pmd_val(pmd) & PMD_TABLE_BIT); + return pmd_leaf(pmd); } From patchwork Wed Mar 13 21:47:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1911884 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=SBeQCrtn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=gandalf.ozlabs.org; envelope-from=srs0=i+0o=kt=vger.kernel.org=sparclinux+bounces-664-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tw40Z3y3Kz1ydl for ; Thu, 14 Mar 2024 08:49:18 +1100 (AEDT) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Tw40Z3Swsz4wc9 for ; Thu, 14 Mar 2024 08:49:18 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4Tw40Z3P4tz4wcg; Thu, 14 Mar 2024 08:49:18 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: gandalf.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=SBeQCrtn; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=sparclinux+bounces-664-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Tw40Z15sRz4wc9 for ; Thu, 14 Mar 2024 08:49:18 +1100 (AEDT) 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id DD287288874 for ; Wed, 13 Mar 2024 21:49:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9203C56B72; Wed, 13 Mar 2024 21:47:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SBeQCrtn" X-Original-To: sparclinux@vger.kernel.org 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 224BA5E066 for ; Wed, 13 Mar 2024 21:47:36 +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=1710366459; cv=none; b=c1dhz8bfd9MsqCSzu+6wH4NC7Kmlp4kczvKLpkfcIqdIodEKvBSnju+3P+WpHykqsUi/NfxYFHdTcNVj9VWpZT9oPWdUiAkK1YyBFTrNY/+AD0HIkLeltjkY8fvneHWpSIA/sBhXb2g9rR61ijoPFCM3I57kRGAdtZ8oiD1oC2E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710366459; c=relaxed/simple; bh=t18R28ny76a7TFkmozYcxNFR6pN9FqPc0sZ3mbG+iGw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dKwH/wMohEczlrYwCuYHQObpr5kA18j6/FlwYyaDgKf8mstXf9QXGXsIEpDcJ6D3TiAS/AV8nT9jycR1tGN88/SlR5GZW8Jmz5Zqsm4/mQGlpZGShdlX0PgurMEF9/NHWbsTHo8+sAQCxDoZEX8//2etXSL1HHrQDOXgLvCB3+s= 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=SBeQCrtn; 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=1710366455; 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=xZurg04juSYF/uW9HtnhgkfMM1C/gArxmrpoVNEgvCQ=; b=SBeQCrtnqHalaF4ij/nFhZNiI+eARsbmV8yx4QsCtNna3JCa4lJ+8rGd3lRzXcXeM8wohm qJN9LS5pXgMNewiDDcDNW9aMhXgU8/VQEAs6HswGtID701FRuXbzkf5+PDDA/Ofw0x5+Qs AduHSVOOgpAUgK3iubymWDp1e+/DXG4= Received: from mail-vs1-f72.google.com (mail-vs1-f72.google.com [209.85.217.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-326-vpVrU8myMv2cIP8S-Ob_eQ-1; Wed, 13 Mar 2024 17:47:34 -0400 X-MC-Unique: vpVrU8myMv2cIP8S-Ob_eQ-1 Received: by mail-vs1-f72.google.com with SMTP id ada2fe7eead31-4730797bef9so2624137.1 for ; Wed, 13 Mar 2024 14:47:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710366453; x=1710971253; 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=xZurg04juSYF/uW9HtnhgkfMM1C/gArxmrpoVNEgvCQ=; b=Pq4Lur2C765Nj+sRcJPIbnDBZ7xmGnKlSegZ9FXY5ajAyfu7G1LGZVyHSHTZ/rd1U9 KLsxnYeM/XukQ/NR5W0CBTe1V1JwYxxeZ1FW8kELuMc+DbRonYMPJuxCcxRSolzXPj7i 9z30TabXE3sST2PwoxGspy8bejaN/gvcWKtdcqtTVy6kSBQ8AqAPUPy8IVQcRSSBfKnQ VzSJfRfVtyvHSYm7y6WbxX9VS6J+XnQhrHhZeGJqckXXOyWTZ8EHWVfYfPLLTfk7MnBQ 56emCkQyiI8d4HHSGkVwWTZBBmleDWa7Hg1ygda2Xq+paJ4unHCxZYV79yD7TWSBoWkh MlkQ== X-Forwarded-Encrypted: i=1; AJvYcCU1AjgYmcBDefrGz9vr7yuhv5JyLsslmfr/GlD69Ik7ss8k1M7rnoDw85FxQOHVsQHNqEEjflvEryzFRIiupS9097X2R0QWAfXhwg== X-Gm-Message-State: AOJu0Yz4e5cb5ZAk3zbOZWegjXx7BMsbvCk+CDSnNdxIK9PuKRZaR6kN jwDWsqONphy5QLELI1DMzyEBTsEulbRhDIbVBxWU28fjwTgsvYsZlzkSWsG9n+5aFm0R/aBnZD2 ola6JPrLMxECN5NvOFhTohZFwoGsdDTfKBhpIhl+5uza4iFxdkOhXti6UHt4= X-Received: by 2002:a05:6102:5492:b0:474:d28c:2ac5 with SMTP id bk18-20020a056102549200b00474d28c2ac5mr243712vsb.0.1710366453595; Wed, 13 Mar 2024 14:47:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkTENrzWBEROMNgSFXQjsM78hPZrMM1UORfrrvjF9qoLUGsHb0Hjw+2mHy3NCjFs/y6Z4aCg== X-Received: by 2002:a05:6102:5492:b0:474:d28c:2ac5 with SMTP id bk18-20020a056102549200b00474d28c2ac5mr243694vsb.0.1710366453272; Wed, 13 Mar 2024 14:47:33 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id dv10-20020ad44eea000000b0069111c5cdd4sm60114qvb.100.2024.03.13.14.47.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 14:47:32 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org, Matthew Wilcox , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , x86@kernel.org, peterx@redhat.com, Mike Rapoport , Muchun Song , sparclinux@vger.kernel.org, Jason Gunthorpe , Mark Salter , Catalin Marinas , Will Deacon Subject: [PATCH 08/13] mm/arm64: Merge pXd_huge() and pXd_leaf() definitions Date: Wed, 13 Mar 2024 17:47:14 -0400 Message-ID: <20240313214719.253873-9-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313214719.253873-1-peterx@redhat.com> References: <20240313214719.253873-1-peterx@redhat.com> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Peter Xu Unlike most archs, aarch64 defines pXd_huge() and pXd_leaf() slightly differently. Redefine the pXd_huge() with pXd_leaf(). There used to be two traps for old aarch64 definitions over these APIs that I found when reading the code around, they're: (1) 4797ec2dc83a ("arm64: fix pud_huge() for 2-level pagetables") (2) 23bc8f69f0ec ("arm64: mm: fix p?d_leaf()") Define pXd_huge() with the current pXd_leaf() will make sure (2) isn't a problem (on PROT_NONE checks). To make sure it also works for (1), we move over the __PAGETABLE_PMD_FOLDED check to pud_leaf(), allowing it to constantly returning "false" for 2-level pgtables, which looks even safer to cover both now. Cc: Muchun Song Cc: Mark Salter Cc: Catalin Marinas Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Peter Xu --- arch/arm64/include/asm/pgtable.h | 4 ++++ arch/arm64/mm/hugetlbpage.c | 8 ++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 401087e8a43d..14d24c357c7a 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -704,7 +704,11 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd) #define pud_none(pud) (!pud_val(pud)) #define pud_bad(pud) (!pud_table(pud)) #define pud_present(pud) pte_present(pud_pte(pud)) +#ifndef __PAGETABLE_PMD_FOLDED #define pud_leaf(pud) (pud_present(pud) && !pud_table(pud)) +#else +#define pud_leaf(pud) false +#endif #define pud_valid(pud) pte_valid(pud_pte(pud)) #define pud_user(pud) pte_user(pud_pte(pud)) #define pud_user_exec(pud) pte_user_exec(pud_pte(pud)) diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 0f0e10bb0a95..1234bbaef5bf 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -81,16 +81,12 @@ bool arch_hugetlb_migration_supported(struct hstate *h) int pmd_huge(pmd_t pmd) { - return pmd_val(pmd) && !(pmd_val(pmd) & PMD_TABLE_BIT); + return pmd_leaf(pmd); } int pud_huge(pud_t pud) { -#ifndef __PAGETABLE_PMD_FOLDED - return pud_val(pud) && !(pud_val(pud) & PUD_TABLE_BIT); -#else - return 0; -#endif + return pud_leaf(pud); } static int find_num_contig(struct mm_struct *mm, unsigned long addr, From patchwork Wed Mar 13 21:47:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1911885 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=KqWOTs1c; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=gandalf.ozlabs.org; envelope-from=srs0=qgqt=kt=vger.kernel.org=sparclinux+bounces-665-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tw40n4JZ5z1ydl for ; Thu, 14 Mar 2024 08:49:29 +1100 (AEDT) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Tw40n3rJFz4wcr for ; Thu, 14 Mar 2024 08:49:29 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4Tw40n3mjJz4wqM; Thu, 14 Mar 2024 08:49:29 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: gandalf.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=KqWOTs1c; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=sparclinux+bounces-665-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Tw40n1TLKz4wcr for ; Thu, 14 Mar 2024 08:49:29 +1100 (AEDT) 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id EA4CF2893B9 for ; Wed, 13 Mar 2024 21:49:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3A08E5D465; Wed, 13 Mar 2024 21:47:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KqWOTs1c" X-Original-To: sparclinux@vger.kernel.org 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 1908454725 for ; Wed, 13 Mar 2024 21:47:38 +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=1710366462; cv=none; b=Ecr+rR8YpuS87oj9iXS3lc3P9au3/dvEKXYAaH3Jp+s36rYg5CQQvYWJkE6ilTlP+eJjLjcgWg4nsKLlN7r6Y3nsihEVvD5H2RxI1IdD5bu4MBLv3ifKGIc9U08h2HgizVYUF1bE1khFFiT7IZT3IibYARoLBUzV/UYWorBnsl0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710366462; c=relaxed/simple; bh=RZT7eZ9qXAWIGdyOh/YTc5ekI4YFmly+9JiblJdJ5UU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R4wsxpCunB7yjJ2PXZI1kFoJwNWLmTOJyBLO1Ens4iSsFQszX+NuamiXD/JpipSaf9s6LiQ1vcY5PPBbD+SxzhKRclUW6dtGPAKxulhzl2uxU1TaJ7kLdXUtq0KzfIOOFQV1+rwQ1yydXKp8iFTqyrhEXyfQQR+Z4daD3hktZMY= 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=KqWOTs1c; 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=1710366457; 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=Q3/QtZ/X4uy5vGDlYUaKemCeea0qTqCUbzq3qEDmZ7g=; b=KqWOTs1cgvMyp8D4WfJo5JT0Rzte5AxEkHwK87aq145U9UDQYdPm52pW0CvKMm41KPmbnd yqHuwogNH+KYNVj8bO6MOX7gVfVo++NpPmv4Ha198kfADbp/0h8o/Lgxaj9Eil4e+NtOff RW2coLE8V5wf9bV4etx1jxXtYSZ1ZDQ= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-20-4PqxyTKGMyiRToOvJ4tJ7g-1; Wed, 13 Mar 2024 17:47:35 -0400 X-MC-Unique: 4PqxyTKGMyiRToOvJ4tJ7g-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6912513fc7bso1699646d6.1 for ; Wed, 13 Mar 2024 14:47:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710366455; x=1710971255; 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=Q3/QtZ/X4uy5vGDlYUaKemCeea0qTqCUbzq3qEDmZ7g=; b=RDtoObfg1cmAAbpDKS/DdY7ZYCO7VUFShBxxuvZSkSiR31IXCS8w40LQ2aILHAmCyY E9zY84qGT49/wvZ5X8lbEfFYoIBAxH87DfLYzRswO++QDE/9ee+jP6WsrCPfydM3nFC7 eVj+Vs/7HuO4UzGdzbNNjwgXF97u6FiA5p970dFa6Rb/5r2DBgbDqwqrfhPqGN+rK7Gv B1vTu8VYmsb+MrDFfyENI74qe9p45fizXcK/1hhMAdI3mg4gx/G3YqDqnG4mXNMrClSl /M8w+kxrLtiIH8USYgCTUFeTj5rWYkqn7MJbVs0o/bDE37l1683Ah5RbM++1Hiw7+1VR 3xww== X-Forwarded-Encrypted: i=1; AJvYcCXCqJP5WhLPQVPVF7Y4CfhHsf/u7dpD3bOgqrRk42jsnykzV3+bTZQwkBtdODom+eZAqDRALvxHDB9DHO4sDKUlIGtCsN5EXfxplA== X-Gm-Message-State: AOJu0YwV2EdkvwYxMbkgfuf/KpvPliKRijyg38jpThO7uJFNDB9yFNtE zmJs2R+87AMh995TqzJ9QPk+sskAvUbEZ/UNnQQ1+AOqFNc9BbgMzJN0W19js5T5XmKU2o3Wlm4 YA+pqU5FtSJH5kZLOJRPdafJyvYpMJPQGWZweCtyGkusV58OIYjVVkzrbwrc= X-Received: by 2002:a05:6214:2c:b0:690:c12f:9750 with SMTP id b12-20020a056214002c00b00690c12f9750mr2845127qvr.4.1710366455045; Wed, 13 Mar 2024 14:47:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/h1WlE9AZBGc/IXZwL3Hjjpc9ZAcuTEVAooWtSlvbi8OV5VzFu9Jid1QvxHh3VTvOYBscJA== X-Received: by 2002:a05:6214:2c:b0:690:c12f:9750 with SMTP id b12-20020a056214002c00b00690c12f9750mr2845108qvr.4.1710366454748; Wed, 13 Mar 2024 14:47:34 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id dv10-20020ad44eea000000b0069111c5cdd4sm60114qvb.100.2024.03.13.14.47.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 14:47:34 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org, Matthew Wilcox , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , x86@kernel.org, peterx@redhat.com, Mike Rapoport , Muchun Song , sparclinux@vger.kernel.org, Jason Gunthorpe , Michael Ellerman , Nicholas Piggin , "Aneesh Kumar K.V" , "Naveen N. Rao" Subject: [PATCH 09/13] mm/powerpc: Redefine pXd_huge() with pXd_leaf() Date: Wed, 13 Mar 2024 17:47:15 -0400 Message-ID: <20240313214719.253873-10-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313214719.253873-1-peterx@redhat.com> References: <20240313214719.253873-1-peterx@redhat.com> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Peter Xu PowerPC book3s 4K mostly has the same definition on both, except pXd_huge() constantly returns 0 for hash MMUs. As Michael Ellerman pointed out [1], it is safe to check _PAGE_PTE on hash MMUs, as the bit will never be set so it will keep returning false. As a reference, __p[mu]d_mkhuge() will trigger a BUG_ON trying to create such huge mappings for 4K hash MMUs. Meanwhile, the major powerpc hugetlb pgtable walker __find_linux_pte() already used pXd_leaf() to check hugetlb mappings. The goal should be that we will have one API pXd_leaf() to detect all kinds of huge mappings. AFAICT we need to use the pXd_leaf() impl (rather than pXd_huge() ones) to make sure ie. THPs on hash MMU will also return true. This helps to simplify a follow up patch to drop pXd_huge() treewide. NOTE: *_leaf() definition need to be moved before the inclusion of asm/book3s/64/pgtable-4k.h, which defines pXd_huge() with it. [1] https://lore.kernel.org/r/87v85zo6w7.fsf@mail.lhotse Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: "Aneesh Kumar K.V" Cc: "Naveen N. Rao" Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Peter Xu --- .../include/asm/book3s/64/pgtable-4k.h | 14 ++-------- arch/powerpc/include/asm/book3s/64/pgtable.h | 27 +++++++++---------- 2 files changed, 14 insertions(+), 27 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/pgtable-4k.h b/arch/powerpc/include/asm/book3s/64/pgtable-4k.h index 48f21820afe2..92545981bb49 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable-4k.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable-4k.h @@ -8,22 +8,12 @@ #ifdef CONFIG_HUGETLB_PAGE static inline int pmd_huge(pmd_t pmd) { - /* - * leaf pte for huge page - */ - if (radix_enabled()) - return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); - return 0; + return pmd_leaf(pmd); } static inline int pud_huge(pud_t pud) { - /* - * leaf pte for huge page - */ - if (radix_enabled()) - return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); - return 0; + return pud_leaf(pud); } /* diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index df66dce8306f..fd7180fded75 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -262,6 +262,18 @@ extern unsigned long __kernel_io_end; extern struct page *vmemmap; extern unsigned long pci_io_base; + +#define pmd_leaf pmd_leaf +static inline bool pmd_leaf(pmd_t pmd) +{ + return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); +} + +#define pud_leaf pud_leaf +static inline bool pud_leaf(pud_t pud) +{ + return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); +} #endif /* __ASSEMBLY__ */ #include @@ -1436,20 +1448,5 @@ static inline bool is_pte_rw_upgrade(unsigned long old_val, unsigned long new_va return false; } -/* - * Like pmd_huge(), but works regardless of config options - */ -#define pmd_leaf pmd_leaf -static inline bool pmd_leaf(pmd_t pmd) -{ - return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); -} - -#define pud_leaf pud_leaf -static inline bool pud_leaf(pud_t pud) -{ - return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); -} - #endif /* __ASSEMBLY__ */ #endif /* _ASM_POWERPC_BOOK3S_64_PGTABLE_H_ */ From patchwork Wed Mar 13 21:47:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1911888 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=QcSzGPTw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=gandalf.ozlabs.org; envelope-from=srs0=q+el=kt=vger.kernel.org=sparclinux+bounces-667-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tw41J4cbVz1ydl for ; Thu, 14 Mar 2024 08:49:56 +1100 (AEDT) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Tw41J49dNz4wcg for ; Thu, 14 Mar 2024 08:49:56 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4Tw41J46tWz4wck; Thu, 14 Mar 2024 08:49:56 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: gandalf.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=QcSzGPTw; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=sparclinux+bounces-667-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Tw41J0vlRz4wcg for ; Thu, 14 Mar 2024 08:49:56 +1100 (AEDT) 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5BD701C2385A for ; Wed, 13 Mar 2024 21:49:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 112A35F866; Wed, 13 Mar 2024 21:47:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QcSzGPTw" X-Original-To: sparclinux@vger.kernel.org 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 3781B5D464 for ; Wed, 13 Mar 2024 21:47:42 +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=1710366466; cv=none; b=BlZPWlgb8i0N01zjMeM7WGAmMCLv9xxnyWahmZk1xRl19BRZf5nyhdPkAjwDSij+XqeJegUfFoFrmn0MtHvGqs4XB4pQ99Y6yu34eM00GDzTI2GEWO96na6u9Dd4Bq01wr7xMuLrOaOiZdJj1viLYN3ejq2qigwmLitzQj9DkDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710366466; c=relaxed/simple; bh=iQQgqfXsWxx8LbxXDlwC+eVTcKSnHUToAbw1far1TeM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bl+ImK6D07GxvZt8r/wTGqmUtPPMjd/s3NkjArqy/cu9WAGEGRS+9BzCRYF1QmQGq8gvpIw3keVzAHhAB9DQYRo8u+pZyoX7B7nXMAGCFEYDpY/zGTAgnIm8bDhrirYKTJGDykrLD+0PtM9ruPi/KPOsKXAtxTMzVP2rbwDeBZk= 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=QcSzGPTw; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710366459; 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=Z0Y+ceGC2u4mzi2lycxKAqHeA0qAqllKwMSRaV+2/Lw=; b=QcSzGPTwArZrbnn4lTjiy0r++lcitKJa39yC+BwkChjhhvy03/hr44Ua5PNB0UCEC4FSf6 HjPUvC71PYbzpT5+u7AxrjfkXiTE78gq1172nEU8XENf7fXkGzA3mbA0pDODw236MjGT+V RKcMlIJQhd6u8mPUu89SO2KFaRR0fSM= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-259-Tqg61XEVN-SNkXZcDAVPpA-1; Wed, 13 Mar 2024 17:47:37 -0400 X-MC-Unique: Tqg61XEVN-SNkXZcDAVPpA-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-69120b349c9so1131876d6.1 for ; Wed, 13 Mar 2024 14:47:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710366456; x=1710971256; 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=Z0Y+ceGC2u4mzi2lycxKAqHeA0qAqllKwMSRaV+2/Lw=; b=e9m9hUWevJMGim5zjvMlduri1Zlek6iSQYrxsX0OhPRXBVDuivb1mOv9NYCuaY9EAV IsweeSwhP3+PZMiWzNRveCPULABfNLMBwvoLuWgg9PghLS4TxDvwEdomO7qKNfyjA5oe olTAUifIFMFJF+1/Wr7h8y28aHOV7k6ZPn1Eqsy2Vx7mJsYAS7068Nvp1+ai/lvSQHZl +hGv1gbzA+R8UHhmhPDnDY9JciodxxLJifLvE31XJ7BfveI1/BvS+6lZYxwxFC6HnOB3 eekshm/DF7Ln9F/0caKv8es1IZVOFwyfrTAqWfxnPqB0OODVlzQ5p5BTKj5yItaNwOXq v8JA== X-Forwarded-Encrypted: i=1; AJvYcCXbk6HWePZfDY/QpH20eFTYZOKhzmYG8bC13xxOZO/UqhpF3FCzQ1/zsCkbJhJdyIWcrVZ9TBEYCAl3CXWy3eL4oSqhodZasJ6CVA== X-Gm-Message-State: AOJu0YxgCjC9w/+Mf1Q3pNs7pNgO3lHSnNb4vSIt/TSOtxDOAKg/dl0w G9xLZ7gDfjfimOQ9c8am/YwstqePVU5zXa4TZCGlr3Q1YPZqhdgnhBBcJCGdilGq3J8WDkzvn4t qerQ558BQxC2VYCL/E/ndKjcnVAk8RzD+gQ3Nl5CFLH7qvkPzIhT2x+gCQBg= X-Received: by 2002:ad4:4c41:0:b0:690:c64d:c2 with SMTP id cs1-20020ad44c41000000b00690c64d00c2mr5759457qvb.2.1710366456318; Wed, 13 Mar 2024 14:47:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+HGFdkYe0dzh0k+TaZTCqm6znW50jTd/iFDz8bJGRu/cwrU7vGL7Qd6Yn9XWGaKvseEdKzw== X-Received: by 2002:ad4:4c41:0:b0:690:c64d:c2 with SMTP id cs1-20020ad44c41000000b00690c64d00c2mr5759436qvb.2.1710366455985; Wed, 13 Mar 2024 14:47:35 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id dv10-20020ad44eea000000b0069111c5cdd4sm60114qvb.100.2024.03.13.14.47.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 14:47:35 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org, Matthew Wilcox , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , x86@kernel.org, peterx@redhat.com, Mike Rapoport , Muchun Song , sparclinux@vger.kernel.org, Jason Gunthorpe Subject: [PATCH 10/13] mm/gup: Merge pXd huge mapping checks Date: Wed, 13 Mar 2024 17:47:16 -0400 Message-ID: <20240313214719.253873-11-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313214719.253873-1-peterx@redhat.com> References: <20240313214719.253873-1-peterx@redhat.com> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Peter Xu Huge mapping checks in GUP are slightly redundant and can be simplified. pXd_huge() now is the same as pXd_leaf(). pmd_trans_huge() and pXd_devmap() should both imply pXd_leaf(). Time to merge them into one. Reviewed-by: Jason Gunthorpe Signed-off-by: Peter Xu --- mm/gup.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 802987281b2f..e2415e9789bc 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -3005,8 +3005,7 @@ static int gup_pmd_range(pud_t *pudp, pud_t pud, unsigned long addr, unsigned lo if (!pmd_present(pmd)) return 0; - if (unlikely(pmd_trans_huge(pmd) || pmd_huge(pmd) || - pmd_devmap(pmd))) { + if (unlikely(pmd_leaf(pmd))) { /* See gup_pte_range() */ if (pmd_protnone(pmd)) return 0; @@ -3043,7 +3042,7 @@ static int gup_pud_range(p4d_t *p4dp, p4d_t p4d, unsigned long addr, unsigned lo next = pud_addr_end(addr, end); if (unlikely(!pud_present(pud))) return 0; - if (unlikely(pud_huge(pud) || pud_devmap(pud))) { + if (unlikely(pud_leaf(pud))) { if (!gup_huge_pud(pud, pudp, addr, next, flags, pages, nr)) return 0; @@ -3096,7 +3095,7 @@ static void gup_pgd_range(unsigned long addr, unsigned long end, next = pgd_addr_end(addr, end); if (pgd_none(pgd)) return; - if (unlikely(pgd_huge(pgd))) { + if (unlikely(pgd_leaf(pgd))) { if (!gup_huge_pgd(pgd, pgdp, addr, next, flags, pages, nr)) return; From patchwork Wed Mar 13 21:47:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1911886 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=H2VNe5EI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=gandalf.ozlabs.org; envelope-from=srs0=nnhn=kt=vger.kernel.org=sparclinux+bounces-666-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tw41C5Sfmz1ydl for ; Thu, 14 Mar 2024 08:49:51 +1100 (AEDT) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Tw41C4z4nz4wcg for ; Thu, 14 Mar 2024 08:49:51 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4Tw41C4t9nz4wcr; Thu, 14 Mar 2024 08:49:51 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: gandalf.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=H2VNe5EI; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=sparclinux+bounces-666-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Tw41C2c2hz4wcg for ; Thu, 14 Mar 2024 08:49:51 +1100 (AEDT) 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 1CA8528A0C6 for ; Wed, 13 Mar 2024 21:49:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C33195F576; Wed, 13 Mar 2024 21:47:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="H2VNe5EI" X-Original-To: sparclinux@vger.kernel.org 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 2C5DC5B669 for ; Wed, 13 Mar 2024 21:47:41 +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=1710366465; cv=none; b=D1zJkLLNDzBUzOvMe0auCtvWCJCiPedWVGat8k8cMb7Yeb9SUL5qMS0yo9PNm9jvoC+e+3yzxVMFVmBlfu1EtyiVZd1zh8GD3UIiJDacQwMKRcYUNBnx3741aqD2chumbXn2fIMiuEttuQAsKZm0Ixy+qKw2hxAAN+vCLMWofcc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710366465; c=relaxed/simple; bh=re8gayKJqX7wtB2aUip/dTMGnIaKcXRJtJft1bXrpLU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dswSP5XAaQTNumkegbLmW07vquQyMaaeNeZwd2uM39m01+NN0Q5oOvyDW9qcoGRSU/m4EpkY2XYkYqEfB6WyntXquhb2ahL8LcO/p5wS9IYqFaqGID2azOMFLzGHDzjb2HemB4yYRPxkLOItQCQkLmla11kZE6eYb+2re4jNx0g= 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=H2VNe5EI; 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=1710366459; 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=C5IYGWVxUA2LCxblG8GUdWUManYweqkS1nMwnfIC++w=; b=H2VNe5EIuFiP3yY4ymiDZ96SXUzISF09YCgfe5lGPz2S3YfvIaV9Qf22lo7cYhBLFX3NeS NsUAYYKI4chTd8Alt2p3HbhiFQCt+rzRzvOwwb7u+0Ff3WGNAagnQyYDLukqnYJyy7pWye CnwxEEALwWNaeFTkJXAp4VO5+PbZCZI= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-632-B4R3U0QtMOO8vdm3Al6mxQ-1; Wed, 13 Mar 2024 17:47:38 -0400 X-MC-Unique: B4R3U0QtMOO8vdm3Al6mxQ-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-690ab2b0de1so1163146d6.0 for ; Wed, 13 Mar 2024 14:47:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710366458; x=1710971258; 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=C5IYGWVxUA2LCxblG8GUdWUManYweqkS1nMwnfIC++w=; b=t1YCYl1L8x/GtW60nN9hUocXknNlLba8bnJSd+3vXYqi58J73BhbNJa3SujoDrqRBt kJnaSOmw91KGZAZE1wNcjTMPAAbTWno9EUKUVjTcKo6j1oZdP+likaCSvRl/xSgFitko MVOdN6HSFdZsX0Dv8DiOxX+sKmNl5PElBK8sH7NrCW3jFwCDwD+3CinNL3+UIlNFLXEh F90CjzVL4ihkHb3mpQeEBCDeNf3S8qwHbB1Si37piB7SPt6FlAvxF7tiJCdGQbCqZX0B IpqWHjGxlEb7xchZJ5Bjm81p7WGvdJYWytMSkhCOjTQ0kmJamUe2i+QzMRvGNlAMa3Wn W8ww== X-Forwarded-Encrypted: i=1; AJvYcCU8YoksqfD0yXM8HmGthBnDU7ENwTnZyCj5yMaGvEnBwqSn+mrZxuDu+Np7jrG9+HNTLfPmAn3Umq28lek310sxgVuwkaQHqPHutw== X-Gm-Message-State: AOJu0Yz9rufi9WFIHlunvy6kPVrfc612syMpxsFl52fRiLO/g2ICYEMe w6SA50LDGFGYZyzFUoblFlCyqKhPMpsfUeBqN/nBFVF2sQ6ZQofFgWNefCH2cDUhl7awwYFBy/Z pm/3xR14uUfUQBqKDJ4iprnRvVriQKo8dy7VgCp6mUEKPykGIqc1S6ClNNCE= X-Received: by 2002:ad4:44af:0:b0:690:cdd5:ea47 with SMTP id n15-20020ad444af000000b00690cdd5ea47mr5817869qvt.4.1710366457675; Wed, 13 Mar 2024 14:47:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHpS4qzMtDq6dHWn+zDTnC7YerPZmR6KmCZydssp8t/OhY0dbMM5c9rhqAeusvBg5vL+ogyTw== X-Received: by 2002:ad4:44af:0:b0:690:cdd5:ea47 with SMTP id n15-20020ad444af000000b00690cdd5ea47mr5817849qvt.4.1710366457259; Wed, 13 Mar 2024 14:47:37 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id dv10-20020ad44eea000000b0069111c5cdd4sm60114qvb.100.2024.03.13.14.47.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 14:47:36 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org, Matthew Wilcox , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , x86@kernel.org, peterx@redhat.com, Mike Rapoport , Muchun Song , sparclinux@vger.kernel.org, Jason Gunthorpe Subject: [PATCH 11/13] mm/treewide: Replace pXd_huge() with pXd_leaf() Date: Wed, 13 Mar 2024 17:47:17 -0400 Message-ID: <20240313214719.253873-12-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313214719.253873-1-peterx@redhat.com> References: <20240313214719.253873-1-peterx@redhat.com> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Peter Xu Now after we're sure all pXd_huge() definitions are the same as pXd_leaf(), reuse it. Luckily, pXd_huge() isn't widely used. Signed-off-by: Peter Xu --- arch/arm/include/asm/pgtable-3level.h | 2 +- arch/arm64/include/asm/pgtable.h | 2 +- arch/arm64/mm/hugetlbpage.c | 4 ++-- arch/loongarch/mm/hugetlbpage.c | 2 +- arch/mips/mm/tlb-r4k.c | 2 +- arch/powerpc/mm/pgtable_64.c | 6 +++--- arch/x86/mm/pgtable.c | 4 ++-- mm/gup.c | 4 ++-- mm/hmm.c | 2 +- mm/memory.c | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h index e7aecbef75c9..9e3c44f0aea2 100644 --- a/arch/arm/include/asm/pgtable-3level.h +++ b/arch/arm/include/asm/pgtable-3level.h @@ -190,7 +190,7 @@ static inline pte_t pte_mkspecial(pte_t pte) #define pmd_dirty(pmd) (pmd_isset((pmd), L_PMD_SECT_DIRTY)) #define pmd_hugewillfault(pmd) (!pmd_young(pmd) || !pmd_write(pmd)) -#define pmd_thp_or_huge(pmd) (pmd_huge(pmd) || pmd_trans_huge(pmd)) +#define pmd_thp_or_huge(pmd) (pmd_leaf(pmd) || pmd_trans_huge(pmd)) #ifdef CONFIG_TRANSPARENT_HUGEPAGE #define pmd_trans_huge(pmd) (pmd_val(pmd) && !pmd_table(pmd)) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 14d24c357c7a..c4efa47fed5f 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -512,7 +512,7 @@ static inline pmd_t pmd_mkinvalid(pmd_t pmd) return pmd; } -#define pmd_thp_or_huge(pmd) (pmd_huge(pmd) || pmd_trans_huge(pmd)) +#define pmd_thp_or_huge(pmd) (pmd_leaf(pmd) || pmd_trans_huge(pmd)) #define pmd_write(pmd) pte_write(pmd_pte(pmd)) diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 1234bbaef5bf..f494fc31201f 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -321,7 +321,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, if (sz != PUD_SIZE && pud_none(pud)) return NULL; /* hugepage or swap? */ - if (pud_huge(pud) || !pud_present(pud)) + if (pud_leaf(pud) || !pud_present(pud)) return (pte_t *)pudp; /* table; check the next level */ @@ -333,7 +333,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, if (!(sz == PMD_SIZE || sz == CONT_PMD_SIZE) && pmd_none(pmd)) return NULL; - if (pmd_huge(pmd) || !pmd_present(pmd)) + if (pmd_leaf(pmd) || !pmd_present(pmd)) return (pte_t *)pmdp; if (sz == CONT_PTE_SIZE) diff --git a/arch/loongarch/mm/hugetlbpage.c b/arch/loongarch/mm/hugetlbpage.c index 1e76fcb83093..a4e78e74aa21 100644 --- a/arch/loongarch/mm/hugetlbpage.c +++ b/arch/loongarch/mm/hugetlbpage.c @@ -64,7 +64,7 @@ uint64_t pmd_to_entrylo(unsigned long pmd_val) { uint64_t val; /* PMD as PTE. Must be huge page */ - if (!pmd_huge(__pmd(pmd_val))) + if (!pmd_leaf(__pmd(pmd_val))) panic("%s", __func__); val = pmd_val ^ _PAGE_HUGE; diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c index 4106084e57d7..76f3b9c0a9f0 100644 --- a/arch/mips/mm/tlb-r4k.c +++ b/arch/mips/mm/tlb-r4k.c @@ -326,7 +326,7 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte) idx = read_c0_index(); #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT /* this could be a huge page */ - if (pmd_huge(*pmdp)) { + if (pmd_leaf(*pmdp)) { unsigned long lo; write_c0_pagemask(PM_HUGE_MASK); ptep = (pte_t *)pmdp; diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c index 9b99113cb51a..6621cfc3baf8 100644 --- a/arch/powerpc/mm/pgtable_64.c +++ b/arch/powerpc/mm/pgtable_64.c @@ -102,7 +102,7 @@ struct page *p4d_page(p4d_t p4d) { if (p4d_leaf(p4d)) { if (!IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMAP)) - VM_WARN_ON(!p4d_huge(p4d)); + VM_WARN_ON(!p4d_leaf(p4d)); return pte_page(p4d_pte(p4d)); } return virt_to_page(p4d_pgtable(p4d)); @@ -113,7 +113,7 @@ struct page *pud_page(pud_t pud) { if (pud_leaf(pud)) { if (!IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMAP)) - VM_WARN_ON(!pud_huge(pud)); + VM_WARN_ON(!pud_leaf(pud)); return pte_page(pud_pte(pud)); } return virt_to_page(pud_pgtable(pud)); @@ -132,7 +132,7 @@ struct page *pmd_page(pmd_t pmd) * enabled so these checks can't be used. */ if (!IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMAP)) - VM_WARN_ON(!(pmd_leaf(pmd) || pmd_huge(pmd))); + VM_WARN_ON(!pmd_leaf(pmd)); return pte_page(pmd_pte(pmd)); } return virt_to_page(pmd_page_vaddr(pmd)); diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c index ff690ddc2334..d74f0814e086 100644 --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c @@ -731,7 +731,7 @@ int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot) return 0; /* Bail out if we are we on a populated non-leaf entry: */ - if (pud_present(*pud) && !pud_huge(*pud)) + if (pud_present(*pud) && !pud_leaf(*pud)) return 0; set_pte((pte_t *)pud, pfn_pte( @@ -760,7 +760,7 @@ int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot) } /* Bail out if we are we on a populated non-leaf entry: */ - if (pmd_present(*pmd) && !pmd_huge(*pmd)) + if (pmd_present(*pmd) && !pmd_leaf(*pmd)) return 0; set_pte((pte_t *)pmd, pfn_pte( diff --git a/mm/gup.c b/mm/gup.c index e2415e9789bc..8e04a04ef138 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -778,7 +778,7 @@ static struct page *follow_p4d_mask(struct vm_area_struct *vma, p4d = READ_ONCE(*p4dp); if (!p4d_present(p4d)) return no_page_table(vma, flags); - BUILD_BUG_ON(p4d_huge(p4d)); + BUILD_BUG_ON(p4d_leaf(p4d)); if (unlikely(p4d_bad(p4d))) return no_page_table(vma, flags); @@ -3070,7 +3070,7 @@ static int gup_p4d_range(pgd_t *pgdp, pgd_t pgd, unsigned long addr, unsigned lo next = p4d_addr_end(addr, end); if (!p4d_present(p4d)) return 0; - BUILD_BUG_ON(p4d_huge(p4d)); + BUILD_BUG_ON(p4d_leaf(p4d)); if (unlikely(is_hugepd(__hugepd(p4d_val(p4d))))) { if (!gup_huge_pd(__hugepd(p4d_val(p4d)), addr, P4D_SHIFT, next, flags, pages, nr)) diff --git a/mm/hmm.c b/mm/hmm.c index c95b9ec5d95f..93aebd9cc130 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -429,7 +429,7 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned long start, unsigned long end, return hmm_vma_walk_hole(start, end, -1, walk); } - if (pud_huge(pud) && pud_devmap(pud)) { + if (pud_leaf(pud) && pud_devmap(pud)) { unsigned long i, npages, pfn; unsigned int required_fault; unsigned long *hmm_pfns; diff --git a/mm/memory.c b/mm/memory.c index 904f70b99498..baee777dcd2d 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2765,7 +2765,7 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud, unsigned long next; int err = 0; - BUG_ON(pud_huge(*pud)); + BUG_ON(pud_leaf(*pud)); if (create) { pmd = pmd_alloc_track(mm, pud, addr, mask); From patchwork Wed Mar 13 21:47:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1911891 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=M8dP7N5c; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=gandalf.ozlabs.org; envelope-from=srs0=t3eu=kt=vger.kernel.org=sparclinux+bounces-669-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tw42W1QNLz1yWt for ; Thu, 14 Mar 2024 08:50:59 +1100 (AEDT) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Tw42W0pYtz4wbh for ; Thu, 14 Mar 2024 08:50:59 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4Tw42W0lldz4wcR; Thu, 14 Mar 2024 08:50:59 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: gandalf.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=M8dP7N5c; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=sparclinux+bounces-669-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Tw42W0ch2z4wbh for ; Thu, 14 Mar 2024 08:50:59 +1100 (AEDT) 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A5EE9B225B6 for ; Wed, 13 Mar 2024 21:50:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D2556026F; Wed, 13 Mar 2024 21:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="M8dP7N5c" X-Original-To: sparclinux@vger.kernel.org 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 BB4E05F486 for ; Wed, 13 Mar 2024 21:47:45 +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=1710366472; cv=none; b=mi2DnahYLtFfnEXIEa/gdoStbEFh9Uq+qaU4LEEhl60BBNKNF5rcAXMGhTmFGBsK2Ey5oy1CtwHb83zDE7APcuaSXDqQHOUt9z+YfWzs67OuPj3ZXpk1oL40KIltilR0nmfLQru8Mqsgy9UN3/ibcwQX9I2DoOBRVzpPiKS562o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710366472; c=relaxed/simple; bh=O0+KZoNJkyqgkkBm880il/b9aGWCTEsuXpCU+/TiYmU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gj9Y81BfXf7ajNSa5jjfSJcjZ2vdT5LnyWZ9xKHxQYPeepi11C1wV1YVGMIkYTd71lxErnZanebj2Q0Cz3q8zjwlJdVTWRA9R2qrT+zF3suqo4mqQId8xAzUqYBVAsrlT+BEbmxeWjNdAKNM/ikn6lfXb+gqnVxQGGDMusZyxHo= 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=M8dP7N5c; 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=1710366463; 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=DmTR2+cqTF97dN4Qm56qtqK3b7/RsOHhzWGdzkuQ/Hs=; b=M8dP7N5ck5a1EFoXV5HlQWhMULKm2SvBuxzOvyytmshr7rRpieN4FPP0YRCWGFvmsFNhWq qkQ8npr5YjCQ38fdzieb/ETsFO6lRMo2PHmialL1oPTixBRumHIBNxgc2GZUyIR3sPif/R GHNK7yx5Zs14BZjYqZ1Mp/a57oYfcwQ= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-84--thJiTYJOnuKghYWAcGXKw-1; Wed, 13 Mar 2024 17:47:40 -0400 X-MC-Unique: -thJiTYJOnuKghYWAcGXKw-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6818b8cb840so989656d6.1 for ; Wed, 13 Mar 2024 14:47:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710366459; x=1710971259; 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=DmTR2+cqTF97dN4Qm56qtqK3b7/RsOHhzWGdzkuQ/Hs=; b=DciqSODWQ23iArefFS6I+Gk2/W7Bj6rbGbmJAAOcXWOTPb95H7ivw0/AXUJ1Xe+Ccc BEXWkLB/shm5w44/jKfl4xuzfzTfh4KUDYRgEUVbqoyiyYNMXmm/1ANYl/BQvJzZ/6wu hveSl3veJVJ2zhxYZdd2yMXTimf2IzOfyyepTu8h5vhRZWip3ScGNeL1UGBWghYW3+YU Jj7CX6sz3g0qvjAcsdBSmfXoJtECLhS9QcwF3RGY/HczxRwkzW52bC79+GtZt4OCn4KV 7/0418UmMtUlhuoscoZgqDGfZBgeW0XpoA8WUxk1YWY4+Zznj/jdelJlhdVvf40RRn8a zq8g== X-Forwarded-Encrypted: i=1; AJvYcCWsbDlddO4TRVEdodi92ug32hoQFJrDftOiNbvJE7dQKpSwq4ETmQO8pm3CzFs5hQEteTjgkJuFw6qSVvG2C93eIb36aNakM+Kx5A== X-Gm-Message-State: AOJu0YysDXBwEcZ0AVqKfcK05F2M04Z5FaoamYoi6eRGFQyZ9n21PtqB RfjRWFqDX3AKBtlQuxoyV+uHhIMKLM0yEgTjTjI/jLrBFaYfP/47Ye8iHkTFxjwCAufCKuLtYGJ gc1VBCkEXccwAGy6qO1zc4aeFv2KV0odSVSJ0irjKogxAO0c4UJ5bppIAi+M= X-Received: by 2002:a05:6214:ca1:b0:690:ca31:f070 with SMTP id s1-20020a0562140ca100b00690ca31f070mr2870508qvs.2.1710366459297; Wed, 13 Mar 2024 14:47:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGdLotpPN70N9pbKC4tqKRd0G68xLINFQf3Gz4t7Rw+iAJ9v+Us3CvOjmBBrqx2DSseSMgKAw== X-Received: by 2002:a05:6214:ca1:b0:690:ca31:f070 with SMTP id s1-20020a0562140ca100b00690ca31f070mr2870497qvs.2.1710366458928; Wed, 13 Mar 2024 14:47:38 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id dv10-20020ad44eea000000b0069111c5cdd4sm60114qvb.100.2024.03.13.14.47.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 14:47:38 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org, Matthew Wilcox , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , x86@kernel.org, peterx@redhat.com, Mike Rapoport , Muchun Song , sparclinux@vger.kernel.org, Jason Gunthorpe Subject: [PATCH 12/13] mm/treewide: Remove pXd_huge() Date: Wed, 13 Mar 2024 17:47:18 -0400 Message-ID: <20240313214719.253873-13-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313214719.253873-1-peterx@redhat.com> References: <20240313214719.253873-1-peterx@redhat.com> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Peter Xu This API is not used anymore, drop it for the whole tree. Signed-off-by: Peter Xu --- arch/arm/mm/Makefile | 1 - arch/arm/mm/hugetlbpage.c | 29 ------------------- arch/arm64/mm/hugetlbpage.c | 10 ------- arch/loongarch/mm/hugetlbpage.c | 10 ------- arch/mips/include/asm/pgtable-32.h | 2 +- arch/mips/include/asm/pgtable-64.h | 2 +- arch/mips/mm/hugetlbpage.c | 10 ------- arch/parisc/mm/hugetlbpage.c | 11 ------- .../include/asm/book3s/64/pgtable-4k.h | 10 ------- .../include/asm/book3s/64/pgtable-64k.h | 25 ---------------- arch/powerpc/include/asm/nohash/pgtable.h | 10 ------- arch/riscv/mm/hugetlbpage.c | 10 ------- arch/s390/mm/hugetlbpage.c | 10 ------- arch/sh/mm/hugetlbpage.c | 10 ------- arch/sparc/mm/hugetlbpage.c | 10 ------- arch/x86/mm/hugetlbpage.c | 16 ---------- include/linux/hugetlb.h | 24 --------------- 17 files changed, 2 insertions(+), 198 deletions(-) delete mode 100644 arch/arm/mm/hugetlbpage.c diff --git a/arch/arm/mm/Makefile b/arch/arm/mm/Makefile index 71b858c9b10c..1779e12db085 100644 --- a/arch/arm/mm/Makefile +++ b/arch/arm/mm/Makefile @@ -21,7 +21,6 @@ KASAN_SANITIZE_physaddr.o := n obj-$(CONFIG_DEBUG_VIRTUAL) += physaddr.o obj-$(CONFIG_ALIGNMENT_TRAP) += alignment.o -obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o obj-$(CONFIG_ARM_PV_FIXUP) += pv-fixup-asm.o obj-$(CONFIG_CPU_ABRT_NOMMU) += abort-nommu.o diff --git a/arch/arm/mm/hugetlbpage.c b/arch/arm/mm/hugetlbpage.c deleted file mode 100644 index c2fa643f6bb5..000000000000 --- a/arch/arm/mm/hugetlbpage.c +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * arch/arm/mm/hugetlbpage.c - * - * Copyright (C) 2012 ARM Ltd. - * - * Based on arch/x86/include/asm/hugetlb.h and Bill Carson's patches - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -int pud_huge(pud_t pud) -{ - return 0; -} - -int pmd_huge(pmd_t pmd) -{ - return pmd_leaf(pmd); -} diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index f494fc31201f..ca58210d6c07 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -79,16 +79,6 @@ bool arch_hugetlb_migration_supported(struct hstate *h) } #endif -int pmd_huge(pmd_t pmd) -{ - return pmd_leaf(pmd); -} - -int pud_huge(pud_t pud) -{ - return pud_leaf(pud); -} - static int find_num_contig(struct mm_struct *mm, unsigned long addr, pte_t *ptep, size_t *pgsize) { diff --git a/arch/loongarch/mm/hugetlbpage.c b/arch/loongarch/mm/hugetlbpage.c index a4e78e74aa21..12222c56cb59 100644 --- a/arch/loongarch/mm/hugetlbpage.c +++ b/arch/loongarch/mm/hugetlbpage.c @@ -50,16 +50,6 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr, return (pte_t *) pmd; } -int pmd_huge(pmd_t pmd) -{ - return (pmd_val(pmd) & _PAGE_HUGE) != 0; -} - -int pud_huge(pud_t pud) -{ - return (pud_val(pud) & _PAGE_HUGE) != 0; -} - uint64_t pmd_to_entrylo(unsigned long pmd_val) { uint64_t val; diff --git a/arch/mips/include/asm/pgtable-32.h b/arch/mips/include/asm/pgtable-32.h index 0e196650f4f4..92b7591aac2a 100644 --- a/arch/mips/include/asm/pgtable-32.h +++ b/arch/mips/include/asm/pgtable-32.h @@ -129,7 +129,7 @@ static inline int pmd_none(pmd_t pmd) static inline int pmd_bad(pmd_t pmd) { #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT - /* pmd_huge(pmd) but inline */ + /* pmd_leaf(pmd) but inline */ if (unlikely(pmd_val(pmd) & _PAGE_HUGE)) return 0; #endif diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h index 20ca48c1b606..7c28510b3768 100644 --- a/arch/mips/include/asm/pgtable-64.h +++ b/arch/mips/include/asm/pgtable-64.h @@ -245,7 +245,7 @@ static inline int pmd_none(pmd_t pmd) static inline int pmd_bad(pmd_t pmd) { #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT - /* pmd_huge(pmd) but inline */ + /* pmd_leaf(pmd) but inline */ if (unlikely(pmd_val(pmd) & _PAGE_HUGE)) return 0; #endif diff --git a/arch/mips/mm/hugetlbpage.c b/arch/mips/mm/hugetlbpage.c index 7eaff5b07873..0b9e15555b59 100644 --- a/arch/mips/mm/hugetlbpage.c +++ b/arch/mips/mm/hugetlbpage.c @@ -57,13 +57,3 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr, } return (pte_t *) pmd; } - -int pmd_huge(pmd_t pmd) -{ - return (pmd_val(pmd) & _PAGE_HUGE) != 0; -} - -int pud_huge(pud_t pud) -{ - return (pud_val(pud) & _PAGE_HUGE) != 0; -} diff --git a/arch/parisc/mm/hugetlbpage.c b/arch/parisc/mm/hugetlbpage.c index a9f7e21f6656..0356199bd9e7 100644 --- a/arch/parisc/mm/hugetlbpage.c +++ b/arch/parisc/mm/hugetlbpage.c @@ -180,14 +180,3 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma, } return changed; } - - -int pmd_huge(pmd_t pmd) -{ - return 0; -} - -int pud_huge(pud_t pud) -{ - return 0; -} diff --git a/arch/powerpc/include/asm/book3s/64/pgtable-4k.h b/arch/powerpc/include/asm/book3s/64/pgtable-4k.h index 92545981bb49..baf934578c3a 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable-4k.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable-4k.h @@ -6,16 +6,6 @@ */ #ifndef __ASSEMBLY__ #ifdef CONFIG_HUGETLB_PAGE -static inline int pmd_huge(pmd_t pmd) -{ - return pmd_leaf(pmd); -} - -static inline int pud_huge(pud_t pud) -{ - return pud_leaf(pud); -} - /* * With radix , we have hugepage ptes in the pud and pmd entries. We don't * need to setup hugepage directory for them. Our pte and page directory format diff --git a/arch/powerpc/include/asm/book3s/64/pgtable-64k.h b/arch/powerpc/include/asm/book3s/64/pgtable-64k.h index 2fce3498b000..579a7153857f 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable-64k.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable-64k.h @@ -4,31 +4,6 @@ #ifndef __ASSEMBLY__ #ifdef CONFIG_HUGETLB_PAGE -/* - * We have PGD_INDEX_SIZ = 12 and PTE_INDEX_SIZE = 8, so that we can have - * 16GB hugepage pte in PGD and 16MB hugepage pte at PMD; - * - * Defined in such a way that we can optimize away code block at build time - * if CONFIG_HUGETLB_PAGE=n. - * - * returns true for pmd migration entries, THP, devmap, hugetlb - * But compile time dependent on CONFIG_HUGETLB_PAGE - */ -static inline int pmd_huge(pmd_t pmd) -{ - /* - * leaf pte for huge page - */ - return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); -} - -static inline int pud_huge(pud_t pud) -{ - /* - * leaf pte for huge page - */ - return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); -} /* * With 64k page size, we have hugepage ptes in the pgd and pmd entries. We don't diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h index 427db14292c9..f5f39d4f03c8 100644 --- a/arch/powerpc/include/asm/nohash/pgtable.h +++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -351,16 +351,6 @@ static inline int hugepd_ok(hugepd_t hpd) #endif } -static inline int pmd_huge(pmd_t pmd) -{ - return 0; -} - -static inline int pud_huge(pud_t pud) -{ - return 0; -} - #define is_hugepd(hpd) (hugepd_ok(hpd)) #endif diff --git a/arch/riscv/mm/hugetlbpage.c b/arch/riscv/mm/hugetlbpage.c index 29c7606414d2..9a4bc4bd2a01 100644 --- a/arch/riscv/mm/hugetlbpage.c +++ b/arch/riscv/mm/hugetlbpage.c @@ -399,16 +399,6 @@ static bool is_napot_size(unsigned long size) #endif /*CONFIG_RISCV_ISA_SVNAPOT*/ -int pud_huge(pud_t pud) -{ - return pud_leaf(pud); -} - -int pmd_huge(pmd_t pmd) -{ - return pmd_leaf(pmd); -} - static bool __hugetlb_valid_size(unsigned long size) { if (size == HPAGE_SIZE) diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c index c2e8242bd15d..ca43b6fce71c 100644 --- a/arch/s390/mm/hugetlbpage.c +++ b/arch/s390/mm/hugetlbpage.c @@ -233,16 +233,6 @@ pte_t *huge_pte_offset(struct mm_struct *mm, return (pte_t *) pmdp; } -int pmd_huge(pmd_t pmd) -{ - return pmd_leaf(pmd); -} - -int pud_huge(pud_t pud) -{ - return pud_leaf(pud); -} - bool __init arch_hugetlb_valid_size(unsigned long size) { if (MACHINE_HAS_EDAT1 && size == PMD_SIZE) diff --git a/arch/sh/mm/hugetlbpage.c b/arch/sh/mm/hugetlbpage.c index 6cb0ad73dbb9..ff209b55285a 100644 --- a/arch/sh/mm/hugetlbpage.c +++ b/arch/sh/mm/hugetlbpage.c @@ -70,13 +70,3 @@ pte_t *huge_pte_offset(struct mm_struct *mm, return pte; } - -int pmd_huge(pmd_t pmd) -{ - return 0; -} - -int pud_huge(pud_t pud) -{ - return 0; -} diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c index d31c2cec35c9..8ed5bdf95d25 100644 --- a/arch/sparc/mm/hugetlbpage.c +++ b/arch/sparc/mm/hugetlbpage.c @@ -407,16 +407,6 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, return entry; } -int pmd_huge(pmd_t pmd) -{ - return pmd_leaf(pmd);; -} - -int pud_huge(pud_t pud) -{ - return pud_leaf(pud); -} - static void hugetlb_free_pte_range(struct mmu_gather *tlb, pmd_t *pmd, unsigned long addr) { diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c index 8362953a24ce..dab6db288e5b 100644 --- a/arch/x86/mm/hugetlbpage.c +++ b/arch/x86/mm/hugetlbpage.c @@ -19,22 +19,6 @@ #include #include -/* - * pmd_huge() returns 1 if @pmd is hugetlb related entry. - */ -int pmd_huge(pmd_t pmd) -{ - return pmd_leaf(pmd); -} - -/* - * pud_huge() returns 1 if @pud is hugetlb related entry. - */ -int pud_huge(pud_t pud) -{ - return pud_leaf(pud); -} - #ifdef CONFIG_HUGETLB_PAGE static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file, unsigned long addr, unsigned long len, diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 77b30a8c6076..300de33c6fde 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -272,13 +272,9 @@ void hugetlb_vma_unlock_write(struct vm_area_struct *vma); int hugetlb_vma_trylock_write(struct vm_area_struct *vma); void hugetlb_vma_assert_locked(struct vm_area_struct *vma); void hugetlb_vma_lock_release(struct kref *kref); - -int pmd_huge(pmd_t pmd); -int pud_huge(pud_t pud); long hugetlb_change_protection(struct vm_area_struct *vma, unsigned long address, unsigned long end, pgprot_t newprot, unsigned long cp_flags); - bool is_hugetlb_entry_migration(pte_t pte); bool is_hugetlb_entry_hwpoisoned(pte_t pte); void hugetlb_unshare_all_pmds(struct vm_area_struct *vma); @@ -399,16 +395,6 @@ static inline void hugetlb_vma_assert_locked(struct vm_area_struct *vma) { } -static inline int pmd_huge(pmd_t pmd) -{ - return 0; -} - -static inline int pud_huge(pud_t pud) -{ - return 0; -} - static inline int is_hugepage_only_range(struct mm_struct *mm, unsigned long addr, unsigned long len) { @@ -493,16 +479,6 @@ static inline vm_fault_t hugetlb_fault(struct mm_struct *mm, static inline void hugetlb_unshare_all_pmds(struct vm_area_struct *vma) { } #endif /* !CONFIG_HUGETLB_PAGE */ -/* - * hugepages at page global directory. If arch support - * hugepages at pgd level, they need to define this. - */ -#ifndef pgd_huge -#define pgd_huge(x) 0 -#endif -#ifndef p4d_huge -#define p4d_huge(x) 0 -#endif #ifndef pgd_write static inline int pgd_write(pgd_t pgd) From patchwork Wed Mar 13 21:47:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1911889 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=QtBNisYf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=gandalf.ozlabs.org; envelope-from=srs0=zs5f=kt=vger.kernel.org=sparclinux+bounces-668-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tw41S53Qfz1yWn for ; Thu, 14 Mar 2024 08:50:04 +1100 (AEDT) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Tw41S4XVwz4wcs for ; Thu, 14 Mar 2024 08:50:04 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4Tw41S4TV9z4wck; Thu, 14 Mar 2024 08:50:04 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: gandalf.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=QtBNisYf; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=sparclinux+bounces-668-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Tw41S29bnz4wcs for ; Thu, 14 Mar 2024 08:50:04 +1100 (AEDT) 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 12562283661 for ; Wed, 13 Mar 2024 21:50:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7AB705FEE5; Wed, 13 Mar 2024 21:47:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QtBNisYf" X-Original-To: sparclinux@vger.kernel.org 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 10EB65EE78 for ; Wed, 13 Mar 2024 21:47:44 +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=1710366467; cv=none; b=nL+wXCKjr52wKxt4r3WaOPEZFmyWsHeEPNF7KQs6TXARfykZu77GEubibflmsaBM1v4QLG5lQQQN36d2oX+ZnYfE38bLKsQ7lk+8DPoWYlm0YgG+SS5y/8gX/Ja4NaSeTft0Qua1uRhtXISIl8iT2TNBgWNKAALg0EhoVvGJy8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710366467; c=relaxed/simple; bh=OtdxslPn00ut3ZNOwlMQpC8bAo76CW3Q9+JhiTFcwrI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mpYd9cQxKsVf4hSmUcRLs6ovE9tS+f17Y9QrKRUmmwfEnmZOr9lagIs2CXVGEMgJyds8NP2cpIUG3bCkAJo6n2Qb0+TRgc5Ru+vWpQKzLHemB9eraPMmYqw1YnWM8Ye/5haxDDzNZbf/iu7kjrfKH+eDHLpKchryIO/JUw+Cp7E= 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=QtBNisYf; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710366463; 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=RceLUqudgSYtio91tFrZNJeoSc+POoSD4WuQnIajVyw=; b=QtBNisYf7XfwYzICx0puyDSv7NCHTQ0Vr0rYjB5gnSkJnBK3UUrk1uxJT25RIZHtO/bfoJ QX5RuHcdVe3zSPZUoEsgIxuO4z52n3apo6g26vmTr79sgNYJhpMATW/tAqt6LRlrQjH95/ rIi7DsrSSvR1wPm24zeojaQC/4iu3NQ= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-541-nkyZhZhYPkK4geRtN9ne7Q-1; Wed, 13 Mar 2024 17:47:41 -0400 X-MC-Unique: nkyZhZhYPkK4geRtN9ne7Q-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-690ab2b0de1so1163206d6.0 for ; Wed, 13 Mar 2024 14:47:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710366461; x=1710971261; 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=RceLUqudgSYtio91tFrZNJeoSc+POoSD4WuQnIajVyw=; b=sQV8KvdtqF2HRz8o8dLSG1s23E2yBdDPojFZ7IlxQDF2qeKtUNsQSy5aiJvlPzlVk2 bVSNfJVk9/PT+uq+5XIpo+8vsgFxGb4g/AVcT3m5HM4n5PmySAwXPA6RQnZDa6YabK/S NsmcOF1B59r8+X5Ui+iFNLbCZZ2QoO94eActCCsQnKNntZgIC9IKup9VbY2eUGUoAsL5 xpnB06VfOLAI2FVL93OKXmbhpQXG9IhhxbtiveoOO09tBSnlY5atDVAHOmUH4kvvBy1g u4fiM/SCrdYyaWRsYJ7bLz7sRWG6fJX8PAeTwAxEZ8UNIlSo0l1npTfKWTWEAemBPw9+ 7uWg== X-Forwarded-Encrypted: i=1; AJvYcCVFwNgjSEjS5NKytjvBj+8wHezNqzmqx8hPZp4XkXItF5px1/9JuhmTo/2ZULJ1cwQoqe02DdL1jYCmhThvqlVAu1RlzIPsxhXOFA== X-Gm-Message-State: AOJu0YxkJvyFCiANR+LMqTY47xpbQMlC6qhNjmuj0Ppba7nNQ4IsmGjq yAxT7P5DLT+mmNkEuoK0c9A6rWoahRqaCSr0PmqRp12/LQafKPfYTWbK+w7VSGDwRmayMyhWJKt R/pVejOpZLAwiNUC+zdbaXMjkI5sX45YdYvi8GuACy8cj+JqaiYhRZz/GDMo= X-Received: by 2002:a0c:eb83:0:b0:68f:e779:70f2 with SMTP id x3-20020a0ceb83000000b0068fe77970f2mr5934048qvo.3.1710366461088; Wed, 13 Mar 2024 14:47:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzQ7u+SJJkcqXmUXcq37q3NbZvmeXcFSg9ZX/No2VaFoCndSeWwMBLZUu/Dqoea36C4ilydg== X-Received: by 2002:a0c:eb83:0:b0:68f:e779:70f2 with SMTP id x3-20020a0ceb83000000b0068fe77970f2mr5934040qvo.3.1710366460771; Wed, 13 Mar 2024 14:47:40 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id dv10-20020ad44eea000000b0069111c5cdd4sm60114qvb.100.2024.03.13.14.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 14:47:39 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org, Matthew Wilcox , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , x86@kernel.org, peterx@redhat.com, Mike Rapoport , Muchun Song , sparclinux@vger.kernel.org, Jason Gunthorpe Subject: [PATCH 13/13] mm: Document pXd_leaf() API Date: Wed, 13 Mar 2024 17:47:19 -0400 Message-ID: <20240313214719.253873-14-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313214719.253873-1-peterx@redhat.com> References: <20240313214719.253873-1-peterx@redhat.com> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Peter Xu There's one small section already, but since we're going to remove pXd_huge(), that comment may start to obsolete. Rewrite that section with more information, hopefully with that the API is crystal clear on what it implies. Reviewed-by: Jason Gunthorpe Signed-off-by: Peter Xu --- include/linux/pgtable.h | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 85fc7554cd52..6b0d222a7fad 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -1770,11 +1770,25 @@ typedef unsigned int pgtbl_mod_mask; #endif /* - * p?d_leaf() - true if this entry is a final mapping to a physical address. - * This differs from p?d_huge() by the fact that they are always available (if - * the architecture supports large pages at the appropriate level) even - * if CONFIG_HUGETLB_PAGE is not defined. - * Only meaningful when called on a valid entry. + * pXd_leaf() is the API to check whether a pgtable entry is a huge page + * mapping. It should work globally across all archs, without any + * dependency on CONFIG_* options. For architectures that do not support + * huge mappings on specific levels, below fallbacks will be used. + * + * A leaf pgtable entry should always imply the following: + * + * - It is a "present" entry. IOW, before using this API, please check it + * with pXd_present() first. NOTE: it may not always mean the "present + * bit" is set. For example, PROT_NONE entries are always "present". + * + * - It should _never_ be a swap entry of any type. Above "present" check + * should have guarded this, but let's be crystal clear on this. + * + * - It should contain a huge PFN, which points to a huge page larger than + * PAGE_SIZE of the platform. The PFN format isn't important here. + * + * - It should cover all kinds of huge mappings (e.g., pXd_trans_huge(), + * pXd_devmap(), or hugetlb mappings). */ #ifndef pgd_leaf #define pgd_leaf(x) false