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 X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DEA5C433E6 for ; Wed, 10 Feb 2021 12:56:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AB67364E3E for ; Wed, 10 Feb 2021 12:56:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB67364E3E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 066326B0006; Wed, 10 Feb 2021 07:56:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 014C96B006C; Wed, 10 Feb 2021 07:56:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF7286B006E; Wed, 10 Feb 2021 07:56:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C47976B0006 for ; Wed, 10 Feb 2021 07:56:37 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 91D99184F4E76 for ; Wed, 10 Feb 2021 12:56:37 +0000 (UTC) X-FDA: 77802357234.23.top30_3d117fc27610 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 7499437606 for ; Wed, 10 Feb 2021 12:56:37 +0000 (UTC) X-HE-Tag: top30_3d117fc27610 X-Filterd-Recvd-Size: 4901 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Wed, 10 Feb 2021 12:56:36 +0000 (UTC) Received: by mail-qk1-f171.google.com with SMTP id s77so1458939qke.4 for ; Wed, 10 Feb 2021 04:56:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=+MVRo4/XnQIx3fd6415VPGbeWHNWjyo8mTnVMpej2lA=; b=O53d2BI1j53KMGAaF6bzA0O5LOM9nvSszG+MG7vHXtJizZwpWW8S02aJyhNyL5wBFV mnrjSjqLO68+sywN8hY/2H8Q4H0Bqlujxc5cNSQ3c93vkFkfN8336ieQq2/Xd43DQ1aL YOcAyEETi1AONr9aaDF5ImQHc/MpJ6pnXwy8pTGJ8eFuLBgOfJUq8VwBgtsKOqasXKm6 QOHLwog1rbX7Xi6mNrkS5/AssX+IYssu6x3VuOj/+f9dYS/3wjog1YIcNRNZuUv+X/wz b7Y8peA5t7BBpa1BNm/UzOpgs5ZkK1km/gtTeRC+QLirflyIAA6lwp2R/L7+gQnGKoH5 pG7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=+MVRo4/XnQIx3fd6415VPGbeWHNWjyo8mTnVMpej2lA=; b=DnEzRANF4o8xGb+2AQoXAKg8VudWGbgHmkXjK9ZYaTY/bMDkXRkAGbSGP6xHUQvVNQ cz99HVBxvuijsS+BwsCbbW81wEUNCp3SyOsmlJW123HqZPDnn374x1Cg9pZvjUrs8V3n HzhCkSAVzLaE61O4+C1YJQKy5IX29Io5ihpt0uaTculDipwZcudI+6Lz+TIJBIGjGtQ9 2D4sNkCPeRtx/WsjiNIwQ9PTlEiqUobeneLD56dD0jJaIQQKSUIrRTgqug02zeQybR7k J2k1581RvPjo7rSkLu4FWp9TzDdVMnvsrf+d2cKTdmr3bB5yIcpMlIj2JHwZsxwgnl8T 9FIQ== X-Gm-Message-State: AOAM532iQVag1ll8NenrXgFg2GIfWqKuZS1AwcMVoBPzm6mPv0rc6uPi f+tZKKN+etRXNJd6ZZek3PBwrw== X-Google-Smtp-Source: ABdhPJxjqcsRFWifv9FC85VtsN1NtJhfvFQm3LwV9wq/GU8W4tcO6YLlagLlTq+fjHi5rG8zRu4Ivw== X-Received: by 2002:a37:a8d6:: with SMTP id r205mr3094578qke.489.1612961796341; Wed, 10 Feb 2021 04:56:36 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-115-133.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.115.133]) by smtp.gmail.com with ESMTPSA id y190sm1331727qkb.133.2021.02.10.04.56.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Feb 2021 04:56:35 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1l9p2o-005qZi-KG; Wed, 10 Feb 2021 08:56:34 -0400 Date: Wed, 10 Feb 2021 08:56:34 -0400 From: Jason Gunthorpe To: Alistair Popple Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org, bskeggs@redhat.com, akpm@linux-foundation.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kvm-ppc@vger.kernel.org, dri-devel@lists.freedesktop.org, jhubbard@nvidia.com, rcampbell@nvidia.com, jglisse@redhat.com Subject: Re: [PATCH 1/9] mm/migrate.c: Always allow device private pages to migrate Message-ID: <20210210125634.GL4718@ziepe.ca> References: <20210209010722.13839-1-apopple@nvidia.com> <20210209010722.13839-2-apopple@nvidia.com> <20210209133932.GD4718@ziepe.ca> <1780857.6Ip0F2Sa4d@nvdebian> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1780857.6Ip0F2Sa4d@nvdebian> X-Bogosity: Ham, tests=bogofilter, spamicity=0.061683, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Feb 10, 2021 at 02:40:10PM +1100, Alistair Popple wrote: > On Wednesday, 10 February 2021 12:39:32 AM AEDT Jason Gunthorpe wrote: > > On Tue, Feb 09, 2021 at 12:07:14PM +1100, Alistair Popple wrote: > > > Device private pages are used to represent device memory that is not > > > directly accessible from the CPU. Extra references to a device private > > > page are only used to ensure the struct page itself remains valid whilst > > > waiting for migration entries. Therefore extra references should not > > > prevent device private page migration as this can lead to failures to > > > migrate pages back to the CPU which are fatal to the user process. > > > > This should identify the extra references in expected_count, just > > disabling this protection seems unsafe, ZONE_DEVICE is not so special > > that the refcount means nothing > > This is similar to what migarte_vma_check_page() does now. The issue is that a > migration wait takes a reference on the device private page so you can end up > with one thread stuck waiting for migration whilst the other can't migrate due > to the extra refcount. > > Given device private pages can't undergo GUP and that it's not possible to > differentiate the migration wait refcount from any other refcount we assume > any possible extra reference must be from migration wait. GUP is not the only thing that elevates the refcount, I think this is an unsafe assumption Why is migration holding an extra refcount anyhow? Jason