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 328D9C433EF for ; Wed, 29 Jun 2022 09:59:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 890756B0073; Wed, 29 Jun 2022 05:59:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 83E3E8E0002; Wed, 29 Jun 2022 05:59:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7070F8E0001; Wed, 29 Jun 2022 05:59:32 -0400 (EDT) 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 61EF66B0073 for ; Wed, 29 Jun 2022 05:59:32 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3AE4434041 for ; Wed, 29 Jun 2022 09:59:32 +0000 (UTC) X-FDA: 79630826184.11.05274F4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id C2A3280038 for ; Wed, 29 Jun 2022 09:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656496771; 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=UzceN8npiU1PHAzECBm7qOnZjHThBc7uhuHl4hlHZrs=; b=FGs720HSx2NWn92vuRUFvh+ugHAkzqJoRBoB6oISnoyiCXqLV2eL0bUAfc7zM82FG5+Cp4 l5cxzuJZVLF0Pgqs7dCL7PBFIztOPDfgLgrlNehtNL3aKvmft4hQRa0GG7QEQjPWUGme3T iu3WUWymM7uOEmJMGva69jOSGNJIgLM= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-269-bu3_ggq4Pk6TcBCCXc1Kgw-1; Wed, 29 Jun 2022 05:59:29 -0400 X-MC-Unique: bu3_ggq4Pk6TcBCCXc1Kgw-1 Received: by mail-wr1-f69.google.com with SMTP id s7-20020adfbc07000000b0021a558c09b4so2241111wrg.4 for ; Wed, 29 Jun 2022 02:59:29 -0700 (PDT) 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=UzceN8npiU1PHAzECBm7qOnZjHThBc7uhuHl4hlHZrs=; b=pLAUnxIchDgd2TrJ8cJrGKIO2NLBrsK7lLc9PWTh3K91SL+1ru0To40JSN1s0JcErS VDAIsKfcJe2ENhaZUElXT/eMv9do+2m4sSS/kxTji9BS0Vl0q9hOaxk5zESKT8nCAOX3 woA2LDHyxib9vMILZebiGUsxh238x1Nnd1p/hnUKT8GIj8hPstDJtnQ1g4wOWr5VpEnR gZ/XA3hgjZedWYaLe/R+axhQcuy4M+vi57YAD/V5DmaMl5OnRnfhXVvfFXhAZ+unqype Bd+oAfII44AwGqFiPw+zni7ZGiamslfLSUa7ZuiAX+sAcDrRZK1runctSxIvC0U9LE+T va+w== X-Gm-Message-State: AJIora8K4Wqd3WuCAJ5/m7+VcMFOqRt+ATa5TX1C+IioNMH9GggPeazM X+Q8CRpaeqQ0B4fdiosOuByW2nF84+gyLoWd946js0tNuUueUKH2xqxFicmMEtJqDFkgpo3FnHL +7zxetfPRLMI= X-Received: by 2002:a7b:c5d0:0:b0:3a0:3dc8:73a1 with SMTP id n16-20020a7bc5d0000000b003a03dc873a1mr2664077wmk.98.1656496768515; Wed, 29 Jun 2022 02:59:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uzk/B6PTZXrzHxht/mKCZa7GoCf9iThGNKGutixbwHJDxt/oLs1rYeiHv7jfh4fv2kOpV6+w== X-Received: by 2002:a7b:c5d0:0:b0:3a0:3dc8:73a1 with SMTP id n16-20020a7bc5d0000000b003a03dc873a1mr2664041wmk.98.1656496768236; Wed, 29 Jun 2022 02:59:28 -0700 (PDT) Received: from ?IPV6:2003:cb:c708:e600:d4fa:af4b:d7b6:20df? (p200300cbc708e600d4faaf4bd7b620df.dip0.t-ipconnect.de. [2003:cb:c708:e600:d4fa:af4b:d7b6:20df]) by smtp.gmail.com with ESMTPSA id y6-20020a05600c20c600b003a0426fae52sm2555196wmm.24.2022.06.29.02.59.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jun 2022 02:59:27 -0700 (PDT) Message-ID: <269e4c6e-d6ee-bace-9fab-a9dcb4268d5a@redhat.com> Date: Wed, 29 Jun 2022 11:59:26 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 To: Alex Sierra , jgg@nvidia.com Cc: Felix.Kuehling@amd.com, 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, hch@lst.de, jglisse@redhat.com, apopple@nvidia.com, willy@infradead.org, akpm@linux-foundation.org References: <20220629035426.20013-1-alex.sierra@amd.com> <20220629035426.20013-4-alex.sierra@amd.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v7 03/14] mm: handling Non-LRU pages returned by vm_normal_pages In-Reply-To: <20220629035426.20013-4-alex.sierra@amd.com> 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656496771; a=rsa-sha256; cv=none; b=AG6THG/5pqE+kWY6/npo6BevtLD/OOEXq5/pcdwsQxC8ii9t2H+H6V03vYBptIGb4KQWvC TTzy2ZLGj5Qn87VmFGA0gLo2n07q7xr/ZP9L1TbuI+h464nhzpbAiGimrDywBzuOnRBFbZ 6rPEJMnmGHZGjVWKRcg58U4E93/d/HY= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FGs720HS; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf30.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656496771; 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=UzceN8npiU1PHAzECBm7qOnZjHThBc7uhuHl4hlHZrs=; b=0NjHlgu3XBDrd6qBBN1K8ywDQaaAra2ZrUqEvTLPnGgDBZuHuWs3PDlmCdmET5lcs2ILgj 5YIVSP++3ToNXDBYmPVknKmTU23ITlkIF0bWNsuBZEHjcMgDYdWUG6A6ls36erS4AGGXHz D5tKARs+LzEqr0kg7E/eLObkZ9HPJR8= X-Stat-Signature: ajrw3quaawbbjmqn33zfpq78xfhtim5z X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C2A3280038 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FGs720HS; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf30.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com X-HE-Tag: 1656496771-230657 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 29.06.22 05:54, Alex Sierra wrote: > With DEVICE_COHERENT, we'll soon have vm_normal_pages() return > device-managed anonymous pages that are not LRU pages. Although they > behave like normal pages for purposes of mapping in CPU page, and for > COW. They do not support LRU lists, NUMA migration or THP. > > Callers to follow_page that expect LRU pages, are also checked for > device zone pages due to DEVICE_COHERENT type. Can we rephrase that to (because zeropage) "Callers to follow_page() currently don't expect ZONE_DEVICE pages, however, with DEVICE_COHERENT we might now return ZONE_DEVICE. Check for ZONE_DEVICE pages in applicable users of follow_page() as well." [...] > /* > diff --git a/mm/memory.c b/mm/memory.c > index 7a089145cad4..e18555af9024 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -624,6 +624,13 @@ struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr, > if (is_zero_pfn(pfn)) > return NULL; > if (pte_devmap(pte)) > +/* > + * NOTE: New uers of ZONE_DEVICE will not set pte_devmap() and will have s/uers/users/ > + * refcounts incremented on their struct pages when they are inserted into > + * PTEs, thus they are safe to return here. Legacy ZONE_DEVICE pages that set > + * pte_devmap() do not have refcounts. Example of legacy ZONE_DEVICE is > + * MEMORY_DEVICE_FS_DAX type in pmem or virtio_fs drivers. > + */ [...] > diff --git a/mm/mprotect.c b/mm/mprotect.c > index ba5592655ee3..e034aae2a98b 100644 > --- a/mm/mprotect.c > +++ b/mm/mprotect.c > @@ -95,7 +95,7 @@ static unsigned long change_pte_range(struct mmu_gather *tlb, > continue; > > page = vm_normal_page(vma, addr, oldpte); > - if (!page || PageKsm(page)) > + if (!page || is_zone_device_page(page) || PageKsm(page)) > continue; > > /* Also skip shared copy-on-write pages */ In -next/-mm there is now an additional can_change_pte_writable() that calls vm_normal_page() -- added by me. I assume that that is indeed fine because we can simply map device coherent pages writable. Besides the nits, LGTM Acked-by: David Hildenbrand -- Thanks, David / dhildenb