From nobody Mon Feb 9 10:26:33 2026 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 1AB10134B2 for ; Wed, 3 Apr 2024 01:32:55 +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=1712107977; cv=none; b=rhV2BlOEx/OZYBkvwi12lzETeQXNBMcxqppiz3Ny49t+gnZtKXuHa9yoOvy0TcJLIZOtPtUBQ5dDvdVY3THr/QKgezcHzEPsUoCvRCc1ddUN45oVws8Rn6Shf7Gt5+cLcOFl6sKWMvu77s5KP5AOiY0P+5sB1++kDpqv3hmwhBY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712107977; c=relaxed/simple; bh=oqREDFbRsB5mY8hvUf0QtLekrY+T63pjwUoG14JNFrg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MqaBQdBrqdKwoAxtUjCJ9suf2txfBOd1+VWPmUxcgHNM59lYGIVPwvobLMiumazi6yZyBh3AS3Aindec4StlkSQYuPRUB+xqeSvd6jAANyI4O1Hq0vUuhXyGp9zQCgeldXZA4RmyEwGfQPLJzLMPHpgVh5IqebXcf8nWqyYPaGU= 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=SnTw24CG; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SnTw24CG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712107975; 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=2ynux/F/qmq0vm7Pu7L1906YdTD8uR3G8JQyOTFf45Q=; b=SnTw24CGlBD2GEd/O0lRbL+TqtSOwWsFb7SDb5byk6WTftMkGYnR0XKQ+QfyKSdWOlJYpX gNYAxP+pJ210eOtg6s9evIs7knx0alS1WM37+WjToeEmKr6hQ14Y+a72zRy/G95rWwIwi5 vR7w4u95bvhPpmx5lZvuGhVOl+R1A4c= Received: from mail-vk1-f198.google.com (mail-vk1-f198.google.com [209.85.221.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-499-Co_-N685O5uFN6fq81JDJw-1; Tue, 02 Apr 2024 21:32:53 -0400 X-MC-Unique: Co_-N685O5uFN6fq81JDJw-1 Received: by mail-vk1-f198.google.com with SMTP id 71dfb90a1353d-4d8837d610fso904742e0c.0 for ; Tue, 02 Apr 2024 18:32:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712107973; x=1712712773; 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=2ynux/F/qmq0vm7Pu7L1906YdTD8uR3G8JQyOTFf45Q=; b=kmatSzGV8KszFpK838VWBvz8q6hOk5OhwLJqjXHkghyTACnjAL4We0R38Xln2zZPgo LehAWrWgM7FuOpcUS+kIakT06XVY13xN6om+lrcMenewbRqbL4+/PuvE++uZajAyAJ/L dz1PLnWPLVE1p8LVEGwBGAeGEVwCqN9A7xy/NCPi7fKPbKrbUCSoCVI3H9jTOFih1TVT vlNLhLei+fb+cHbtvyyBHblz0BL8B3vWx5EbB1mCAF+1E83neK+lykdj0HJ3bb2vfiTU JAxbuBYaaAF/09+mgb7e7VLut2MqsqbJ2W9n4SUHfr/42n7O67St+iweYhiVOnyJdZ8N UFiA== X-Forwarded-Encrypted: i=1; AJvYcCVIcA3GwENPX6h26PQjbi4prLmEqyPVYQo6rk+z3tOz59k5qo04UOC9PYHdGXzbNJkbvJhYSx2JgYIARGKYyWWZIIP/mIAb9SGtaNnu X-Gm-Message-State: AOJu0YyN/o/q95Ou8u0j8aD/o7lzmI3TqNpilbqELxKKcebclsYkPY36 68BESXLq1x37/grpeX8owHkct9wZ0ejrRRC2/ep6FzKNgLHW+WZ2dj5DShhhO6E22hqELIrFpR3 GvA9AALRnhSvRFfcjxX1BB9SRtgjnlwXeCr461LsFV8aOw2pZW3WDSwcq3a6UVg== X-Received: by 2002:a05:6102:588c:b0:478:9533:a75a with SMTP id ju12-20020a056102588c00b004789533a75amr2155412vsb.1.1712107972841; Tue, 02 Apr 2024 18:32:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE9+hYqxzCimkmspOuHcmCsRdwFLI47CvtrgBTMbK0H1Qo/OVIYE/CpCTqBmVGSH1xwK+vwHQ== X-Received: by 2002:a05:6102:588c:b0:478:9533:a75a with SMTP id ju12-20020a056102588c00b004789533a75amr2155389vsb.1.1712107972182; Tue, 02 Apr 2024 18:32:52 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id qm18-20020a056214569200b0068ff8bda6c7sm6031687qvb.92.2024.04.02.18.32.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 18:32:51 -0700 (PDT) From: peterx@redhat.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Huacai Chen , peterx@redhat.com, David Hildenbrand , Jason Gunthorpe , Nathan Chancellor , Andrew Morton , Matthew Wilcox , WANG Xuerui , Ryan Roberts , loongarch@lists.linux.dev Subject: [PATCH 1/3] mm: Allow anon exclusive check over hugetlb tail pages Date: Tue, 2 Apr 2024 21:32:47 -0400 Message-ID: <20240403013249.1418299-2-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240403013249.1418299-1-peterx@redhat.com> References: <20240403013249.1418299-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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Peter Xu PageAnonExclusive() used to forbid tail pages for hugetlbfs, as that used to be called mostly in hugetlb specific paths and the head page was guaranteed. As we move forward towards merging hugetlb paths into generic mm, we may start to pass in tail hugetlb pages (when with cont-pte/cont-pmd huge pages) for such check. Allow it to properly fetch the head, in which case the anon-exclusiveness of the head will always represents the tail page. There's already a sign of it when we look at the fast-gup which already contain the hugetlb processing altogether: we used to have a specific commit 5805192c7b72 ("mm/gup: handle cont-PTE hugetlb pages correctly in gup_must_unshare() via GUP-fast") covering that area. Now with this more generic change, that can also go away. Signed-off-by: Peter Xu Acked-by: David Hildenbrand Tested-by: Ryan Roberts --- include/linux/page-flags.h | 8 +++++++- mm/internal.h | 10 ---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 888353c209c0..225357f48a79 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -1095,7 +1095,13 @@ PAGEFLAG(Isolated, isolated, PF_ANY); static __always_inline int PageAnonExclusive(const struct page *page) { VM_BUG_ON_PGFLAGS(!PageAnon(page), page); - VM_BUG_ON_PGFLAGS(PageHuge(page) && !PageHead(page), page); + /* + * Allow the anon-exclusive check to work on hugetlb tail pages. + * Here hugetlb pages will always guarantee the anon-exclusiveness + * of the head page represents the tail pages. + */ + if (PageHuge(page) && !PageHead(page)) + page =3D compound_head(page); return test_bit(PG_anon_exclusive, &PF_ANY(page, 1)->flags); } =20 diff --git a/mm/internal.h b/mm/internal.h index 9512de7398d5..87f6e4fd56a5 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1259,16 +1259,6 @@ static inline bool gup_must_unshare(struct vm_area_s= truct *vma, if (IS_ENABLED(CONFIG_HAVE_FAST_GUP)) smp_rmb(); =20 - /* - * During GUP-fast we might not get called on the head page for a - * hugetlb page that is mapped using cont-PTE, because GUP-fast does - * not work with the abstracted hugetlb PTEs that always point at the - * head page. For hugetlb, PageAnonExclusive only applies on the head - * page (as it cannot be partially COW-shared), so lookup the head page. - */ - if (unlikely(!PageHead(page) && PageHuge(page))) - page =3D compound_head(page); - /* * Note that PageKsm() pages cannot be exclusive, and consequently, * cannot get pinned. --=20 2.44.0 From nobody Mon Feb 9 10:26:33 2026 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 ECF2514006 for ; Wed, 3 Apr 2024 01:32:56 +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=1712107978; cv=none; b=aD0PjHgTcAvjOijyY7DiwitKJOZhAoI3tNJwNpo7naeHpn3vVv9pHg4DtSw5em0521/AZNQQp+vmkI+lAg4JuzlkCLPjAoLbtV4mWcbhlHlY5fIr2Wj+m3QRXNSFXSpboctYF2bcFEOLuQR/CnlzZKhDqccFZKACKMV7hoGDTD8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712107978; c=relaxed/simple; bh=tDJsFCuEB0R3BpJAyJuzqy8CPWr5VO5Dk1p5YV+4YIc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EyqEY7egodU+QAK2LBrBffI42A1uziKvlZvq1IKTCI6pkxm8gjx8Ym1pXXzJ2GuDtDX0C/9hg8XXlrCDPmSZXm+zEG8Tr6E+yOWLC5xHqp2AEtX939+XJSGDWzi6zyKPxPvaWjiyunamSDeP5ABkco8S0Ycwh5j3gyqIYRShx0I= 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=U8k8wso+; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="U8k8wso+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712107976; 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=UqFcRORApCbbLwHiV/NvWvcvg5AC7kP7mUGUslgtJS8=; b=U8k8wso+Rv9yjf3YePfq8jUy8L8k71NsR1nmCb2etojMeFe8PviOzb8eqyxdZBunDahESU V3hpftv8sFJifCvX2q1ZJmykHgs+nUHX/3Q2vGQdwEGB/QYP4zHsMIGHG24KDuSQPU62XK 6Bl+Sjg+t/VkNt5pf/IQUGkGsoIp3JY= 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-208-0VQIcHcdMuq1trLK6-LZGA-1; Tue, 02 Apr 2024 21:32:54 -0400 X-MC-Unique: 0VQIcHcdMuq1trLK6-LZGA-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-69925f44915so937356d6.1 for ; Tue, 02 Apr 2024 18:32:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712107974; x=1712712774; 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=UqFcRORApCbbLwHiV/NvWvcvg5AC7kP7mUGUslgtJS8=; b=Pw2lj4yCt0sn/Dr0U+haK0fZSWkWhILdPfywBBdky60t5rm2kpIfQPM9opHG3yWQKm fGBKcxmOnkG0QDgDP+wlw3LwAf7m2ZQz0IAvWIc4I0fcySg1+WIZa220o01pV4WmBaMP mgYQM3tWGPbNZ8vOfcRhBlJAGy6aU7TwZylYxSV9DKlyTtYoacDU3imjX3y1SyleoJ9t yLHGcE0fzoUv+SSXmSzhdW52a0219yrR8WoBfZDzCLIIyL7CHSV71ju0n6yH3SP2iyFQ B+2/qBYkaIJJs3vmk/CJOYoSQGq5ApCORwmv4WkpNUNQnfS8CCFPByn+eBw383w7OM0c fK+A== X-Forwarded-Encrypted: i=1; AJvYcCXXQdoycVgu+pl2nCuBjkemQMToFJt1QtURR8aWsYhgTQngzGxU+OZRXt7YQFmT428Wg8loxZ2OD18dReVnFafU4YfNcw/+UjF+1GLN X-Gm-Message-State: AOJu0YwSEzu12u0jMrVXsxG9LLoMJQD2jwwlMT15xu8zNv5VP2JF2AsY c6VnFgicAHbhx9MT1ftiXuGbhVhbWeeePfMqwjxRuBZg14OJ40/lN00k85opgcqcmbdoHsmSAlX G805qwkGI7JfmInIhXqy4g6rnTp2UgdTrXFuP7CLFHmVEkYcsBIO/zolJ1dY/MA== X-Received: by 2002:a05:6214:946:b0:698:ff21:99f6 with SMTP id dn6-20020a056214094600b00698ff2199f6mr9007652qvb.3.1712107973810; Tue, 02 Apr 2024 18:32:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdeiJvxhuNcK+1vYTZU0OZ0cczYLrBalyCYqNCwtKHKX2kkX+lMyBxEcKCdgdQrvrdhUD2Gg== X-Received: by 2002:a05:6214:946:b0:698:ff21:99f6 with SMTP id dn6-20020a056214094600b00698ff2199f6mr9007637qvb.3.1712107973351; Tue, 02 Apr 2024 18:32:53 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id qm18-20020a056214569200b0068ff8bda6c7sm6031687qvb.92.2024.04.02.18.32.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 18:32:53 -0700 (PDT) From: peterx@redhat.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Huacai Chen , peterx@redhat.com, David Hildenbrand , Jason Gunthorpe , Nathan Chancellor , Andrew Morton , Matthew Wilcox , WANG Xuerui , Ryan Roberts , loongarch@lists.linux.dev Subject: [PATCH 2/3] fixup! mm/gup: handle huge pmd for follow_pmd_mask() Date: Tue, 2 Apr 2024 21:32:48 -0400 Message-ID: <20240403013249.1418299-3-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240403013249.1418299-1-peterx@redhat.com> References: <20240403013249.1418299-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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Peter Xu Allow follow_pmd_mask() to take hugetlb tail pages. The old warnings do not help now as hugetlb now allows it to happen, so drop them. Reported-by: Ryan Roberts Signed-off-by: Peter Xu Tested-by: Ryan Roberts --- mm/gup.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 91d70057aea0..d60b63fcfc82 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -775,8 +775,6 @@ static struct page *follow_huge_pmd(struct vm_area_stru= ct *vma, assert_spin_locked(pmd_lockptr(mm, pmd)); =20 page =3D pmd_page(pmdval); - VM_BUG_ON_PAGE(!PageHead(page) && !is_zone_device_page(page), page); - if ((flags & FOLL_WRITE) && !can_follow_write_pmd(pmdval, page, vma, flags)) return NULL; @@ -805,7 +803,6 @@ static struct page *follow_huge_pmd(struct vm_area_stru= ct *vma, =20 page +=3D (addr & ~HPAGE_PMD_MASK) >> PAGE_SHIFT; ctx->page_mask =3D HPAGE_PMD_NR - 1; - VM_BUG_ON_PAGE(!PageCompound(page) && !is_zone_device_page(page), page); =20 return page; } --=20 2.44.0 From nobody Mon Feb 9 10:26:33 2026 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 0A64214A9D for ; Wed, 3 Apr 2024 01:32:57 +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=1712107979; cv=none; b=H49w1RiycFEASOUybxvC5L9XATqsEnOWPf117OleEQi+ekrxZ1q65gfWFwoV++Sy2sW5EdklydojwuKV3yW/uvtoizq3KTtIT38Iv01WHknL1r+znNoRukAlpLlWOrEN9Xel4/7i3PyM2rt8utY1/OPMP91BTLgMjM8Ao2jKYZw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712107979; c=relaxed/simple; bh=z1GaugFYICjVSrn2n8rnHfGDwwW/vuxiZSFHEY4qUdg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KlS0hak/8RfmZShXEABA6/h3j96yDzJSikZe45spqoR0JFe2oprDh3kq20aqp68HpycuFftwjdqbgttTjBjeCgKVMFkDFB/D7CpeEdcixEiIe7aL5humdxzJhVWlqsz/R6J2L64Km8OybogzfWJU2foLJe66CjN4SgtnGfzi5kI= 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=H+khp82s; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="H+khp82s" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712107976; 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=PR/NBCt+5qJ4X31foyrecLlAlU9UbBCiiBiwAD7jaH8=; b=H+khp82sZxOLI++B7jpOxxre5hhOx5sM7WFXrAEN70n6cDeySi4WSi/vXlNfYur1SEz2IZ hKb37eb1nERa2rdpKAq4s2ALMDXWU6NL/ZFh2gfMZ25W2ZZYpKHTlTRUa6DiWb5d5KWumL 4otW9SD4aoOCrH0UDvqtxoefcJhoJu4= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-210-RtxefYq6NIeYwwSouRjnFA-1; Tue, 02 Apr 2024 21:32:55 -0400 X-MC-Unique: RtxefYq6NIeYwwSouRjnFA-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-4311dd10102so23842621cf.0 for ; Tue, 02 Apr 2024 18:32:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712107975; x=1712712775; 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=PR/NBCt+5qJ4X31foyrecLlAlU9UbBCiiBiwAD7jaH8=; b=wb/lKpOpkIOrmyxxmW1AuOAfE8HpJnBlesS3+d3HObVG4hvcUPK0i13sqFSeu1KkfZ wTFxwPO7ttzw5BFTaDrzjw1iQR2C019poZAqg10LVrQbmG/9cVIXwZYV1jGCQGLw5ZyO X0bosezjGQviUCWJCRwXSZrEyl03ou6Q/CPPxRewrWIksIfCph9hqgjIIwp3NasyQqLz xC1H4h9W5zzPPdr8mG9zPCLBgtraCPWra6W/I8/ydpGsunPMiW8DSpeqz1jD6nBylgf5 lp2gJeLU1Bp3nvClyKFYDDUyZUG3If2Q6ObX6JBW17AwM3r7XBPp63uvOdhGxJQ/nIVG 43eQ== X-Forwarded-Encrypted: i=1; AJvYcCWTTE0GsaK36eFK06sQAO3VJSy+4eaI/m13e8RqzlyebQyjWydoC5IGLUK8GwUr8KLY9L3tf6OBRVemWjg0ilOVOMEqqyIjtEuNI2Pw X-Gm-Message-State: AOJu0YypnvXO9XARqAnS+meDTtKSZHM/GFS8QWkLWtNUFwB9DyPkIvb2 BYtFbY/y/hzyyMOA/lOF/9zzPXUpfpYGe+p1uFOuGTkPMwOmDDBdbGKvENLOJo1DbVeD0V+z3fK E9YdSKf6yeO9m5lRHMsDhRHZILvFdKfcS+io+Vu1picmJRSfrbddFreIjpmEcaQ== X-Received: by 2002:ad4:46d3:0:b0:698:fc78:21ae with SMTP id pm19-20020ad446d3000000b00698fc7821aemr9828987qvb.6.1712107974909; Tue, 02 Apr 2024 18:32:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDjHRAOIt7pAcFSSzP58lew6Exi/iOo8/2ozkB/HO9HAPtSJzX+RWcE9OqEaW9cSxSEbXVlA== X-Received: by 2002:ad4:46d3:0:b0:698:fc78:21ae with SMTP id pm19-20020ad446d3000000b00698fc7821aemr9828970qvb.6.1712107974456; Tue, 02 Apr 2024 18:32:54 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id qm18-20020a056214569200b0068ff8bda6c7sm6031687qvb.92.2024.04.02.18.32.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 18:32:54 -0700 (PDT) From: peterx@redhat.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Huacai Chen , peterx@redhat.com, David Hildenbrand , Jason Gunthorpe , Nathan Chancellor , Andrew Morton , Matthew Wilcox , WANG Xuerui , Ryan Roberts , loongarch@lists.linux.dev Subject: [PATCH 3/3] fixup! mm/arch: provide pud_pfn() fallback Date: Tue, 2 Apr 2024 21:32:49 -0400 Message-ID: <20240403013249.1418299-4-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240403013249.1418299-1-peterx@redhat.com> References: <20240403013249.1418299-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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Peter Xu Signed-off-by: Peter Xu Tested-by: Ryan Roberts --- include/linux/pgtable.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index fa8f92f6e2d7..0f4b2faa1d71 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -1882,9 +1882,13 @@ typedef unsigned int pgtbl_mod_mask; * code. Now it happens too for pud_pfn (and can happen for larger * mappings too in the future; we're not there yet). Instead of defining * it for all archs (like pmd_pfn), provide a fallback. + * + * Note that returning 0 here means any arch that didn't define this can + * get severely wrong when it hits a real pud leaf. It's arch's + * responsibility to properly define it when a huge pud is possible. */ #ifndef pud_pfn -#define pud_pfn(x) ({ BUILD_BUG(); 0; }) +#define pud_pfn(x) 0 #endif =20 /* --=20 2.44.0