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 8CAFFC4338F for ; Mon, 16 Aug 2021 13:24:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2401E600D4 for ; Mon, 16 Aug 2021 13:24:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2401E600D4 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 A71936B0071; Mon, 16 Aug 2021 09:24:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A21536B0072; Mon, 16 Aug 2021 09:24:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9100E6B0073; Mon, 16 Aug 2021 09:24:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0109.hostedemail.com [216.40.44.109]) by kanga.kvack.org (Postfix) with ESMTP id 74F696B0071 for ; Mon, 16 Aug 2021 09:24:45 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2037218F41 for ; Mon, 16 Aug 2021 13:24:45 +0000 (UTC) X-FDA: 78481013730.21.6CED307 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 7D7B4D0066D1 for ; Mon, 16 Aug 2021 13:24:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629120283; 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=Fsd158OY566OjNuqnho/MiPw3AgTcPdq2DX43UPAUYo=; b=N4dU0Z5AlRuR2q5tWMRIW2C9mlhhyAk1da6ppyzKgIa2xbgXwbhRttgnz6MUsUTmt2l1jV VFfzYOlhYGRF5GR2RbdhNA1YZSZABItJ1O/G6sjPVx8cvepeskpZnVime+4yWDC+ooO0TF uOvDqhSfM04+L6r1Mob9YJTO4eB2jzQ= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-179-JtIkHe0APuC9pNzsqQT0YQ-1; Mon, 16 Aug 2021 09:24:40 -0400 X-MC-Unique: JtIkHe0APuC9pNzsqQT0YQ-1 Received: by mail-wr1-f69.google.com with SMTP id r17-20020adfda510000b02901526f76d738so5524162wrl.0 for ; Mon, 16 Aug 2021 06:24:40 -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=Fsd158OY566OjNuqnho/MiPw3AgTcPdq2DX43UPAUYo=; b=Q1Dhrv+j9iDNg/jZNHqWeZ+PMbV+uCBL/rKL9Tizixs8MeE6nULM8U4td9+IJMttua J9KiPmAOv2T3CvBTCf72hnAJmWj/dofCh3K9ulCTsW2HvvWbUsH+XczPFSRqFNir+tDt g4T9aOgzIMWgh37EXhkWuVkudOdCxkB4QSCzp+e89pGudXDXq8SBzm16N1CRv0vdJlo1 vkvlp9j8webvO3MRcqSYwW7301KOnhfbKX2IuUx7xFuVUFgOficd9jAyNRrcPSHZziRW CkqV7m/sVbjuuv2DuQbI8OzYxULRRb90SkcSnVmrkN3kGYSjI7MYKv74Hj6cT5hA3/0y /20A== X-Gm-Message-State: AOAM532Nmhx5IzB92PPNO/fxgL83/SdluYCk+M+KXCKFAv91YPx1/X8E 2fI3o1kPsIFO2/s/yQ4EXfLX3EoB4YnX9RahjgDjTPsSIU7O96ssI1TEV2wAsWdJFuIuXAPi2dx th/taUEhW+8Q= X-Received: by 2002:a1c:a5d4:: with SMTP id o203mr396426wme.106.1629120279582; Mon, 16 Aug 2021 06:24:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+zn8Y/sVRuv+LI4mi0Apb9QM43FB5cReCM9GAf2si0PXlT7CKP2qZlhSorxCbG7zUjTBozQ== X-Received: by 2002:a1c:a5d4:: with SMTP id o203mr396403wme.106.1629120279364; Mon, 16 Aug 2021 06:24:39 -0700 (PDT) Received: from [192.168.3.132] (p5b0c67f1.dip0.t-ipconnect.de. [91.12.103.241]) by smtp.gmail.com with ESMTPSA id b12sm13924688wrx.72.2021.08.16.06.24.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Aug 2021 06:24:38 -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: <1595869887-23307-1-git-send-email-anthony.yznaga@oracle.com> <43471cbb-67c6-f189-ef12-0f8302e81b06@oracle.com> <55720e1b39cff0a0f882d8610e7906dc80ea0a01.camel@oracle.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [RFC PATCH 0/5] madvise MADV_DOEXEC Message-ID: <88884f55-4991-11a9-d330-5d1ed9d5e688@redhat.com> Date: Mon, 16 Aug 2021 15:24:38 +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 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=N4dU0Z5A; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf15.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com X-Stat-Signature: 7boy1crisf3au3n5oe7e6dy9w1cgagdb X-Rspamd-Queue-Id: 7D7B4D0066D1 X-Rspamd-Server: rspam05 X-HE-Tag: 1629120284-823220 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 14:46, Matthew Wilcox wrote: > On Mon, Aug 16, 2021 at 02:20:43PM +0200, David Hildenbrand wrote: >> On 16.08.21 14:07, Matthew Wilcox wrote: >>> On Mon, Aug 16, 2021 at 10:02:22AM +0200, David Hildenbrand wrote: >>>>> 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. The first process tha= t >>>>> declares an address range mshare'd can continue to map objects in t= he >>>>> shared area. All other processes that want mshare'd access to this >>>>> memory area can do so by calling mshare(). After this call, the >>>>> address range given by mshare becomes a shared range in its address >>>>> space. Anonymous mappings will be shared and not COWed. >>>> >>>> Did I understand correctly that you want to share actual page tables= between >>>> processes and consequently different MMs? That sounds like a very ba= d idea. >>> >>> That is the entire point. Consider a machine with 10,000 instances >>> of an application running (process model, not thread model). If each >>> application wants to map 1TB of RAM using 2MB pages, that's 4MB of pa= ge >>> tables per process or 40GB of RAM for the whole machine. >> >> What speaks against 1 GB pages then? >=20 > Until recently, the CPUs only having 4 1GB TLB entries. I'm sure we > still have customers using that generation of CPUs. 2MB pages perform > better than 1GB pages on the previous generation of hardware, and I > haven't seen numbers for the next generation yet. I read that somewhere else before, yet we have heavy 1 GiB page users,=20 especially in the context of VMs and DPDK. >=20 >>> There's a reason hugetlbfs was enhanced to allow this page table shar= ing. >>> I'm not a fan of the implementation as it gets some locks upside down= , >>> so this is an attempt to generalise the concept beyond hugetlbfs. >> >> Who do we account the page tables to? What are MADV_DONTNEED semantics= ? Who >> cleans up the page tables? What happens during munmap? How does the rm= ap >> even work? How to we actually synchronize page table walkers? >> >> See how hugetlbfs just doesn't raise these problems because we are sha= ring >> pages and not page tables? >=20 > No, really, hugetlbfs shares page tables already. You just didn't > notice that yet. So, it only works for hugetlbfs in case uffd is not in place (-> no=20 per-process data in the page table) and we have an actual shared=20 mappings. When unsharing, we zap the PUD entry, which will result in=20 allocating a per-process page table on next fault. I will rephrase my previous statement "hugetlbfs just doesn't raise=20 these problems because we are special casing it all over the place=20 already". For example, not allowing to swap such pages. Disallowing=20 MADV_DONTNEED. Special hugetlbfs locking. --=20 Thanks, David / dhildenb