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=-11.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 CF56CC4338F for ; Mon, 16 Aug 2021 15:01:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B078E60F39 for ; Mon, 16 Aug 2021 15:01:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232733AbhHPPCV (ORCPT ); Mon, 16 Aug 2021 11:02:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57300 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232467AbhHPPCU (ORCPT ); Mon, 16 Aug 2021 11:02:20 -0400 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-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-466-XmVHXO7fNd-na5CVeNE8fw-1; Mon, 16 Aug 2021 11:01:46 -0400 X-MC-Unique: XmVHXO7fNd-na5CVeNE8fw-1 Received: by mail-wr1-f70.google.com with SMTP id z10-20020a5d440a0000b0290154e0f00348so5604267wrq.4 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=ES/VadXQGsMFxbZWLYbHsPO1Dd8fcHcxJequ+5zZuHFseTdXCu8ArsXq5VqvgZqDkt Q2Sd2iL/K5o7lPCVoZp26ePSAummQgVOn95LAHvM5d0DI02BeWVsvJ2uFfNCXY99eou+ oQB2ioj+SOJfrVnZIjuRDPYF3Zix4PR6SW7OwbVFAEMnoaPCBDEdSHuUp0MMsQDUZqCb 3Blbvy7T6LX5pK+RLu0uEOVRJkRAaE3bSrFg3yAAWMy28QzpxeR0KmUg0x9lTJSNOtuM 4BxrsMO3893yF2Z2pxazKO3QcCXj0ufHK9o1AFjO8OpsGtXBvOF4jU+93MYK++St7yIa bG5g== X-Gm-Message-State: AOAM530NUU8V6gQSRjNKoD2y43kB5U0SR9WZLvGvt23wB5aK2GC7QbpY 5L9L9eqvjegZZHQZEgHHx96dHkwsyR8rHjFGyEWGt8dpDO23JT7xNJI3pr35IuYZTIo+m5x4R8Q sT58O04QwMkZjaDfuOxIM18QG X-Received: by 2002:a5d:674b:: with SMTP id l11mr17877163wrw.357.1629126105494; 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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 having >>>> private anonymous pages shared between processes that don't COW, introducing >>>> 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_PRIVATE? > > Are you referring to this? Yes > > : 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. > > If so, that's a misunderstanding, because there are no games being played. > 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. > It actually seems to be just like I understood it. We'll have multiple processes share anonymous pages writable, even though they are not using shared memory. IMHO, sharing page tables to optimize for something kernel-internal (page table consumption) should be completely transparent to user space. Just like ARCH_WANT_HUGE_PMD_SHARE currently is unless I am missing something important. The VM_MAYSHARE check in want_pmd_share()->vma_shareable() makes me assume that we really only optimize for MAP_SHARED right now, never for MAP_PRIVATE. -- Thanks, David / dhildenb