From mboxrd@z Thu Jan 1 00:00:00 1970 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 7F22AC433FE for ; Wed, 16 Feb 2022 08:31:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 16A476B0080; Wed, 16 Feb 2022 03:31:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F4EE6B0081; Wed, 16 Feb 2022 03:31:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EAF1A6B0082; Wed, 16 Feb 2022 03:31:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id D89E46B0080 for ; Wed, 16 Feb 2022 03:31:08 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B0AD62061F for ; Wed, 16 Feb 2022 08:31:08 +0000 (UTC) X-FDA: 79147973016.02.CC9FB2F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 15972160004 for ; Wed, 16 Feb 2022 08:31:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645000267; 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=dMr7qMjbySmB3FKzyMaIvMtNvTUPHIVGxBY8lAVP/YQ=; b=Css8yhuH6bPauD/GhKsMyoxVUh41GM4/Y8tVvtOFz+I+u0YYoP60x5eo1u5ww4ivRD215p qEHbB0OX7bf8OG5AiF8k2HzPITogxfAoyXFSGw+WRXy+RdSuB8PUkg+d9BVtdrHYhTgHdC 4PycnhRUGkvGnpPgnp5kFJqd/v6QjOw= 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.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-249-5iTjpgT2NHuQdDKvhbcJsw-1; Wed, 16 Feb 2022 03:31:06 -0500 X-MC-Unique: 5iTjpgT2NHuQdDKvhbcJsw-1 Received: by mail-wm1-f72.google.com with SMTP id m3-20020a7bcb83000000b0034f75d92f27so215121wmi.2 for ; Wed, 16 Feb 2022 00:31:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=dMr7qMjbySmB3FKzyMaIvMtNvTUPHIVGxBY8lAVP/YQ=; b=ahsjN0E4SocFOl8i/YA8rQ7S6V4krRUApYrWd+Gz337Vs/ngjL9RXttlNcZ+b+egzm tTTEjr/Tk2XKx26oOUWYm99bhOXpl4JYJoNy10UxBfgPQ+WPCA5lne0EygOylRZ79J6H DjEZE+UV3J7bLI8UwBLyaaHeSnyAEGCLXOjFi8T1P+NxWJw7kryktWkndOvp38F7i8E5 lBunf36qKTT65O0IAoVTi9Ir11q1yKa8OlbMiJEoFsPOCL2FcNJ7sJm/ManPNEjdr/1K ikMp5Qi0n31hMCsiXeA7EEG4vV20P0La9GTKTFkezX5MGqLuUCKcZWUJvsqhdnmVqfzp v62g== X-Gm-Message-State: AOAM531F2RhsHM2qMk+wlEe+ahGHetTIjKqEpnN4NsUenG2bBoQoZVsa eaiHDlUF7ndtPwlmaBUVdMb7U47DDArCXJ20qeATn4qu2mUQM9U6+YGgSXnsQqlZW+WbQbaSQFY RQViJ7E56bkM= X-Received: by 2002:a5d:6a03:0:b0:1e4:4055:7e35 with SMTP id m3-20020a5d6a03000000b001e440557e35mr1391876wru.495.1645000264840; Wed, 16 Feb 2022 00:31:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJzw1zMgqtvBG1B1Fs/z6twGtOuFvl241Tm8Z6QUAB1L998Nv+s1BS79V+EKfFEFJWSxdpuYnw== X-Received: by 2002:a5d:6a03:0:b0:1e4:4055:7e35 with SMTP id m3-20020a5d6a03000000b001e440557e35mr1391848wru.495.1645000264537; Wed, 16 Feb 2022 00:31:04 -0800 (PST) Received: from ?IPV6:2003:cb:c70b:600:4ff7:25c:5aad:2711? (p200300cbc70b06004ff7025c5aad2711.dip0.t-ipconnect.de. [2003:cb:c70b:600:4ff7:25c:5aad:2711]) by smtp.gmail.com with ESMTPSA id y17sm17260030wma.5.2022.02.16.00.31.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Feb 2022 00:31:04 -0800 (PST) Message-ID: <98d8bbc5-ffc2-8966-fdc1-a844874e7ae8@redhat.com> Date: Wed, 16 Feb 2022 09:31:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 To: Alistair Popple , Jason Gunthorpe Cc: Felix Kuehling , Christoph Hellwig , Alex Sierra , akpm@linux-foundation.org, linux-mm@kvack.org, rcampbell@nvidia.com, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, jglisse@redhat.com, willy@infradead.org References: <877d9vd10u.fsf@nvdebian.thelocal> <20220216020357.GD4160@nvidia.com> <6156515.kVgMqSaHHm@nvdebian> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v6 01/10] mm: add zone device coherent type memory support In-Reply-To: <6156515.kVgMqSaHHm@nvdebian> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Css8yhuH; spf=none (imf08.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam07 X-Rspam-User: X-Rspamd-Queue-Id: 15972160004 X-Stat-Signature: auoyd9wfojoqukb3bbfjhmtjobpg8kbn X-HE-Tag: 1645000267-604881 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 16.02.22 03:36, Alistair Popple wrote: > On Wednesday, 16 February 2022 1:03:57 PM AEDT Jason Gunthorpe wrote: >> On Wed, Feb 16, 2022 at 12:23:44PM +1100, Alistair Popple wrote: >> >>> Device private and device coherent pages are not marked with pte_devmap and they >>> are backed by a struct page. The only way of inserting them is via migrate_vma. >>> The refcount is decremented in zap_pte_range() on munmap() with special handling >>> for device private pages. Looking at it again though I wonder if there is any >>> special treatment required in zap_pte_range() for device coherent pages given >>> they count as present pages. >> >> This is what I guessed, but we shouldn't be able to just drop >> pte_devmap on these pages without any other work?? Granted it does >> very little already.. > > Yes, I agree we need to check this more closely. For device private pages > not having pte_devmap is fine, because they are non-present swap entries so > they always get special handling in the swap entry paths but the same isn't > true for coherent device pages. I'm curious, how does the refcount of a PageAnon() DEVICE_COHERENT page look like when mapped? I'd assume it's also (currently) still offset by one, meaning, if it's mapped into a single page table it's always at least 2. Just a note that if my assumption is correct and if we'd have such a page mapped R/O, do_wp_page() would always have to copy it unconditionally and would not be able to reuse it on write faults. (while I'm working on improving the reuse logic, I think there is also work in progress to avoid this additional reference on some ZONE_DEVICE stuff -- I'd assume that would include DEVICE_COHERENT ?) > >> I thought at least gup_fast needed to be touched or did this get >> handled by scanning the page list after the fact? > > Right, for gup I think the only special handling required is to prevent > pinning. I had assumed that check_and_migrate_movable_pages() would still get > called for gup_fast but unless I've missed something I don't think it does. > That means gup_fast could still pin movable and coherent pages. Technically > that is ok for coherent pages, but it's undesirable. We really should have the same pinning rules for GUP vs. GUP-fast. is_pinnable_page() should be the right place for such checks (similarly as indicated in my reply to the migration series). -- Thanks, David / dhildenb