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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3529C7EE2E for ; Mon, 12 Jun 2023 16:25:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65B0B8E0003; Mon, 12 Jun 2023 12:25:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 60A228E0002; Mon, 12 Jun 2023 12:25:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FA0D8E0003; Mon, 12 Jun 2023 12:25:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3FE698E0002 for ; Mon, 12 Jun 2023 12:25:27 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BB731C02C3 for ; Mon, 12 Jun 2023 16:25:26 +0000 (UTC) X-FDA: 80894621052.21.E3EB89D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 806D6180015 for ; Mon, 12 Jun 2023 16:25:24 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UuDbwnEF; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686587124; a=rsa-sha256; cv=none; b=yG1LuR6ubvjjigK2t+UoeB1G6i4usIIy7EdxLEEZlu0ERG0J5Evqu/QFPrhJB0q68a+XFM h9SklyCAgmpqvRi/HFxAKP83XnDrPLp8XwerE/M02Z5n6W7FtzFKMC0YQu+7VHCKZGbviC qHkWbgNznTU/J77lM0jyaRdBrpgKR1s= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UuDbwnEF; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686587124; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EqwXplhA6elh/wvBFScazI5+BTtK4bRNV6UTAcVMSLo=; b=j10CMYsOt7tekZ9iNJLixU5cT+pUstKNUmlcoVTvvDe7dSuDA0jVNcOoDKNA8rLgZyUSxH HIVGUXQHPSnpuT3Wlg04UGNDnjc1+SzR5tUuSP+Yww8+OeNCSaOwsOAHpkOIitCalHTsdE jrald+hLJkH4dbvPZAxkGD4o7SuMy4I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686587123; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EqwXplhA6elh/wvBFScazI5+BTtK4bRNV6UTAcVMSLo=; b=UuDbwnEFrZBtfztTcQTYm7kGuLXEoq5H+ccZRYjcZBorpM5sSaJBrT254HJmR/pjvvQaS6 Aq0XH6p5FbAnl+DWyoAtDFzTnw0oNGROXLaluJLeHoG/6VcWEefue/aeqxZqL0SXgDItvg YleaMGOLf4zU1bsIMWmN8D3/94QMi/8= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-111-fiRUTuIKO-iNsNbjbgxFEw-1; Mon, 12 Jun 2023 12:25:22 -0400 X-MC-Unique: fiRUTuIKO-iNsNbjbgxFEw-1 Received: by mail-ot1-f69.google.com with SMTP id 46e09a7af769-6b2b00c5ee0so211844a34.0 for ; Mon, 12 Jun 2023 09:25:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686587121; x=1689179121; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=EqwXplhA6elh/wvBFScazI5+BTtK4bRNV6UTAcVMSLo=; b=eNZQMit7n/bwMH0QkXxzEdhoI6GJLB77dDaolARLPYwkunqA6OOIAtuboOf/Q/4YLo FJ1b5VJUfwlp+WTSPt7so+24ZtHL8Glhl2TZL05S1Zwi4fg5kTMN8nNOcgRfrhjRxoMi AKIg7/HzDcMtuYZvGBJElXjFC8nkqQmMuJ3hL+3heOm8KyKh/jvFIXRL3JGLTBVeBZro Rv3DJ1LF/wumHzRLPgV/q2+0HCXRjD8eNUlIqhTi7GZ5i99wDWrFDJCDugUpVH3+JKxL UBKZxk2IIOQHBXq7kwU5zckxtbKmgY8fccb7Fps/CMYjl7zmBGWw+6TJ/WDIjeuoVuG8 noiQ== X-Gm-Message-State: AC+VfDwQRcdib2IKOLbQQ5u3VgUsrPC5D8oxKlrcSkVyvZm3WtdoRhAB R58jqheGvF+BbFvRJFY2tgdI4A1+t8x3pV0VJ8otY2+nB46ewokxpogwRZl7xbn85hORgAriTrO ksTFTmLVKZW0= X-Received: by 2002:a05:6830:6116:b0:6b1:5075:87ec with SMTP id ca22-20020a056830611600b006b1507587ecmr5481292otb.1.1686587121461; Mon, 12 Jun 2023 09:25:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6oDPJ4lumFhl21SxU7udUxydSD4vf4JJO9yBFnkI9xGni4BGh7usWoNwiiWtsG9588r15Cdw== X-Received: by 2002:a05:6830:6116:b0:6b1:5075:87ec with SMTP id ca22-20020a056830611600b006b1507587ecmr5481276otb.1.1686587121169; Mon, 12 Jun 2023 09:25:21 -0700 (PDT) Received: from x1n (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id j3-20020a0cf303000000b00627a6fd04ddsm3313829qvl.122.2023.06.12.09.25.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 09:25:20 -0700 (PDT) Date: Mon, 12 Jun 2023 12:25:18 -0400 From: Peter Xu To: Khalid Aziz Cc: akpm@linux-foundation.org, willy@infradead.org, markhemm@googlemail.com, viro@zeniv.linux.org.uk, david@redhat.com, mike.kravetz@oracle.com, andreyknvl@gmail.com, dave.hansen@intel.com, luto@kernel.org, brauner@kernel.org, arnd@arndb.de, ebiederm@xmission.com, catalin.marinas@arm.com, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhiramat@kernel.org, rostedt@goodmis.org, vasily.averin@linux.dev, xhao@linux.alibaba.com, pcc@google.com, neilb@suse.de, maz@kernel.org Subject: Re: [PATCH RFC v2 0/4] Add support for sharing page tables across processes (Previously mshare) Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 806D6180015 X-Stat-Signature: xito6dszndxjrufswg8nzgm4jgdzbjpx X-HE-Tag: 1686587124-462226 X-HE-Meta: U2FsdGVkX1+fhYL3bjozUF/x5+JbXbEnltGWXOu0jyauMnTr7dhlSL29U8pw7Frg3J10rWTUEzoX5e1UdSnsgb/qRzb5+wuAZnx+njFsBaWbrfQ8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TVpuJ4tSMDcLU+0zd2tjCp693mJ2dlN25qAckMjGg6ru8ZV4l3FiBlYMQpvdfz6hfXuiEsQWeP0XJ3R7WVPReu4/SENEjYkqr4+7AoIZhbXwqRoFSVqD9OHULthIW638WoL5y6/HjiVBywkbVNm2nIDNAsnoQxtqZBQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000028, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Apr 26, 2023 at 10:49:47AM -0600, Khalid Aziz wrote: > This patch series adds a new flag to mmap() call - MAP_SHARED_PT. Since hugetlb has this, it'll be very helpful if you can provide a comparison between this approach and hugetlb's - especially on the differences - and reasonings about those. Merging anything like this definitely should also pave way for hugetlb's future, so it even seems to be an "requirement" of such patchset even though implicitily.. considering the "hotness" that hugetlb recently has on refactoring demand (if not a rewrite). Some high level questions: - Why mmap() flag? For this one, I agree it should be opt-in - sharing pgtable definitely means sharing of a lot of privileges operating on current mm, so one should be aware and be prepared to be messed up. IIUC hugetlb doesn't do this but instead when something "racy" happens itt just unshares by default. To me opt-in makes more sense if to start from zero, because I don't think by default a process wants to leak its mm to others. I think you mentioned allowing pgtable to be shared even for mprotect() from one MM then all MMs can see; but if so then DONTNEED should really do the same - when one MM DONTNEED it it should go away for all. It doesn't make a lot of sense to me to treat it differently with a DONTNEED refcount anywhere.. - Can guest MM opt-out? Should we allow guest MM to opt-out when they want? It sounds like a good thing to have to me, especially for file that sounds like as simple as zapping the pgtable. But then mmap flag will stop working iiuc, so goes back to that question (e.g. what about madvise or prctl?). - Why mm_struct to represent shared pgtable? IIUC hugetlb used the pgtable page itself plus some refcounting (the refcounting is racy with gup-fast that Jann used to point out, but that's another story..). My question is do you think that won't work? Are there reasons to explain? Why mm_struct is the structure you chose for representing a shared pgtable? Why per-file? Thanks, -- Peter Xu