Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1165055imm; Mon, 21 May 2018 22:55:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZogU8F+Dsv8g42cTXRUboMnGOqh/b+akxUzZ8rcZrmgAUeOxtbLZK47Jr79U/bWN+8Y68Ba X-Received: by 2002:a17:902:321:: with SMTP id 30-v6mr23238168pld.122.1526968558825; Mon, 21 May 2018 22:55:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526968558; cv=none; d=google.com; s=arc-20160816; b=it8Wdt+HOyvcSxkRkg6MacqrEwFoLoJNP91TEYUIrfYxbIBbmBzKXyX3R4VylAczI4 Qdw5UPBCAXfRg3ExeE5800pBnLs32Y+piNFCMdeKGN9Vk41M+zt4skRkPi0zOZPIMcaA 88l75kjyQljX9wufjdSuS54H0s49ceMKpLW2yooG1XUlG+qOCJmxrWVB5nUogZlhv1ML MAQt7Ivl0m1GtuCDFmkPywnXAY9LuzCDRvp1R4zUOEa3lRdQ8TPB6+nWqznJVaqytKeE YFDqgPcnxKuuZl0dtpILLMY+nJEFA2azYQdWlWdiWP72hVXwyCc1GieL1wXv5HEWV0A7 DtIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=PZjr8VGIRjb7zRNHpXfZRq2Cz4/Ztj3SW/tTIlXAvv8=; b=Brvr+HSkx3ZDx81xoSp70ZFXHHLsq/gTWAOjUYqlL+3KArxhTeixqcC2T8GfeuZUWE 43E6VqAsKUos4WlbejTD4DE/BmVHqi+6A06yIiTHp+S9jCyzAAB+gGtGYPsHvWJN1Syd +J0C9kgt7XLE68JxKvXmfYpwilQ5zJKn7UbCAAixhZv83aemXmpPfrbYSQqhOkAST3If jdPillaLwXzod3kte9PCjWh0AGXEQ2/5WHFWVpxkGilqx60GDgaT4+vLJG1MvnY0rF8v RiZVdHRPUPil0sAsIPes4SOBDsIQLsi4Vt6C+3DUK3+Dhk6tWbYN1mKIlAxCi2bXNKKZ Jf/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=agOj7fhJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id be3-v6si15004775plb.474.2018.05.21.22.55.43; Mon, 21 May 2018 22:55:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=agOj7fhJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751324AbeEVFzd (ORCPT + 99 others); Tue, 22 May 2018 01:55:33 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:36894 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751002AbeEVFza (ORCPT ); Tue, 22 May 2018 01:55:30 -0400 Received: by mail-lf0-f66.google.com with SMTP id r2-v6so27304757lff.4; Mon, 21 May 2018 22:55:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=PZjr8VGIRjb7zRNHpXfZRq2Cz4/Ztj3SW/tTIlXAvv8=; b=agOj7fhJFqR0S13lexxpRX7TYtUPKQsftOy9il5K7ZMSYTH53KIC+VgrP/h+Cxtg1o 0d5VaCy4P/36HxG0lr4fPAL0qVUFb523w61rRFkyx/Hp51j1IAI0laTe/29KUSf8+ANo IcWYB8YaFwVNpAxp7YrvcVbDfli7bzGPgNfsgkHJcBJXxWR0TDiSA2bqE4KeDfecynFB IJONVEmD9jtageU9g4T/ANldLZ0CbcjkZR3gdOR343VTGnAJSwYd8Kul6fZ6VtdvcA7E q67bFovRPg8Ta/w29QPah8nBBGNDcN/zlHfYkOCn5I22I+sq9i7CynARlQj34OPChrXj +s8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=PZjr8VGIRjb7zRNHpXfZRq2Cz4/Ztj3SW/tTIlXAvv8=; b=Qe78yshAwYK7n2rEWU2w+Z0YtQfLreSOvBU9C/4Cy+vTMZpv0pu5NFiXif0+LqesgN Q1OT+GFIE9MwFNi+Jmv6XnzziZbcW+gS5gi6m5z3luk4beXyrfFmopfPfAkEz9CprZqr +v+3U37JWYqsyvdlnwe8TY3V1qWYuxA1qP19Ro0kj9jU8ieIpRWMoyIm/jnlRhX9SpB5 px6E+n2g6k77BR33MODKkopve1KZY58FM06NJHLLZ/wHVCboenNsef5oyDyEe0pQ+rpB zvlA5bwHq702LlKzHmkP/wX2MYlypWK/qjvVIEQkrxYHZSH8KSd1WJNgupxZARLRCmoq DPLw== X-Gm-Message-State: ALKqPwftjaLlqMrsYRylRjpbMCgbKyJ5wijdg13Gf5+neOSvT9piADLC fy1Hq9CGQob4oNXv7C4VzG0= X-Received: by 2002:a2e:330c:: with SMTP id d12-v6mr14462083ljc.8.1526968528685; Mon, 21 May 2018 22:55:28 -0700 (PDT) Received: from [10.17.182.9] (ll-52.209.223.85.sovam.net.ua. [85.223.209.52]) by smtp.gmail.com with ESMTPSA id p17-v6sm2783130ljc.72.2018.05.21.22.55.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 May 2018 22:55:27 -0700 (PDT) Subject: Re: [Xen-devel] [RFC 1/3] xen/balloon: Allow allocating DMA buffers To: Boris Ostrovsky , Oleksandr Andrushchenko , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, jgross@suse.com, konrad.wilk@oracle.com Cc: daniel.vetter@intel.com, matthew.d.roper@intel.com, dongwon.kim@intel.com References: <20180517082604.14828-1-andr2000@gmail.com> <20180517082604.14828-2-andr2000@gmail.com> <6a108876-19b7-49d0-3de2-9e10f984736c@oracle.com> <9541926e-001a-e41e-317c-dbff6d687761@gmail.com> <218e2bf7-490d-f89e-9866-27b7e3dbc835@oracle.com> From: Oleksandr Andrushchenko Message-ID: <77c20852-b9b8-c35a-26b0-b0317e6aba09@gmail.com> Date: Tue, 22 May 2018 08:55:26 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/21/2018 11:36 PM, Boris Ostrovsky wrote: > On 05/21/2018 03:13 PM, Oleksandr Andrushchenko wrote: >> On 05/21/2018 09:53 PM, Boris Ostrovsky wrote: >>> On 05/21/2018 01:32 PM, Oleksandr Andrushchenko wrote: >>>> On 05/21/2018 07:35 PM, Boris Ostrovsky wrote: >>>>> On 05/21/2018 01:40 AM, Oleksandr Andrushchenko wrote: >>>>>> On 05/19/2018 01:04 AM, Boris Ostrovsky wrote: >>>>>>> On 05/17/2018 04:26 AM, Oleksandr Andrushchenko wrote: >>>>>>>> From: Oleksandr Andrushchenko >>>>>>> A commit message would be useful. >>>>>> Sure, v1 will have it >>>>>>>> Signed-off-by: Oleksandr Andrushchenko >>>>>>>> >>>>>>>> >>>>>>>>         for (i = 0; i < nr_pages; i++) { >>>>>>>> -        page = alloc_page(gfp); >>>>>>>> -        if (page == NULL) { >>>>>>>> -            nr_pages = i; >>>>>>>> -            state = BP_EAGAIN; >>>>>>>> -            break; >>>>>>>> +        if (ext_pages) { >>>>>>>> +            page = ext_pages[i]; >>>>>>>> +        } else { >>>>>>>> +            page = alloc_page(gfp); >>>>>>>> +            if (page == NULL) { >>>>>>>> +                nr_pages = i; >>>>>>>> +                state = BP_EAGAIN; >>>>>>>> +                break; >>>>>>>> +            } >>>>>>>>             } >>>>>>>>             scrub_page(page); >>>>>>>>             list_add(&page->lru, &pages); >>>>>>>> @@ -529,7 +565,7 @@ static enum bp_state >>>>>>>> decrease_reservation(unsigned long nr_pages, gfp_t gfp) >>>>>>>>         i = 0; >>>>>>>>         list_for_each_entry_safe(page, tmp, &pages, lru) { >>>>>>>>             /* XENMEM_decrease_reservation requires a GFN */ >>>>>>>> -        frame_list[i++] = xen_page_to_gfn(page); >>>>>>>> +        frames[i++] = xen_page_to_gfn(page); >>>>>>>>       #ifdef CONFIG_XEN_HAVE_PVMMU >>>>>>>>             /* >>>>>>>> @@ -552,18 +588,22 @@ static enum bp_state >>>>>>>> decrease_reservation(unsigned long nr_pages, gfp_t gfp) >>>>>>>>     #endif >>>>>>>>             list_del(&page->lru); >>>>>>>>     -        balloon_append(page); >>>>>>>> +        if (!ext_pages) >>>>>>>> +            balloon_append(page); >>>>>>> So what you are proposing is not really ballooning. You are just >>>>>>> piggybacking on existing interfaces, aren't you? >>>>>> Sort of. Basically I need to {increase|decrease}_reservation, not >>>>>> actually >>>>>> allocating ballooned pages. >>>>>> Do you think I can simply EXPORT_SYMBOL for >>>>>> {increase|decrease}_reservation? >>>>>> Any other suggestion? >>>>> I am actually wondering how much of that code you end up reusing. You >>>>> pretty much create new code paths in both routines and common code >>>>> ends >>>>> up being essentially the hypercall. >>>> Well, I hoped that it would be easier to maintain if I modify existing >>>> code >>>> to support both use-cases, but I am also ok to create new routines if >>>> this >>>> seems to be reasonable - please let me know >>>>>    So the question is --- would it make >>>>> sense to do all of this separately from the balloon driver? >>>> This can be done, but which driver will host this code then? If we >>>> move from >>>> the balloon driver, then this could go to either gntdev or grant-table. >>>> What's your preference? >>> A separate module? >>> Is there any use for this feature outside of your zero-copy DRM driver? >> Intel's hyper dma-buf (Dongwon/Matt CC'ed), V4L/GPU at least. >> >> At the time I tried to upstream zcopy driver it was discussed and >> decided that >> it would be better if I remove all DRM specific code and move it to >> Xen drivers. >> Thus, this RFC. >> >> But it can also be implemented as a dedicated Xen dma-buf driver which >> will have all the >> code from this RFC + a bit more (char/misc device handling at least). >> This will also require a dedicated user-space library, just like >> libxengnttab.so >> for gntdev (now I have all new IOCTLs covered there). >> >> If the idea of a dedicated Xen dma-buf driver seems to be more >> attractive we >> can work toward this solution. BTW, I do support this idea, but was not >> sure if Xen community accepts yet another driver which duplicates >> quite some code >> of the existing gntdev/balloon/grant-table. And now after this RFC I >> hope that all cons >> and pros of both dedicated driver and gntdev/balloon/grant-table >> extension are >> clearly seen and we can make a decision. > > IIRC the objection for a separate module was in the context of gntdev > was discussion, because (among other things) people didn't want to have > yet another file in /dev/xen/ > > Here we are talking about (a new) balloon-like module which doesn't > create any new user-visible interfaces. And as for duplicating code --- > as I said, I am not convinced there is much of duplication. > > I might even argue that we should add a new config option for this module. I am not quite sure I am fully following you here: so, you suggest that we have balloon.c unchanged, but instead create a new module (namely a file under the same folder as balloon.c, e.g. dma-buf-reservation.c) and move those {increase|decrease}_reservation routines (specific to dma-buf) to that new file? And make it selectable via Kconfig? If so, then how about the changes to grant-table and gntdev? Those will look inconsistent then. If you suggest a new kernel driver module: IMO, there is nothing bad if we create a dedicated kernel module (driver) for Xen dma-buf handling selectable under Kconfig option. Yes, this will create a yet another device under /dev/xen, but most people will never see it if we set Kconfig to default to "n". And then we'll need user-space support for that, so Xen tools will be extended with libxendmabuf.so or so. This way all Xen dma-buf support can be localized at one place which might be easier to maintain. What is more it could be totally transparent to most of us as Kconfig option won't be set by default (both kernel and Xen). Thank you, Oleksandr > > -boris > >>> -boris >> Thank you, >> Oleksandr >> [1] >> https://lists.freedesktop.org/archives/dri-devel/2018-April/173163.html