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 X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BBFAC432BE for ; Mon, 16 Aug 2021 15:01:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2A13861042 for ; Mon, 16 Aug 2021 15:01:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2A13861042 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 968628D0001; Mon, 16 Aug 2021 11:01:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9204C6B0073; Mon, 16 Aug 2021 11:01:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 807548D0001; Mon, 16 Aug 2021 11:01:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0116.hostedemail.com [216.40.44.116]) by kanga.kvack.org (Postfix) with ESMTP id 63F886B0072 for ; Mon, 16 Aug 2021 11:01:51 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id EA5B718089822 for ; Mon, 16 Aug 2021 15:01:50 +0000 (UTC) X-FDA: 78481258380.01.2CF572A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 1DA8B4001899 for ; Mon, 16 Aug 2021 15:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629126108; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JVtrxiWdB8p21eCaSQrl/t87lJASYUwCcn6GOLpI4Do=; b=RihADVzFD1yNktFuyIH/t5gOys/CZwJibM8i+4STceMlrbxo+Nh0iukrXb4t40xESHdHeF Kk8oWSN/oOI0BpIcL6qYn5bqc+3H2NcF+luSEmzPWO4Wrf8Zn6ivhcvtRh01PSCAUmSyUc DXs8P7jcZSRUvopp7yNRCxKPgNaale8= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-228-hleGgro2PmuxYDRMgcaBKw-1; Mon, 16 Aug 2021 11:01:46 -0400 X-MC-Unique: hleGgro2PmuxYDRMgcaBKw-1 Received: by mail-wm1-f70.google.com with SMTP id u15-20020a05600c210fb02902e6a5231792so83652wml.0 for ; Mon, 16 Aug 2021 08:01:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:organization:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=JVtrxiWdB8p21eCaSQrl/t87lJASYUwCcn6GOLpI4Do=; b=YjQ2UqJraUvdgqqjMIkUS9tKeVvu9eG31QnWZ80JPM3YqBM2C4hKxlPiptJzGH8nyS jmhQucdmpc0X6spK+ejoMI1h7Q3Rhin5ELzkhGJo6Y0I7wttMETpOfQ6ZjXeULvbcAuW Mhhn/GxEMhXHk3Ux+tOA/nxekQeGdC9kzhsxeOeE7rbf+aLdJ3f1zRNP7KxWYoRyyZxa KgzQJS/jKQElu+40VdOZW5wfVErmA0ZKJGeT/jqWhzKB4MCdRdNuUHS0k9rTjM3V7gF/ qos6+5A08ZYEYE+hQ9fSNETag3WaoqpdgXrefYjOqq6EPoZ1YunYrmszaQGmAia+KK/F DuJA== X-Gm-Message-State: AOAM533aM8wUhzbRyuP6UyV7W3TRm48rgdnKpmwc9U00piRi6j8X34h/ 8nlOZAEwfa+itL8HZJpDrfZoaLLnmrp2dKXkWEGTn6SRs07+ZgRIKgEgPUtyeArRiHIBC0vgfBC litivRNVQ1x8= X-Received: by 2002:a5d:674b:: with SMTP id l11mr17877173wrw.357.1629126105504; Mon, 16 Aug 2021 08:01:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdm7Cf1rb8lSN5vx8LmqxghsO7Jg0YPB5e1ppQkH+miodzACZ8lDSAFJcWjkLfzHMpaKlLRA== X-Received: by 2002:a5d:674b:: with SMTP id l11mr17877144wrw.357.1629126105297; Mon, 16 Aug 2021 08:01:45 -0700 (PDT) Received: from [192.168.3.132] (p5b0c67f1.dip0.t-ipconnect.de. [91.12.103.241]) by smtp.gmail.com with ESMTPSA id e3sm12620176wrv.65.2021.08.16.08.01.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Aug 2021 08:01:44 -0700 (PDT) To: Matthew Wilcox Cc: Khalid Aziz , "Longpeng (Mike, Cloud Infrastructure Service Product Dept.)" , Steven Sistare , Anthony Yznaga , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "Gonglei (Arei)" References: <55720e1b39cff0a0f882d8610e7906dc80ea0a01.camel@oracle.com> <88884f55-4991-11a9-d330-5d1ed9d5e688@redhat.com> <40bad572-501d-e4cf-80e3-9a8daa98dc7e@redhat.com> <3ce1f52f-d84d-49ba-c027-058266e16d81@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [RFC PATCH 0/5] madvise MADV_DOEXEC Message-ID: Date: Mon, 16 Aug 2021 17:01:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Rspamd-Queue-Id: 1DA8B4001899 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RihADVzF; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf18.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam04 X-Stat-Signature: 9irpsqystw5fjxnxikfzieefk96yirii X-HE-Tag: 1629126108-735337 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 16.08.21 16:40, Matthew Wilcox wrote: > On Mon, Aug 16, 2021 at 04:33:09PM +0200, David Hildenbrand wrote: >>>> I did not follow why we have to play games with MAP_PRIVATE, and hav= ing >>>> private anonymous pages shared between processes that don't COW, int= roducing >>>> new syscalls etc. >>> >>> It's not about SHMEM, it's about file-backed pages on regular >>> filesystems. I don't want to have XFS, ext4 and btrfs all with their >>> own implementations of ARCH_WANT_HUGE_PMD_SHARE. >> >> Let me ask this way: why do we have to play such games with MAP_PRIVAT= E? >=20 > Are you referring to this? Yes >=20 > : Mappings within this address range behave as if they were shared > : between threads, so a write to a MAP_PRIVATE mapping will create a > : page which is shared between all the sharers. >=20 > If so, that's a misunderstanding, because there are no games being play= ed. > What Khalid's saying there is that because the page tables are already > shared for that range of address space, the COW of a MAP_PRIVATE will > create a new page, but that page will be shared between all the sharers= . > The second write to a MAP_PRIVATE page (by any of the sharers) will not > create a COW situation. Just like if all the sharers were threads of > the same process. >=20 It actually seems to be just like I understood it. We'll have multiple=20 processes share anonymous pages writable, even though they are not using=20 shared memory. IMHO, sharing page tables to optimize for something kernel-internal=20 (page table consumption) should be completely transparent to user space.=20 Just like ARCH_WANT_HUGE_PMD_SHARE currently is unless I am missing=20 something important. The VM_MAYSHARE check in want_pmd_share()->vma_shareable() makes me=20 assume that we really only optimize for MAP_SHARED right now, never for=20 MAP_PRIVATE. --=20 Thanks, David / dhildenb