From patchwork Wed Jan 29 11:54:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13953685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDE52C0218D for ; Wed, 29 Jan 2025 11:55:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76F73280041; Wed, 29 Jan 2025 06:55:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 72076280025; Wed, 29 Jan 2025 06:55:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 573D0280041; Wed, 29 Jan 2025 06:55:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 3714C280025 for ; Wed, 29 Jan 2025 06:55:07 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EB655120CEE for ; Wed, 29 Jan 2025 11:54:27 +0000 (UTC) X-FDA: 83060331774.04.D945E94 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id AD70440010 for ; Wed, 29 Jan 2025 11:54:25 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hMADFfoo; spf=pass (imf11.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738151665; h=from:from:sender: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:dkim-signature; bh=herznK9N3+37fO8/yUnjjPI+kU1qrhYMSQrHDNQrbI8=; b=dkkU07lvKNTtXoa8hUA7wDkYBSJLFweeQhmObSipEpoxF8Tlhj53E5zCT6MZFyzdy3YpKm 6yGuCcOWF56XVtgYhKSRwSNqV50hmK87woC0skpKW0XhXtNQKTjUDom29/lcVo6vM7pCO1 VnqIEcfcAnlP8T++g7aSStQAWUNKmDc= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hMADFfoo; spf=pass (imf11.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738151665; a=rsa-sha256; cv=none; b=S5ZRFulnz5mSAKxTAey9se6aFVAcJpvyBeaFtQ2gDl7clKXrhEOVvqWFjlv6qoVrwODxZN Yd+AZtS6IGjrxRtk2umO5Jlvl0k0eHmcFUXEBHLmSaI476oTMA0VQ9/F15NT8parNAb8Qo Z4cYdbUOyEJRcGqG5ziHZUY4sLvvsFM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738151665; 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=herznK9N3+37fO8/yUnjjPI+kU1qrhYMSQrHDNQrbI8=; b=hMADFfoopB18sNNmEW1bLa3glL3c9ZuvalEuwSIxmuL/58tRa8jO36GXrMC645H5eYSe6z Hr4v7esVJU/t4Le5oxZjz9YMiZ67rzzsG9fxPj5HMs+Dozq+aAzgge8bmtDLnOzhnVvMDl yrW7HujKj6aPVcOYPAMTdqv8ZmPi/kw= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-691-an8ZvwIvNGyhl4jjfmhnvA-1; Wed, 29 Jan 2025 06:54:21 -0500 X-MC-Unique: an8ZvwIvNGyhl4jjfmhnvA-1 X-Mimecast-MFC-AGG-ID: an8ZvwIvNGyhl4jjfmhnvA Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4361efc9dc6so36447515e9.3 for ; Wed, 29 Jan 2025 03:54:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738151661; x=1738756461; 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=herznK9N3+37fO8/yUnjjPI+kU1qrhYMSQrHDNQrbI8=; b=uuIbHpx1oQeasKwaNr2VHgl6EtPm/eHKkXrcssXAgst6GviYrBFM6kL4wdwuRj3HhG aq7TtvG/cyfxbaGxM4U4180cCtY7SMI2VnOkOyhnkjNxNh1RpjAzieJrIrVtvDwtyOMq dQonwVW+PLr5UQTpCRcLOSZDkCzsM4OCJ9mLye/FGLOjfkxzCfwUwCaov4dYme2h4Gf1 /NPeltM820/e1vzxFEovaXtkSZWplo586jw0kwR/XwhAaM4GCSPeygbMVUEdDi5GMKoE eS0u3wuIBWcZPZn1WRsk7K8sJ5E6W2oU1z7S9qRzYNbj6YLIb72RV6wDj1Swt0wmJhI8 WLpA== X-Forwarded-Encrypted: i=1; AJvYcCVoKslQe1eF/jt/SgYXaYhOk/Mrr0r8XXqe6xXFS9uFTKg+IJQlBsGpifxC5EP1td8l8EKP1lpy7g==@kvack.org X-Gm-Message-State: AOJu0YzS7npS/+211bKVRp2eNusIWjhxfjs9428QpJKDt7irZpD+TPhZ xjYPNu0pebFA2L5niLnlBaL6vR6J+s7dFuqW1gnye0iUXTSyJ5JLebLJM6OjUm0WBimbzK3Ic+/ P0oeih1xSGJ+dH4Xn/KFT4J9eoGGp9AySfiJsqYtAFbxSWisO X-Gm-Gg: ASbGncs/twSee6uHxZryKJnYEHAES30l9jElBpV0DQ5WJG47s5aIrVawRyUSHYSFtjD 40aJC+WeXquvp58wCWQnSjwFxcEijjefgGMguAwXS1LPTjDMHF8P/wruVGDaHbvOrq4jRFzNupj dQPoyRJXIY8wZymuEj6+pTrEfTdDnP0e/m8mp6Z1MX0he4KdCj8a32Oplv+ueQqbZ3m5CYfVHYG eYP7MuMYvbGb+3vbhQyK/GkNHMRdHSmIU9uDGylgXTRHnG3TuZUu563+ja+HLqqfGLP0IzXpwFK C9PC0EI3OzsmMfT1trY7WfG11raQOcYIZyNubAvujSKIEOjZlduyjHzg6FGF9pejvw== X-Received: by 2002:a05:600c:5486:b0:433:c76d:d57e with SMTP id 5b1f17b1804b1-438dc3a40d3mr26190565e9.5.1738151660695; Wed, 29 Jan 2025 03:54:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IEopxoArzHie066mjWjUvNKTSc/02V79PTjUrPj2QcjbwdMpR1m12X2+qvEI4pAjYXanIEeWA== X-Received: by 2002:a05:600c:5486:b0:433:c76d:d57e with SMTP id 5b1f17b1804b1-438dc3a40d3mr26190115e9.5.1738151660040; Wed, 29 Jan 2025 03:54:20 -0800 (PST) Received: from localhost (p200300cbc7053b0064b867195794bf13.dip0.t-ipconnect.de. [2003:cb:c705:3b00:64b8:6719:5794:bf13]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-438dcbbc52dsm21427725e9.0.2025.01.29.03.54.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jan 2025 03:54:18 -0800 (PST) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org, nouveau@lists.freedesktop.org, David Hildenbrand , Andrew Morton , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Jonathan Corbet , Alex Shi , Yanteng Si , Karol Herbst , Lyude Paul , Danilo Krummrich , David Airlie , Simona Vetter , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Pasha Tatashin , Peter Xu , Alistair Popple , Jason Gunthorpe , stable@vger.kernel.org Subject: [PATCH v1 02/12] mm/rmap: reject hugetlb folios in folio_make_device_exclusive() Date: Wed, 29 Jan 2025 12:54:00 +0100 Message-ID: <20250129115411.2077152-3-david@redhat.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250129115411.2077152-1-david@redhat.com> References: <20250129115411.2077152-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 7MAYCi4wGh2XClFBW5T9MD-DK7ioUM0CijBh_0GEOIQ_1738151661 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: AD70440010 X-Stat-Signature: 5pip9bzahun6i9syq4s3b4hy8smp63kb X-HE-Tag: 1738151665-187769 X-HE-Meta: U2FsdGVkX18RH5KyShFCp/7nO1nFhtGFRZQKc1HzK3Ux8CgviMO7o35QOGE3t4ZGByuZKS5d6p+hGsAR54oqXafN8ujpRLr9TvvRTQ/DHOLzlaybO04cdhR/4HVBfPwXukvLDlecV2CFnzVXUI4GLYjgWVXkU030VKfyViP1Rl6Z0xPddkDpWSOxVaU/WiVBFzzpWS7BWolpQf8qPlOmeNYLlwZPr5O4RFJfn9ZJqZc0eQJEd5U7dJNhoxE3boEqxdZLIoxruNgXpuwSWMgSy7hIe9ifvtXh4ZBcbaJtnCJcKFlh/IlSeGz0+meSxzuo364CSmLycC9CorStbxLzNgENJQSJL3oZHsJuNN8iNRNaCB+X79M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ds6PosWc/sXZsk1qOesZYbDjiAWxVhPFQ1mocGDcYB+Ef19jxFNVpzu04k4SZRFqf6C5ZSPGnnW6I9e5Jmr/ncLAMUbH7eVWwqw/pwa2w7ud0KTo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.009333, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Even though FOLL_SPLIT_PMD on hugetlb now always fails with -EOPNOTSUPP, let's add a safety net in case FOLL_SPLIT_PMD usage would ever be reworked. In particular, before commit 9cb28da54643 ("mm/gup: handle hugetlb in the generic follow_page_mask code"), GUP(FOLL_SPLIT_PMD) would just have returned a page. In particular, hugetlb folios that are not PMD-sized would never have been prone to FOLL_SPLIT_PMD. hugetlb folios can be anonymous, and page_make_device_exclusive_one() is not really prepared for handling them at all. So let's spell that out. Fixes: b756a3b5e7ea ("mm: device exclusive memory access") Cc: Signed-off-by: David Hildenbrand Reviewed-by: Alistair Popple --- mm/rmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/rmap.c b/mm/rmap.c index c6c4d4ea29a7..17fbfa61f7ef 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -2499,7 +2499,7 @@ static bool folio_make_device_exclusive(struct folio *folio, * Restrict to anonymous folios for now to avoid potential writeback * issues. */ - if (!folio_test_anon(folio)) + if (!folio_test_anon(folio) || folio_test_hugetlb(folio)) return false; rmap_walk(folio, &rwc);