Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp995415lqs; Wed, 6 Mar 2024 03:16:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWVICjrn4GmNjLL7hIZDmkZMhemh3FfOM1+JRCdZrB4DJvoGV887PsXAcgwIUeyvva+dfWYsQyKfEHfggqUb36wiQAF2PEkeYYo886IXg== X-Google-Smtp-Source: AGHT+IGeSFy++mqKhTzjjJL4PK7KUvI/y2AwLTrEPKd/cB1V1w1T4y+dMxM2VNZw4F0X8TYsOZ56 X-Received: by 2002:a05:6a00:4b42:b0:6e5:ec63:95dd with SMTP id kr2-20020a056a004b4200b006e5ec6395ddmr11256489pfb.21.1709723779058; Wed, 06 Mar 2024 03:16:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709723779; cv=pass; d=google.com; s=arc-20160816; b=vyNn/UX/xMQn9fTQIXzqu3m6iS41xBmH19MENCB3kVMpirpo8gO3E4o9TLxplvm/gp yNPHr94U0oFKyolwTEkl1tX+ZmwIgeTTgtmQ42GJDium7CQQXedjFazwXx029+3ydDgg ayvU56WBnLDyOVRqjriy2IJgOPy9CwaPjOwjlc70TXbu0vSwknr53xjoNOU4SoQZacM4 0tETa4O7ksgdGXVwZ3ZZE689HQ79RvTXOuNh4K+Vh2Wd/D5p8NoWe3NP+lHcOavyndQo 6Xzq0X0Uf/4hb9lZ0034kE1BXiKfeeflal8rRR97MIpkvhAfFgaYDfcZqZYvdWdTX+ZI FhaA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=20nNimBrOEQv87l0vyMx8t0O66X6ZMzRQtOERvnhrUo=; fh=TfNJ8xcgN3m/teezD0dzXtIbyKrw2zuc7fzjnbGjy+c=; b=Hy0z+OWq89XwmM+D39nS4k+bIGRbBnRymW+L2GI6zbsNJN//FdyIIza5Fq4vVqhuC4 n7pOfi/hRZnitOeN3c2jmdZOJJ8AFWm13zIRolRSw3k2NJeToJjG24igUu4PhXPVZ73K 2vYVbY7QzKqxZgDmxEWeni816egCNNLhyIv3rzV7/tAAyPK21jRU4/uVjHPt9s7Qbt0a O7qi5syBl5MbVU0+3xjM6ZpX7XOKTjtTk4GCJiY0WDd+6mcPUfhqqeG+6kn5Hgri3w25 UxPlfncDQjNBWiT3xvu6JFbkstkR/ilvcPHFxpnhbqYbx2FDYY7PCEcv0Dg4ujSM2+Cg osDg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OYLVYXF0; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-93786-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93786-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id i4-20020aa78d84000000b006e6465f77f4si1864118pfr.348.2024.03.06.03.16.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 03:16:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93786-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OYLVYXF0; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-93786-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93786-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 951ADB2AE32 for ; Wed, 6 Mar 2024 10:42:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7CC9F605D9; Wed, 6 Mar 2024 10:42:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OYLVYXF0" 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 204DA605C8 for ; Wed, 6 Mar 2024 10:42:10 +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=1709721732; cv=none; b=m+B80v5fW928eBQdSitwM4Vw6rwR98DXAKq6igLOUjhMgWAvG07z9iSvdKjb5VEdn2YeCh100xhttIMQUG782LkUMl0UIiYTJgn4K3BmAwxhLsfcaXHyBShKPjLo0MFEWS2xGCrMa1ng2TnLI23/0G8UjkUtCunwAwDo9i3cRT8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721732; c=relaxed/simple; bh=TOc5ZVxpN+gjn979gpSdbWiDJGT5Kkl4rfkIMqncNfo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hLjKnDlJT53eKA8GstsP4NWbHLtZb6n6UjaQnEAP4EesqgK/N4tFpaelzwEXeYunTxL4+MrfzJ55SAxrwpKd4CTaRBXrfk32DZxJ8RmKAV1A4aAUoOyI6AMvfs/0lQGuSN++WZs8uMemGYRi+mcEDidCgtnMzCmCpFlA+ZfL+UE= 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=OYLVYXF0; 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=1709721729; 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=20nNimBrOEQv87l0vyMx8t0O66X6ZMzRQtOERvnhrUo=; b=OYLVYXF0Q3FH516eOTadMFuJ1FxoUjoGoN6h49kP8znMXzmUDfEiXVx+ryyoALMSfZukmw FPGGSwjjnWKTMNWJsg2Q5016DO7b/0AL07psN4DxKitcKg59xXmu8SDLdlNAPPACoDb2Xe KcZAt+FgGNXsRu7C8VTx7sMerukt7Zg= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-651-oo52lPpuOsCDdbHCtpeneA-1; Wed, 06 Mar 2024 05:42:04 -0500 X-MC-Unique: oo52lPpuOsCDdbHCtpeneA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C7D471C05AF3; Wed, 6 Mar 2024 10:42:03 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C2C5112131D; Wed, 6 Mar 2024 10:41:56 +0000 (UTC) From: peterx@redhat.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, Andrew Morton , Muchun Song , Jason Gunthorpe , peterx@redhat.com, Matthew Wilcox , Mike Rapoport , Christophe Leroy , x86@kernel.org, sparclinux@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Alistair Popple Subject: [PATCH RFC 01/13] mm/hmm: Process pud swap entry without pud_huge() Date: Wed, 6 Mar 2024 18:41:35 +0800 Message-ID: <20240306104147.193052-2-peterx@redhat.com> In-Reply-To: <20240306104147.193052-1-peterx@redhat.com> References: <20240306104147.193052-1-peterx@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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 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..c44391a0246e 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_none(pud) || !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]; -- 2.44.0