Received: by 2002:a05:7208:3003:b0:81:def:69cd with SMTP id f3csp4187107rba; Tue, 2 Apr 2024 09:40:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUW4AUi477kRFiLHATnauh54OnLSxqcy+hBUvmePoopMl8eQN9MDrrgVKD8/Ow35oxSCRoT6/rNGN0X2lr7rOiGAfGEqy1hlu5WRb06rw== X-Google-Smtp-Source: AGHT+IHrshDSRMHrOACpvZz4qcI1cia5ml5guANMFE60oWo21zZaMZbUqynHxhfSdgc8fdvagcEO X-Received: by 2002:a17:902:ea12:b0:1e2:3e0a:fc61 with SMTP id s18-20020a170902ea1200b001e23e0afc61mr254252plg.34.1712076030602; Tue, 02 Apr 2024 09:40:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712076030; cv=pass; d=google.com; s=arc-20160816; b=ke7IZCfbCK91/nzj+dvxzT+xVw8g/IPg2DOiutO9B9Igxzo4aqcNu6ryEOrL/qvUQs JaLuboBJa1E4RCRKP4WTBfkQO5dtXf+aYkN88uaDkvqdK2HuZ1YRn4AbrOKjW8VdA/4x MNL6w6jEu8tB5WBkKNNphftqcFNgd/RkK+tduTyp7opQPey9L3DXxvLRRapNqBeiQjIQ /H2syp4j9kiJqRAAMNeyjfbiWp6eVZgIMptzSlEIk2RPuuMX8a/MkEFajYCu6USyMrN5 4TC8dAtf9vvD4V18bdv4FEO8s1Nvhcp/XQprbHY4gDo2nArmQzorVCg4ZQuRN8hNOTDG zmBA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:message-id:dkim-signature; bh=iEb1HUNjpnqEgLGmlXxstqgOUp3S0IqEbnWahtuTkPk=; fh=Mjt+bL92WfBq6cOk6frXDw1gntJUUH//2FOyN1MVq7w=; b=EW6V24NDsLh5tEE25jrzXnAnP/AQqbTjx8gZG8mPaHkxqtRZ6zchE5cNGQhVbmyKyR YaP2kGo1oZZ4xJ08UijrzWKghl5HeJfBsQ9PsuLdAtXdyPewDcHJZ97dI6MgeQcK2paU NvYae97Zy9u7NOzJ1fc3ckLlhs2zMQBJdJSDyfiYrZcAOmGBbVcL/WCbvN3gRo8nBUr6 qLuSnyQbe0v8axH5XRgI3ICRFGuqs3lAqQ70C+geq++TuDcFPkfZAKp8O3dZ4cCeKt0R yfSjk0Xef1ASAyIXz+Bji53wQsCX3M2+8Vu21m7T1mdu8+7RxIcC0DZ00d+zVTmyzOqc 5w7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hpmd0MXj; 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-128361-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128361-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x11-20020a170902a38b00b001e02dff570esi10760177pla.202.2024.04.02.09.40.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 09:40:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-128361-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hpmd0MXj; 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-128361-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128361-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0117828704E for ; Tue, 2 Apr 2024 16:40:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8FBDF15A48A; Tue, 2 Apr 2024 16:40:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hpmd0MXj" 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 685681598F6 for ; Tue, 2 Apr 2024 16:40: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=1712076012; cv=none; b=p1zsV47GcX1ccGQEbpc42HZthF7t1ItZuTfyLLxJBOZO6dpnzc/HXBidGcFyTjvluOH3ulJTuuo7ZLiSMXmmSQMTQ1vpOTdZutDAU6ijI60nBA32r+a82dW8rbZNKvl5s1ZNiKyuA2/HRH4C/yWFE0bwCRWuVLZq9G4PCl3/qHg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712076012; c=relaxed/simple; bh=agCorDctzOnEBAOUE8vStWX0Yxg1CI1HzeGRcPoVj6Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=RJHj+AydPKtbKTVjyMMTlP2bmk9g6hrx+2p4zhlLS3AkbmNaKuUlAB/obTuwPW5bhxapiAsDsK3PZOybUcZiwXZKwv8c/P0Kh9luQFWU60zSyWyvst0HSnVz0Ml4qESrPncv+F7Dmww3vZ8ERGV2jZbcfH897d9icoxR8+OsDdk= 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=hpmd0MXj; 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=1712076009; 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:autocrypt:autocrypt; bh=iEb1HUNjpnqEgLGmlXxstqgOUp3S0IqEbnWahtuTkPk=; b=hpmd0MXjgJHQCXMsNPgRbG+wPn+eoMVy/l4jpXkTlTjbsFYX+K490jU4eHjFuYWlcEYZlh Oc1zg/jW/2j9wTcoqIvo+Aaneu6oEtcVXGbxnuP2Mg6JypOCIhHOq2JHaAS6WKicjENK6n Xt0uzKWk6GuEcA4hv3VociXqZcXO0M8= Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-267-WeTDQxHvOCqZGcnYQ1IFsw-1; Tue, 02 Apr 2024 12:40:08 -0400 X-MC-Unique: WeTDQxHvOCqZGcnYQ1IFsw-1 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2d818a149bbso15246091fa.3 for ; Tue, 02 Apr 2024 09:40:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712076006; x=1712680806; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=iEb1HUNjpnqEgLGmlXxstqgOUp3S0IqEbnWahtuTkPk=; b=fOFWdqLKdcG3bZPJlwZ0Ue95q9Tn/s0PnJdmSkvOM9SB9fTImhD1oPIJz9iVXmagaN 3eer8t1xxyioc5p5m3iQV/JAVc702e07Ufvttc5XEGMXZallFUkZSvdC8tTQMiE0MtAn 2OWb7iSjKZKDiJWvD9StWz+9Gx9xkReVxwgFBAEh1x9tSTr/wdkT+qAKkz1wNsPjNJhv 3vAURj5QsIuB5c4bQ2A9ClQX3BcnhjboGA2LWBnrrGNK6JV0T86IkljwplPfsOU7s5e3 /g4slPoL0az0f5RpTd3jHiRSX0dK0qfCXjOkWk+58sxxafallIOIWQscocaHG/0fEhFv JIHA== X-Forwarded-Encrypted: i=1; AJvYcCUz+Mdtu02xsBeXqYQ/loxSAzzfotPdO5MlVW0O/0LB4QHIfn8FfrjrehLRft04b+PUjyaQbfXmVVdfL95R2XWaa4vC2SYqhex7eoXy X-Gm-Message-State: AOJu0Yw4vNXu4QM+/IPrz91DLlhj1kQ9gIrvWuaauO9S09uSfKgrLKIX IOlmMz3mQMSTcj0zx6/DLB8eQhhrBo5jp4e0czchsSJ/Ez8xQONIBK5/Zj7Ol60PxngTvgudxlg AbL9z3wCwUN2XHBA2NP7Y/rUrxQVqDaHRH8sW+ShG61bK3PIJFN6ek3NiQD4qEQ== X-Received: by 2002:a2e:a1c6:0:b0:2d6:f56a:2c93 with SMTP id c6-20020a2ea1c6000000b002d6f56a2c93mr100945ljm.49.1712076006578; Tue, 02 Apr 2024 09:40:06 -0700 (PDT) X-Received: by 2002:a2e:a1c6:0:b0:2d6:f56a:2c93 with SMTP id c6-20020a2ea1c6000000b002d6f56a2c93mr100927ljm.49.1712076006141; Tue, 02 Apr 2024 09:40:06 -0700 (PDT) Received: from ?IPV6:2003:cb:c732:e600:4982:2903:710f:f20a? (p200300cbc732e60049822903710ff20a.dip0.t-ipconnect.de. [2003:cb:c732:e600:4982:2903:710f:f20a]) by smtp.gmail.com with ESMTPSA id t10-20020a05600c450a00b004161b59e230sm2538868wmo.41.2024.04.02.09.40.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Apr 2024 09:40:05 -0700 (PDT) Message-ID: <98d4ef76-93e4-4e76-be60-9f0076389dc5@redhat.com> Date: Tue, 2 Apr 2024 18:40:03 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 13/13] mm/gup: Handle hugetlb in the generic follow_page_mask code To: Matthew Wilcox Cc: Ryan Roberts , peterx@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yang Shi , "Kirill A . Shutemov" , Mike Kravetz , John Hubbard , Michael Ellerman , Andrew Jones , Muchun Song , linux-riscv@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , Christoph Hellwig , Lorenzo Stoakes , Rik van Riel , linux-arm-kernel@lists.infradead.org, Andrea Arcangeli , "Aneesh Kumar K . V" , Vlastimil Babka , James Houghton , Jason Gunthorpe , Mike Rapoport , Axel Rasmussen References: <20240327152332.950956-1-peterx@redhat.com> <20240327152332.950956-14-peterx@redhat.com> <5d9dd9a7-e544-4741-944c-469b79c2c649@redhat.com> From: David Hildenbrand Content-Language: en-US Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2Ahm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eop7uh+6bezi+rugUI+w6DABEBAAHCwXwEGAEIACYCGwwWIQQb2cqtc1xMOkYN/MpN3hD3 AP+DWgUCXw7HsgUJEqkpoQAKCRBN3hD3AP+DWrrpD/4qS3dyVRxDcDHIlmguXjC1Q5tZTwNB boaBTPHSy/Nksu0eY7x6HfQJ3xajVH32Ms6t1trDQmPx2iP5+7iDsb7OKAb5eOS8h+BEBDeq 3ecsQDv0fFJOA9ag5O3LLNk+3x3q7e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 02.04.24 18:00, Matthew Wilcox wrote: > On Tue, Apr 02, 2024 at 05:26:28PM +0200, David Hildenbrand wrote: >>> The oops trigger is at mm/gup.c:778: >>> VM_BUG_ON_PAGE(!PageHead(page) && !is_zone_device_page(page), page); >>> >>> So 2M passed ok, and its failing for 32M, which is cont-pmd. I'm guessing you're trying to iterate 2M into a cont-pmd folio and ending up with an unexpected tail page? >> >> I assume we find the expected tail page, it's just that the check >> >> VM_BUG_ON_PAGE(!PageHead(page) && !is_zone_device_page(page), page); >> >> Doesn't make sense with hugetlb folios. We might have a tail page mapped in >> a cont-pmd entry. As soon as we call follow_huge_pmd() on "not the first >> cont-pmd entry", we trigger this check. >> >> Likely this sanity check must also allow for hugetlb folios. Or we should >> just remove it completely. >> >> In the past, we wanted to make sure that we never get tail pages of THP from >> PMD entries, because something would currently be broken (we don't support >> THP > PMD). > > That was a practical limitation on my part. We have various parts of > the MM which assume that pmd_page() returns a head page and until we > get all of those fixed, adding support for folios larger than PMD_SIZE > was only going to cause trouble for no significant wins. > > I agree with you we should get rid of this assertion entirely. We should > fix all the places which assume that pmd_page() returns a head page, > but that may take some time. > > As an example, filemap_map_pmd() has: > > if (pmd_none(*vmf->pmd) && folio_test_pmd_mappable(folio)) { > struct page *page = folio_file_page(folio, start); > vm_fault_t ret = do_set_pmd(vmf, page); > > and then do_set_pmd() has: > > if (page != &folio->page || folio_order(folio) != HPAGE_PMD_ORDER) > return ret; > > so we'd simply refuse to use a PMD to map a folio larger than PMD_SIZE. > There's a lot of work to be done to make this work generally (not to > mention figuring out how to handle mapcount for such folios ;-). Yes :) -- Cheers, David / dhildenb