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=-8.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable 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 C4A5EC433E3 for ; Mon, 20 Jul 2020 20:49:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8708622BEF for ; Mon, 20 Jul 2020 20:49:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="VcLaCG1j" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8708622BEF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0FE8D6B0003; Mon, 20 Jul 2020 16:49:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0AEEC6B000A; Mon, 20 Jul 2020 16:49:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB9C78D0002; Mon, 20 Jul 2020 16:49:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0250.hostedemail.com [216.40.44.250]) by kanga.kvack.org (Postfix) with ESMTP id D2F2E6B0003 for ; Mon, 20 Jul 2020 16:49:12 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8CD18180ACC20 for ; Mon, 20 Jul 2020 20:49:12 +0000 (UTC) X-FDA: 77059644144.03.fog74_101027426f27 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 5037719986 for ; Mon, 20 Jul 2020 20:49:12 +0000 (UTC) X-HE-Tag: fog74_101027426f27 X-Filterd-Recvd-Size: 5114 Received: from hqnvemgate26.nvidia.com (hqnvemgate26.nvidia.com [216.228.121.65]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Mon, 20 Jul 2020 20:49:11 +0000 (UTC) Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 20 Jul 2020 13:48:58 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Mon, 20 Jul 2020 13:49:10 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Mon, 20 Jul 2020 13:49:10 -0700 Received: from rcampbell-dev.nvidia.com (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 20 Jul 2020 20:49:10 +0000 Subject: Re: [PATCH v2 2/5] mm/migrate: add a direction parameter to migrate_vma To: Jason Gunthorpe CC: , , , , , , "Jerome Glisse" , John Hubbard , "Christoph Hellwig" , Andrew Morton , Shuah Khan , Ben Skeggs , Bharata B Rao References: <20200713172149.2310-1-rcampbell@nvidia.com> <20200713172149.2310-3-rcampbell@nvidia.com> <20200720183643.GA3028737@nvidia.com> <2e775a5d-9d62-de52-6799-3bbb09c88c5a@nvidia.com> <20200720195943.GH2021234@nvidia.com> From: Ralph Campbell X-Nvconfidentiality: public Message-ID: Date: Mon, 20 Jul 2020 13:49:09 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20200720195943.GH2021234@nvidia.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1595278138; bh=Ccj/+mKAxu8hTLWfU4Ue43iWGdFGZ2AWQABgAkqwS5c=; h=X-PGP-Universal:Subject:To:CC:References:From:X-Nvconfidentiality: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=VcLaCG1jeJ3grIAQ6dNREngT9LTn9RlNSSs2PV9xB2FKhVBQ9sSCMPElcq6X8bk+g BffYfWyypukyPqCEivuSYDvDbuieMzbmOD4tLYnkHSGC+/8Eo7xnq/qABwzVunk2E6 uuRVRSaBj5I2QN265J3jgZcvbPEcUO9iGyrjO1Dmiosny1t4HQJP2yT8VtJhLO0nNd d2SZ6bBN3ywT4vnkEiIQBekg3S0vniVavcHfZrE0YcmAZXB+VncPBE1u5hMqQT3tC2 V47tjJs5XwPa9/MN0I8bxqzoDxEte6LZmbM+QXwVdqRgI+PVl2LkjNrZZ7TGxvNp+b GRhbS0bjKKnhw== X-Rspamd-Queue-Id: 5037719986 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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 7/20/20 12:59 PM, Jason Gunthorpe wrote: > On Mon, Jul 20, 2020 at 12:54:53PM -0700, Ralph Campbell wrote: >>>> diff --git a/include/linux/migrate.h b/include/linux/migrate.h >>>> index 3e546cbf03dd..620f2235d7d4 100644 >>>> +++ b/include/linux/migrate.h >>>> @@ -180,6 +180,11 @@ static inline unsigned long migrate_pfn(unsigned long pfn) >>>> return (pfn << MIGRATE_PFN_SHIFT) | MIGRATE_PFN_VALID; >>>> } >>>> +enum migrate_vma_direction { >>>> + MIGRATE_VMA_FROM_SYSTEM, >>>> + MIGRATE_VMA_FROM_DEVICE_PRIVATE, >>>> +}; >>> >>> I would have guessed this is more natural as _FROM_DEVICE_ and >>> TO_DEVICE_ ? >> >> The caller controls where the destination memory is allocated so it isn't >> necessarily device private memory, it could be from system to system. >> The use case for system to system memory migration is for hardware >> like ARM SMMU or PCIe ATS where a single set of page tables is shared by >> the device and a CPU process over a coherent system memory bus. >> Also many integrated GPUs in SOCs fall into this category too. > > Maybe just TO/FROM_DEIVCE then? Even though the memory is not > DEVICE_PRIVATE it is still device owned pages right? > >> So to me, it makes more sense to specify the direction based on the >> source location. > > It feels strange because the driver doesn't always know or control the > source? > > Jason > The driver can't really know where the source is currently located because the API is designed to not initially hold the page locks, migrate_vma_setup() only knows the source once it holds the page table locks and isolates/locks the pages being migrated. The direction and pgmap_owner are supposed to filter which pages the caller is interested in migrating. Perhaps the direction should instead be a flags field with separate bits for system memory and device private memory selecting source candidates for migration. I can imagine use cases for all 4 combinations of d->d, d->s, s->d, and s->s being valid. I didn't really think a direction was needed, this was something that Christoph Hellwig seemed to think made the API safer.