Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp627775yba; Thu, 16 May 2019 06:34:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJEfQTToU2vA1o77NnoR3GMoRRFj8XcvSrA0Xxu6unUFHcxB2XCX6f3eaFpVFrNuDtqM4M X-Received: by 2002:aa7:820c:: with SMTP id k12mr54037957pfi.177.1558013664514; Thu, 16 May 2019 06:34:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558013664; cv=none; d=google.com; s=arc-20160816; b=sTjnqWgY8pkrP2kAQd+tbtjflmuexNFBeIWs47OaKq9Lz15tRtp55Xfgmdq8IlhD33 p5kFn+A3lk3y4yAstSjtpwFLz/dE3yxVmF95qJN/dDLGp7OzDd4fbWCGL//EJgCSiwOK 8cnU8JVFg7QkAEeVnS2MAFbyGnnICP3FYJ249MWdsJgA1QmNYsSFFUYXD8bzYNauN1Ph G7Uy010r99NV1PXJ1WouNv6juv15TbD/D1pMRI2OxC/4g/a5eSKK3V7aJBLZGZ6H0aj1 nY/rLZSYvshWn6M1Y4lqvZxD2vds9Nrfs8YT5TyI0SiocsWLYh4yBYVXU69uMfErz7Ph j+9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=X+8Dc+8NQkNb3/Q1ARB2w0BPiehxHFy6DByP8EfeHyE=; b=BXNbuDDi4tvbvtK/fce0iLlpXgc+kM24wBXbwk159o+x8Z+yTJf4xt8uD9aG8mdUbz XghvZApnWAA4VKji6vAmQh6qPc9jQGc+eChegFVdHpupwW7h+EZEn7S70TgPDmtN3u6x DmN0D4cfHDoltCTuR02dFNNxX254XBQl5M5v3zuIzfuzDMxQeSmLnDlRKdukbDDQlQwX sFGmYHvggAw3/HdsTYB2qECtGB/bPJBtdg/cY8fVp3CPzpDjtSnKIUG1L9uJGEmhv6QP 4PsjO8QVRy1clV0z70MFtAygR7Jlz3EcVKln+pp9PS1ol2EsuNztYrTZpTuelWHJnN5R pmTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="SYjE/ozB"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u21si242625pga.151.2019.05.16.06.34.08; Thu, 16 May 2019 06:34:24 -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=@google.com header.s=20161025 header.b="SYjE/ozB"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727602AbfEPNce (ORCPT + 99 others); Thu, 16 May 2019 09:32:34 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:42743 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727069AbfEPNcd (ORCPT ); Thu, 16 May 2019 09:32:33 -0400 Received: by mail-oi1-f193.google.com with SMTP id w9so690572oic.9 for ; Thu, 16 May 2019 06:32:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=X+8Dc+8NQkNb3/Q1ARB2w0BPiehxHFy6DByP8EfeHyE=; b=SYjE/ozBIlk8Fx5sGYi6WTZimcARTlAHPPEaELxcs6u17YAQfVwz99WhY0CA7x7cml b4Cbzvdp8D4NHP23ztKo/w3yjKTb6vite0InwNqCh9vwMas7ZY5DZACFYyoKryN+jMoV NyjJVH4U+KBZh2WxuP67pee+2CWg+DVK+qrBguGtLysuan0h4KqHqlWLuJXrjYjddiTS urPSTTaLVGMYc8qvdvqRVf/kNHorlEc45l0DrLwMjryCebhvK2KjtGwCcLCUUeSttn4X CZIbEe5ZiInHuQP0yaoUgNKXgkMbz8IOp3sMzWpkjg/O0QLy/mCw2/ZKl8KC6OVEqqUx fA9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=X+8Dc+8NQkNb3/Q1ARB2w0BPiehxHFy6DByP8EfeHyE=; b=WMxg4yAPztD0UmlJ4uL4ZL6QcR5dqJ8llJMzH1nB01iVSxca1oD/0MRtJPjAODby/7 Y2gcKJtklD6mkekmdkKeG7s/XZsa9Ilnq2OIngMcoTkfCsaU3XaT3UBuorhSSEEZ0Ijl HWdThjtNYTujd44+oX8swX3HtGaXmVtLSloc+8dHuwh7O1Hdgkt9R0use5NrC+2s50oJ mGNJ4IbalxaKXUp26Z8S4SCxm0Rltb8HrOBwMzx1EVtd0/MhS/GRSeq8PHxwt0A13fmi Dp8F29vouln1GLPuRBREfMKXuj2MK0Ymif63D4TBdV7dG3dFcAATM0sHsMIcOT4Pkr2b 1vzg== X-Gm-Message-State: APjAAAWjUkc8CUAp/a31hvrWSS3PzWjiMoOXe4ufuRWbf4ijxoRpXESS pVbHfPM9TGyrimUTSpwjljv2Jp3aGkWyOD4E+NHP2Q== X-Received: by 2002:aca:180d:: with SMTP id h13mr10065721oih.39.1558013552764; Thu, 16 May 2019 06:32:32 -0700 (PDT) MIME-Version: 1.0 References: <155793276388.13922.18064660723547377633.stgit@localhost.localdomain> In-Reply-To: <155793276388.13922.18064660723547377633.stgit@localhost.localdomain> From: Jann Horn Date: Thu, 16 May 2019 15:32:06 +0200 Message-ID: Subject: Re: [PATCH RFC 0/5] mm: process_vm_mmap() -- syscall for duplication a process mapping To: Kirill Tkhai Cc: Andrew Morton , Dan Williams , Michal Hocko , keith.busch@intel.com, "Kirill A . Shutemov" , pasha.tatashin@oracle.com, Alexander Duyck , ira.weiny@intel.com, Andrey Konovalov , arunks@codeaurora.org, Vlastimil Babka , Christoph Lameter , Rik van Riel , Kees Cook , hannes@cmpxchg.org, npiggin@gmail.com, Mathieu Desnoyers , Shakeel Butt , Roman Gushchin , Andrea Arcangeli , Hugh Dickins , Jerome Glisse , Mel Gorman , daniel.m.jordan@oracle.com, kernel list , Linux-MM , Linux API Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 15, 2019 at 5:11 PM 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. [...] > The proposed syscall aims to introduce an interface, which > supplements currently existing process_vm_writev() and > process_vm_readv(), and allows to solve the problem with > anonymous memory transfer. The above example may be rewritten as: > > void *buf; > > buf = mmap(NULL, n * PAGE_SIZE, PROT_READ|PROT_WRITE, > MAP_PRIVATE|MAP_ANONYMOUS, ...); > recv(sock, buf, n * PAGE_SIZE, 0); > > /* Sign of @pid is direction: "from @pid task to current" or vice versa. */ > process_vm_mmap(-pid, buf, n * PAGE_SIZE, remote_addr, PVMMAP_FIXED); > munmap(buf, n * PAGE_SIZE); In this specific example, an alternative would be to splice() from the socket into /proc/$pid/mem, or something like that, right? proc_mem_operations has no ->splice_read() at the moment, and it'd need that to be more efficient, but that could be built without creating new UAPI, right? But I guess maybe your workload is not that simple? What do you actually do with the received data between receiving it and shoving it over into the other process?