Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1360568pxb; Fri, 21 Jan 2022 16:30:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVcxbVQIIhEnHgab/D/0s/tcoppaT06yVwKBndN4iCTtJpJd1iP7NOg82dy1q4yi9BkOPu X-Received: by 2002:a63:9142:: with SMTP id l63mr4587677pge.476.1642811414153; Fri, 21 Jan 2022 16:30:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642811414; cv=none; d=google.com; s=arc-20160816; b=Ug8+OXhcfVZF5KuyyOBlvi4n/mBg9bkPvzpHHoLZ2WyDtC1jNyQbmLwwLZC+MY5t/W hIoPQ9LxWYsgIwX5XGb0NJJH4+ALjdiFQwelxhZLulJMtCMRrm+DnDkR5QMksdUcRlbl 5Fw2AtzLmot8pjQEm1FlZcTkpiT8KZQiqaXdED2e8BdbIgCMpeEbQRIyJt+a7i8SpJ7Q WdlN6bPwcSd92DdtO+mtm9f50MKSTJ/Taq6LmpzSBKbzlCEagp7D483EeJD3Or2VaX9a xVbQ0fGscXhtZ8dv0Q7HqrTmbHymKtX+5QdA1GKqvW6KhUivN4HJN6TWhgFWXNsR3anz S1Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=mMsttHL5yQ5Bam0gaHSIXD7InB+D1TXSs5SzrAG0bSk=; b=bb/IO/yozHaW3kXv8vNWqVykxNWAQHgvqchqC5b5mTVwH9NwgUMPeV/N3ayunQWbOY W/mU9Z8+JQZpKNmo7bMgNncDDO3zMZIzlEQyevYGwEJOSu2cuOOyxw4R7/MGsL06glf+ ieziRwaxTHzPPueHB8HVwK6hJKRiFVIo87x6R9tuBCR0K+StzDxjjySXYEOkmC8ppqvT 7SQM0lsmT8sFrQHt23+wdVoSiimns5jdMn2M24zGFq1s4XMR44XgfDmG48GwslyeMOZN JFscbUngifjBGSq7CI+d5atKYKG6xXg1CQYDA8nAemz/s6/2qRjQ0gDE7N33CTofnxhK NfYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=KYXhTDyT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 145si7523836pga.75.2022.01.21.16.30.02; Fri, 21 Jan 2022 16:30:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=KYXhTDyT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378455AbiAUCOI (ORCPT + 99 others); Thu, 20 Jan 2022 21:14:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245178AbiAUCOH (ORCPT ); Thu, 20 Jan 2022 21:14:07 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76FF2C061574 for ; Thu, 20 Jan 2022 18:14:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=mMsttHL5yQ5Bam0gaHSIXD7InB+D1TXSs5SzrAG0bSk=; b=KYXhTDyTi334B1jiFPr/nlo7Nx Zw1cXlIffzkjqN/ZJCyJnkY2yK+SzelC8tB1iQv4o3bYrnyAL1hbnaqukDfqFbdlNMzd5+DBhXmHh 8tqJ2IUDqYJM4QXVzqKqq/z1oa3JZWPXnZgA82cSbO1tQwvZbbEtWEtq60SGyGPZgXoNTrXdy4kU+ fvh7Mng8jrJvOOqzBeF2lsiEr23ThBUM1fWIzUdcdJe8Y+lCG65oP5mO+g0Fw2R8Oo3EICVtTVGNF L2bgvhyHninDk0zTvnJSodc6+OwtwYbtlRgwCuXwEk+yQ3mfxgGO+zbvJ4panbZD/G3IVyeuTf5SE 5UqOZ5zQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nAjR2-00F9EU-MD; Fri, 21 Jan 2022 02:13:52 +0000 Date: Fri, 21 Jan 2022 02:13:52 +0000 From: Matthew Wilcox To: Barry Song <21cnbao@gmail.com> Cc: khalid.aziz@oracle.com, akpm@linux-foundation.org, arnd@arndb.de, dave.hansen@linux.intel.com, david@redhat.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, longpeng2@huawei.com, rppt@kernel.org, surenb@google.com Subject: Re: [RFC PATCH 0/6] Add support for shared PTEs across processes Message-ID: References: <20220121010806.5607-1-21cnbao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220121010806.5607-1-21cnbao@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 21, 2022 at 09:08:06AM +0800, Barry Song wrote: > > A file under /sys/fs/mshare can be opened and read from. A read from > > this file returns two long values - (1) starting address, and (2) > > size of the mshare'd region. > > > > -- > > int mshare_unlink(char *name) > > > > A shared address range created by mshare() can be destroyed using > > mshare_unlink() which removes the shared named object. Once all > > processes have unmapped the shared object, the shared address range > > references are de-allocated and destroyed. > > > mshare_unlink() returns 0 on success or -1 on error. > > I am still struggling with the user scenarios of these new APIs. This patch > supposes multiple processes will have same virtual address for the shared > area? How can this be guaranteed while different processes can map different > stack, heap, libraries, files? The two processes choose to share a chunk of their address space. They can map anything they like in that shared area, and then also anything they like in the areas that aren't shared. They can choose for that shared area to have the same address in both processes or different locations in each process. If two processes want to put a shared library in that shared address space, that should work. They probably would need to agree to use the same virtual address for the shared page tables for that to work. Processes should probably not put their stacks in the shared region. I mean, it could work, I suppose ... threads manage it in a single address space. But I don't see why you'd want to do that. For heaps, if you want the other process to be able to access the memory, I suppose you could put it in the shared region, but heaps aren't going to be put in the shared region by default. Think of this like hugetlbfs, only instead of sharing hugetlbfs memory, you can share _anything_ that's mmapable. > BTW, it seems you have different intention with the below? > Shared page tables during fork[1] > [1] https://lwn.net/Articles/861547/ Yes, that's completely different.