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 F0793C6FA83 for ; Tue, 27 Sep 2022 18:06:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 702288E00F2; Tue, 27 Sep 2022 14:06:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B0668E00C1; Tue, 27 Sep 2022 14:06:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 551618E00F2; Tue, 27 Sep 2022 14:06:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4768F8E00C1 for ; Tue, 27 Sep 2022 14:06:09 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1765840708 for ; Tue, 27 Sep 2022 18:06:09 +0000 (UTC) X-FDA: 79958644458.17.8F3D267 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by imf22.hostedemail.com (Postfix) with ESMTP id A450AC0010 for ; Tue, 27 Sep 2022 18:06:08 +0000 (UTC) Received: by mail-pg1-f171.google.com with SMTP id bh13so10104351pgb.4 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=J57dGTNCkFzxGHZ7o62xzuotsh6f07bOTltcVktFo71Mav4w36Lhz/3/vrqgAfx7QA cJnxZiGFfyutn07bcroO8T367DTEn+e/DI7OWz8Ik8yIccjRz7+h6thm1oyUIGZju3/3 2/wLGHPuoxLbABxwXw+6qPdpNcAECsI+sJEOWSRsbsMlsv9ymG3TxwMtF6dJJ18lAd6v 2RYHZ+qpD6bH5z8Dv7M2uZd2F4tLmy8IFp4nxT8+cYjuXSujVLiEecUz3VUy2QGq+iAQ Ohy+4addbIsLlWsz8p62laH8vlrwSIcmuLG3OyX8dYAr5ZpKhtGWSVmW4mV2WTXsSTDM wTDQ== X-Gm-Message-State: ACrzQf0UcGLKWsNRrtjKVj66l9qx88aKIWJGCSL6IZVsth5qAxvJOfZu NFvtXpYvF9hbHuowivswoKk= X-Google-Smtp-Source: AMsMyM67D5l6eCrRorHIp+FxVnOs/2rE6yCoLSkUXLEQ7zNt+/Db1rh6BF5lqhVRxJRmE/Hguv4dPw== 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> ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=O4RQnE+k; spf=pass (imf22.hostedemail.com: domain of shiyn.lin@gmail.com designates 209.85.215.171 as permitted sender) smtp.mailfrom=shiyn.lin@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664301968; a=rsa-sha256; cv=none; b=LtNYss8cFj9XzlVWF7L4ceX+bjd4CUH/aZobxliZEZn1MgfPzA2oH/HfGj4EKiB8BBlrdM 8Jhfuz959xjew0kowGQc9aCTiMXOb2BHqrDNMyyNWQuk++mqW2RLTmtB2Nuniw+I5f4WMk HN4AFdiTMA+CKKrExc8t9S3gALxQ4XQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664301968; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gldTMiGdSSy+s/mX5olbpKniS/LLCTAFW6jQieMpGNc=; b=ETsqVRs+b+KSWj1EryusZf9lX0RPTJ8LsvJf5gXt7aYZy3iQGh9OxNNdZs7H1ZSkYWoNt3 /twBhV+5mv01efK5La0I9CnjuoER2o/4jzlWiIUH0nqtY5nZ/yNUkxgv/SM6Df0Qr4QkUg 5BzPtc57ZE/NXt2MFEbcV9fR7vQQzP8= Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=O4RQnE+k; spf=pass (imf22.hostedemail.com: domain of shiyn.lin@gmail.com designates 209.85.215.171 as permitted sender) smtp.mailfrom=shiyn.lin@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Stat-Signature: rer9dkweuikqjx7ukpw681wx93awid7b X-Rspamd-Queue-Id: A450AC0010 X-Rspamd-Server: rspam05 X-HE-Tag: 1664301968-214607 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 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