Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp846507rwd; Thu, 15 Jun 2023 02:57:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4lNhBVEU70aoZM9knWww9uB5bAPx1gDAzPJFn+fpS4Nz0hVIxM6XhO3sMzLUMatxo8MvN3 X-Received: by 2002:a05:6a00:1a93:b0:666:7866:ecb9 with SMTP id e19-20020a056a001a9300b006667866ecb9mr3373014pfv.14.1686823055976; Thu, 15 Jun 2023 02:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686823055; cv=none; d=google.com; s=arc-20160816; b=ukDoYI698BxghGKwUUu12oNBo3xZXPY4QQyQLMdNWHhIV6K2fLbwMbhoQO19EUSYVG Wt5nLrdG4rLoOKoGywVbkRuehhX2St9HBooVwzEIE84d3FXY2nViMY4IgZeQbOnVb1u9 LX6UWDE8ap6LgLuGEkTpHao+dAgtSV56radWAfl7eESltNJV8qaK+do8AbV2J8AL/Ml2 PI+uf4haak8qY2NL6blXZE7s8ItlGfRR44Ypq7j9lrex2bfs6XUzcBuPdXo1nSoLvOTZ 6EinOXwfUJ3g9I5UpDhLB5o4wbxdyBGrikzIoEPKbAt4ypw9Ps1R7HE25nH7RlDVdW1E eogA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :organization:from:references:cc:to:content-language:user-agent :mime-version:date:message-id:dkim-signature; bh=tFas5ce2A1vgl/Pd1KLK4gSYDaGRoYeIBhP4kavIodY=; b=Z8PAeQtK0QwM16SQ2WTbR2+BnbYfhh1Myy3V9TsiMrwXkkncxU/JkmgmvFbamj+Jz3 uaRHFXRCD1jInARj0Q702wTvsESIg/RN4QCL5jlf2qYdW6zdEJnlEPgxIv7u2q9pY6Oe KPM7Q0U6t2n8E4kg/vI+O1HUvCUClrtH9tx2UD+2LqzS1JppmX8rk80jdJu4LavS/a8Y 72UL8hc3V3KzOduhxNxb/QdHTF7khvma4ItPvdeXnlUM3kakKChrm9rFqFXxJA7BELeP FVz+ExKahwKmS3EN+wN1g0/cZehRHz5rBGoBgHPk4qfqLetOG+99K2gvtB2Rzefgqy47 Qm7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Rkva/9+c"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w77-20020a627b50000000b00625559a78a2si3349852pfc.107.2023.06.15.02.57.24; Thu, 15 Jun 2023 02:57:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Rkva/9+c"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245599AbjFOJtd (ORCPT + 99 others); Thu, 15 Jun 2023 05:49:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241788AbjFOJt2 (ORCPT ); Thu, 15 Jun 2023 05:49:28 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A5C11BF9 for ; Thu, 15 Jun 2023 02:48:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686822520; 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=tFas5ce2A1vgl/Pd1KLK4gSYDaGRoYeIBhP4kavIodY=; b=Rkva/9+cC8pNRv5Jh/EQ/fOlV15WLFgoiRfFrXsHvBX9gNFfG5nMHPar2DksxMtWek1nqL 5TXeAdxLvnO24Klk8Zfi3Mwx6rMRbRh5yBVA5lmI95bPpeBy8R2AwbsxGTAQQ/jzOnvKFI IXvmI5XgUeEAJa749YxWhwqo0BQg0H4= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-623-wszj9QZnOo2Z6r8R1OzqIQ-1; Thu, 15 Jun 2023 05:48:38 -0400 X-MC-Unique: wszj9QZnOo2Z6r8R1OzqIQ-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-4f62cf0bb78so6548587e87.1 for ; Thu, 15 Jun 2023 02:48:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686822517; x=1689414517; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tFas5ce2A1vgl/Pd1KLK4gSYDaGRoYeIBhP4kavIodY=; b=NNk12YyFmY/d4ZHHlSwKQx3QmoGLvmf4qiHJIyDjcLmVDlM6mjr+J0m7AZUkqJL5S4 oL/6a0vJCbU+MB0ev15G4mVl5Ke00kGceEDUfghXkqzDN8zhGK/7Ipom9T9QUxZpTB5S YxXHgm/o/Qz/g0d7z4ZdEOitEntlpawv/73Tzl7n5R4hl8L1nnOa88XKWrPQgJjTDprt 118Y/p8Bg6DmYuVKBeSq+W5SvVvWxluInX9Zu3606xYPxZVPDLngEEHeQM4zSvvGxIXi A/wbAHU56GqWViQk8xswle8B5y0vv0434P8FWfX+NMzslOiEXM59OUxGQIzqM+u8BdMs chJQ== X-Gm-Message-State: AC+VfDzD8FISUehCb/NZPDYZs806IwfZL/ECBg7Qf4p53Jl2Gd83sHov lNvjZ2BD+JDf3Iy/UKJ5lN+O3PWcZvmlUBkCrxU3nmCdNM/3aNI/Fnrfb1rPjO5kw/NHrak6Rx7 5PmFyOwxhRdwTvPpuPpAAA63D X-Received: by 2002:a19:f205:0:b0:4dd:ce0b:7692 with SMTP id q5-20020a19f205000000b004ddce0b7692mr9513525lfh.46.1686822517133; Thu, 15 Jun 2023 02:48:37 -0700 (PDT) X-Received: by 2002:a19:f205:0:b0:4dd:ce0b:7692 with SMTP id q5-20020a19f205000000b004ddce0b7692mr9513496lfh.46.1686822516710; Thu, 15 Jun 2023 02:48:36 -0700 (PDT) Received: from ?IPV6:2a09:80c0:192:0:5dac:bf3d:c41:c3e7? ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with ESMTPSA id z15-20020a7bc7cf000000b003f6129d2e30sm20115269wmk.1.2023.06.15.02.48.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Jun 2023 02:48:36 -0700 (PDT) Message-ID: <015062b6-2d4a-7b91-8f64-1695f526f794@redhat.com> Date: Thu, 15 Jun 2023 11:48:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Content-Language: en-US To: "Kasireddy, Vivek" , Mike Kravetz , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "dri-devel@lists.freedesktop.org" , "qemu-devel@nongnu.org" , Hugh Dickins Cc: "Hocko, Michal" , "jmarchan@redhat.com" , "Kim, Dongwon" , "Chang, Junxiao" , "muchun.song@linux.dev" , "stable@vger.kernel.org" , James Houghton , Gerd Hoffmann , Greg Kroah-Hartman , Andrew Morton , "kirill.shutemov@linux.intel.com" References: <20230608204927.88711-1-mike.kravetz@oracle.com> <281caf4f-25da-3a73-554b-4fb252963035@redhat.com> <676ee47d-8ca0-94c4-7454-46e9915ea36a@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH] udmabuf: revert 'Add support for mapping hugepages (v4)' In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> Skimming over at shmem_read_mapping_page() users, I assume most of >> them >> use a VM_PFNMAP mapping (or don't mmap them at all), where we won't be >> messing with the struct page at all. >> >> (That might even allow you to mmap hugetlb sub-pages, because the struct >> page -- and mapcount -- will be ignored completely and not touched.) > Oh, are you suggesting that if we do vma->vm_flags |= VM_PFNMAP > in the mmap handler (mmap_udmabuf) and also do > vmf_insert_pfn(vma, vmf->address, page_to_pfn(page)) > instead of > vmf->page = ubuf->pages[pgoff]; > get_page(vmf->page); > > in the vma fault handler (udmabuf_vm_fault), we can avoid most of the > pitfalls you have identified -- including with the usage of hugetlb subpages? Yes, that's my thinking, but I have to do my homework first to see if that would really work for hugetlb. The thing is, I kind-of consider what udmabuf does a layer violation: we have a filesystem (shmem/hugetlb) that should handle mappings to user space. Yet, a driver decides to bypass that and simply map the pages ordinarily to user space. (revealed by the fact that hugetlb does never map sub-pages but udmabuf decides to do so) In an ideal world everybody would simply mmap() the original memfd, but thinking about offset+size configuration within the memfd that might not always be desirable. As a workaround, we could mmap() only the PFNs, leaving the struct page unaffected. I'll have to look closer into that. -- Cheers, David / dhildenb