Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1332428rwb; Tue, 27 Sep 2022 11:28:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6X2Ec50t104TJqGrNCMy0D/j/y68qbF63J2v0XQjsYvKYdkQVR9V0oDUyZJ9qhaNGXhUwu X-Received: by 2002:a17:90b:3b81:b0:202:597a:c71d with SMTP id pc1-20020a17090b3b8100b00202597ac71dmr5801592pjb.105.1664303330539; Tue, 27 Sep 2022 11:28:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664303330; cv=none; d=google.com; s=arc-20160816; b=L7v113CFjOjgiV/sZoX8CRc8rj8B+9UbaCvVbPo00YMG9h+cN8ocy7vriwdiU+jJzY KW5b+Ow4HVY28NyKoZRzTQt6AXPUHoCR3itwgmAsMGs3s641SMMFRxtTRTpG9g08pWWy hty129/zrKbiORBDqTTW1aAcUquWSID2Zmrzz8M5NhSsmN58LgDg/NAF+FDV9RYDo74x EwaUaajTbL11hP21Hk1I1d47jw7rIiilfJkk1TTrlrEV9mlaT+HspOmalmph+HrNe/5C /DuDpBtZUo2oE84+S5ApIgfZR78u5sGGm3m8Podmk83nCcnsTlpS7sBfOJMYuh7HiYlj D6cg== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=gldTMiGdSSy+s/mX5olbpKniS/LLCTAFW6jQieMpGNc=; b=IrJP8OeJFkbv1rZ2E157m1+lPTct8P07he0N92P7uZZ3HFcddbXkH8RVy54Kk7QqaH CMx51EwPUj9QaBHcAT6D9ltsRkJLTMOUzVo8fHB+MYW3m3fpw+G0crSzOoanoHYQqkQv B8c3pPOrQ8vq1uuHB6q1UJ+GusK7veG9QVyVubvk2RssR702vszMcmRkAbGBQXMcrfGS 54rwf2aEoTIhk/LEQ0vVBwbiZi59XvAKLAX3AtMeNn954+OaDW7iwarhq8SZ3fak3JaX 0zX/v54g2kIYY6SIulokWqDkQfxTphd60bLiGF5QCvkUjwYLXIVysXNPVkKXgabK3I7W YnoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=O4RQnE+k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w37-20020a634925000000b0043961d06befsi2650334pga.486.2022.09.27.11.28.38; Tue, 27 Sep 2022 11:28:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=O4RQnE+k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232590AbiI0SGM (ORCPT + 99 others); Tue, 27 Sep 2022 14:06:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232462AbiI0SGJ (ORCPT ); Tue, 27 Sep 2022 14:06:09 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41CF4AA349 for ; Tue, 27 Sep 2022 11:06:08 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id l65so10361254pfl.8 for ; Tue, 27 Sep 2022 11:06:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date; bh=gldTMiGdSSy+s/mX5olbpKniS/LLCTAFW6jQieMpGNc=; b=O4RQnE+kP++cKx/K7Aw550wsJ4fY1C8HC+psA7CQHnY7faIr8roalHlx4b2Ak+Qp/4 hTTHWqFGCOhM8E7PHekmTZVU2krdXaxiPtW5AbbugelKKlVku0oaSW4HJg27/b33l8rW 2wFKlszRjdyPQZPoAVEfJYPkeO05TT2yyXLDUVoNNPg6LAKbIEe6WgdqmBJ6c3Vq/nQF B0kc9DXK7ArVbcjrkCtI6sph3lGljpXrfFrcZL+4PMeLEv1uo1ioWx7ubdunt4s3qsd5 DBpRbqWSmWmyY6TYfM9yiH6Rh/xMSZURWoYos9ABnEGH0xRYj/HvK/jChSE17bTHyckW +ikQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=gldTMiGdSSy+s/mX5olbpKniS/LLCTAFW6jQieMpGNc=; b=LkhpiXo28Mfvu7lEgg+Q1gmSCyOBJzFhGaqM8FIY+CC2xCEY9tzumLqyUI7BCMX002 T+pZF2gqmXf6knQ+EUo7PLH7gxefX7Vmidd7kRf4ejVaS+TwMQZk+IDA1JI+h72Eb5UM scj5Y6maWUZIjPsddv0lQuVhrRbDsqBGQowpVkDcKPHAj9VaOg+6CZU5vG97Xfs+qFQ8 pvnKTyK7roL0oUP6muNlyj45o+FPm3nuu03//1yTENP2J+CsXuP1QAaAXruHuhwHTTOb +ocQplltfbVinOqEImSOofWsOA2LLrsYnY3gIn4696Cmw9UuAil/VGnkovKVmnpEkLlu B2OQ== X-Gm-Message-State: ACrzQf195Q+YaAM7mz9XP9rKz84xpgLTOchlT/8wAz54/uehby8ZLehF QXU5qQ2ugf+bU/8yyjZid20= X-Received: by 2002:a63:1546:0:b0:42c:50dc:2115 with SMTP id 6-20020a631546000000b0042c50dc2115mr25819826pgv.613.1664301967508; Tue, 27 Sep 2022 11:06:07 -0700 (PDT) Received: from strix-laptop (2001-b011-20e0-1b32-d148-19d6-82fa-6094.dynamic-ip6.hinet.net. [2001:b011:20e0:1b32:d148:19d6:82fa:6094]) by smtp.gmail.com with ESMTPSA id i8-20020a655b88000000b00434651f9a96sm1821908pgr.15.2022.09.27.11.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 11:06:06 -0700 (PDT) Date: Wed, 28 Sep 2022 02:05:59 +0800 From: Chih-En Lin To: Nadav Amit Cc: Andrew Morton , Qi Zheng , David Hildenbrand , Matthew Wilcox , Christophe Leroy , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , Luis Chamberlain , Kees Cook , Iurii Zaikin , Vlastimil Babka , William Kucharski , "Kirill A . Shutemov" , Peter Xu , Suren Baghdasaryan , Arnd Bergmann , Tong Tiangen , Pasha Tatashin , Li kunyu , Anshuman Khandual , Minchan Kim , Yang Shi , Song Liu , Miaohe Lin , Thomas Gleixner , Sebastian Andrzej Siewior , Andy Lutomirski , Fenghua Yu , Dinglan Peng , Pedro Fonseca , Jim Huang , Huichun Feng Subject: Re: [RFC PATCH v2 2/9] mm: pgtable: Add sysctl to enable COW PTE Message-ID: References: <20220927162957.270460-1-shiyn.lin@gmail.com> <20220927162957.270460-3-shiyn.lin@gmail.com> <8632896B-35D1-4B8F-8A7F-275DEEBCB962@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8632896B-35D1-4B8F-8A7F-275DEEBCB962@vmware.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 27, 2022 at 05:27:45PM +0000, Nadav Amit wrote: > On Sep 27, 2022, at 9:29 AM, Chih-En Lin wrote: > > > Add a new sysctl vm.cow_pte to set MMF_COW_PTE_READY flag for enabling > > copy-on-write (COW) to the PTE page table during the next time of fork. > > > > Since it has a time gap between using the sysctl to enable the COW PTE > > and doing the fork, we use two states to determine the task that wants > > to do COW PTE or already doing it. > > I don’t get why it is needed in general and certainly why sysctl controls > this behavior. > > IIUC, it sounds that you want prctl and not sysctl for such control. But > clearly you think that this control is needed because there is a tradeoff. > Please explain the tradeoff and how users are expected to make a decision > whether to turn the flag or not. > If applying COW to the page table, it will has a significantly change to kernel, this is why I think it uses the sysctl at first. But, prctl might be better a choice. For the tradeoff. Since, in some cases (like executing the command in the terminal), enabling COW to page table only will increase the overhead due to the page fault (break COW). It doesn't have any benefit from the COW mechanism. So, we let the users decide which process will enable COW page table. The expected user usually will be the process that requires a lot of memory and want to create a new process for an isolated environment. (e.g., fuzzer, container, etc) So, expand COW to page table may improves the startup time and memory usage (on-demand allocate memory). Thanks, Chih-En Lin