Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp689355yba; Thu, 16 May 2019 07:27:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqyeeO3fwSMPEOJF4uMmtC4jL7HjnSikwcGW+jsRB5jZsPsiSSOC1JMtn6a2qOMU7Rl4q9yL X-Received: by 2002:a63:d343:: with SMTP id u3mr50949593pgi.285.1558016821241; Thu, 16 May 2019 07:27:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558016821; cv=none; d=google.com; s=arc-20160816; b=uvV2DhASwbkhgLHKCpsDYPXJbw35O4vPAANtV9+RKr4TF2/F6qMoLbvuDXC7m6h5GN Gi4xuUqAD2o945l72U7HNGQ+lVogYkD8K2uzQm7QpjptMrz9HrplwVEa50FGOYcljHce mrGPHaDur/95J5p6RrNfDAj8GNBIUkmzmsM00Uvw91WUDxVNd60VEkpgNtIzzUNFUepl hur0FZncSn3ru0E/+mZJX4EedpoiYsKTA3lDov9xuqvUkGo6waNo9nv+O1l+yJD+GAHn Rhf7reIgG+K4/UP1LupyyZ/HrrsoOO/zAjhSwTNCBuFYjJjnAJI43eK8yeQ0Qf7ciG3T Kgyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=BHIpC+UdANUov3s0HHM/ibRe8plH32u/8iUjr4VOiDw=; b=KumZhSGStLheQHkEBEXuqnHnAZv6Ke/ElkbBKAJX8fwj0SSRWjtLMLBgK5+CCLYfpq ta1ONHQ0vLnrDk6mV2dXZpIhWsm9Df0RHyLqsn5xaKc7Gf9FehGzo/RwR+EOKfpcEoSB DG/kGAOUKfekT0gxHrhM5PMTjT2J1y9KDAp0q93KDPR5NZDiHjM6GNx6Sx2pcArtCNh2 +NrFXto1SJ+J3CUdhAhGLnB8QHIYHbrT6198ivcihiVG5cfBTHQbSfRyhvjoIkRFOsBH GN/8BerZWNF+Ho0Bm1PXQLC0JsQ2ddtYX+7N8G9Kea+Kvi8nvvqtC41rPGPZVoTN/pqZ gS6A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3si5248699pff.117.2019.05.16.07.26.45; Thu, 16 May 2019 07:27:01 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727287AbfEPOZM (ORCPT + 99 others); Thu, 16 May 2019 10:25:12 -0400 Received: from relay.sw.ru ([185.231.240.75]:55298 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726790AbfEPOZL (ORCPT ); Thu, 16 May 2019 10:25:11 -0400 Received: from [172.16.25.169] by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hRHJj-0007J4-HM; Thu, 16 May 2019 17:25:07 +0300 Subject: Re: [PATCH RFC 0/5] mm: process_vm_mmap() -- syscall for duplication a process mapping To: Adam Borowski Cc: akpm@linux-foundation.org, dan.j.williams@intel.com, mhocko@suse.com, keith.busch@intel.com, kirill.shutemov@linux.intel.com, pasha.tatashin@oracle.com, alexander.h.duyck@linux.intel.com, ira.weiny@intel.com, andreyknvl@google.com, arunks@codeaurora.org, vbabka@suse.cz, cl@linux.com, riel@surriel.com, keescook@chromium.org, hannes@cmpxchg.org, npiggin@gmail.com, mathieu.desnoyers@efficios.com, shakeelb@google.com, guro@fb.com, aarcange@redhat.com, hughd@google.com, jglisse@redhat.com, mgorman@techsingularity.net, daniel.m.jordan@oracle.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <155793276388.13922.18064660723547377633.stgit@localhost.localdomain> <20190515193841.GA29728@angband.pl> <7136aa47-3ce5-243d-6c92-5893b7b1379d@virtuozzo.com> <20190516134220.GB24860@angband.pl> From: Kirill Tkhai Message-ID: <14efd2c5-ffd1-84ad-b1d1-42f8ef44d7e2@virtuozzo.com> Date: Thu, 16 May 2019 17:25:06 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190516134220.GB24860@angband.pl> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16.05.2019 16:42, Adam Borowski wrote: > On Thu, May 16, 2019 at 04:10:07PM +0300, Kirill Tkhai wrote: >> On 15.05.2019 22:38, Adam Borowski wrote: >>> On Wed, May 15, 2019 at 06:11:15PM +0300, Kirill Tkhai wrote: >>>> This patchset adds a new syscall, which makes possible >>>> to clone a mapping from a process to another process. >>>> The syscall supplements the functionality provided >>>> by process_vm_writev() and process_vm_readv() syscalls, >>>> and it may be useful in many situation. >>>> >>>> For example, it allows to make a zero copy of data, >>>> when process_vm_writev() was previously used: >>> >>> I wonder, why not optimize the existing interfaces to do zero copy if >>> properly aligned? No need for a new syscall, and old code would immediately >>> benefit. >> >> Because, this is just not possible. You can't zero copy anonymous pages >> of a process to pages of a remote process, when they are different pages. > > fork() manages that, and so does KSM. Like KSM, you want to make a page > shared -- you just skip the comparison step as you want to overwrite the old > contents. > > And there's no need to touch the page, as fork() manages that fine no matter > if the page is resident, anonymous in swap, or file-backed, all without > reading from swap. Yes, and in case of you dive into the patchset, you will found the new syscall manages page table entries in the same way fork() makes. >>>> There are several problems with process_vm_writev() in this example: >>>> >>>> 1)it causes pagefault on remote process memory, and it forces >>>> allocation of a new page (if was not preallocated); >>>> >>>> 2)amount of memory for this example is doubled in a moment -- >>>> n pages in current and n pages in remote tasks are occupied >>>> at the same time; >>>> >>>> 3)received data has no a chance to be properly swapped for >>>> a long time. >>> >>> That'll handle all of your above problems, except for making pages >>> subject to CoW if written to. But if making pages writeably shared is >>> desired, the old functions have a "flags" argument that doesn't yet have a >>> single bit defined. > > > Meow! >