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 55A95EB64D9 for ; Thu, 6 Jul 2023 13:20:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E20728D0001; Thu, 6 Jul 2023 09:20:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD1736B0072; Thu, 6 Jul 2023 09:20:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C71BB8D0001; Thu, 6 Jul 2023 09:20:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B44B96B0071 for ; Thu, 6 Jul 2023 09:20:58 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 8E869A0C42 for ; Thu, 6 Jul 2023 13:20:58 +0000 (UTC) X-FDA: 80981247396.05.5E24698 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 4F91120013 for ; Thu, 6 Jul 2023 13:20:56 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BR377fPu; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf03.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688649656; 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=A7s8uyqG1vcIobDWxB0t9oElaquD+rOvumYmWRMufnY=; b=pIy/WHzqUIUik7/tiym3TyP3iXIuL6E1yQsu+bC/zcLme47D4EW/B1A4/XxWbEE7+yV7q8 RPZ2E4LAuZggKxb9OxWpjrFGWfi+E00GjJSdZDHG8ureanL/ed3NgD+LT1xdG8Zub5b7Mw pKZPJfoCupFIY2nOfjLbVywS+D8CLkU= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BR377fPu; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf03.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688649656; a=rsa-sha256; cv=none; b=YTZNjqy5Ucy80167ek9pXX37KICnhesJCdwoy3iNEeZA7+qxaW9gpWmzxJg/rHCLMIzcAb 0vMS8l12FCycETqc+pEncmO+8fgAhb3FLYjyf1tz9D6+0+aj6OxejuVFTAZsfw6mxuKqJC NURWNh2wU9FsP9lfiWMf7GzjijA+MLM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688649655; 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=A7s8uyqG1vcIobDWxB0t9oElaquD+rOvumYmWRMufnY=; b=BR377fPuFniNZJGZ9iWhANlItoOwrujA0xDQlm6Lux3nl8Rctsx7gKW47bSYLkzSvxkvla mZPtRoZl+kh7zuzcOIKZePGZOf4iJkax194ni9Z+Si/ehe24U3T2dts/paRz2mex/65434 9MZNAhREHM6MvAYXNUFT3dNYeYymTjU= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-250-VON_9qkKMs2X8sK3kw1Rgg-1; Thu, 06 Jul 2023 09:20:52 -0400 X-MC-Unique: VON_9qkKMs2X8sK3kw1Rgg-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3fbdd5d09b8so4814415e9.1 for ; Thu, 06 Jul 2023 06:20:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688649651; x=1691241651; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=A7s8uyqG1vcIobDWxB0t9oElaquD+rOvumYmWRMufnY=; b=DlcVBw0Q4HZ6Z49wHRf9rxxRxZGLTo22GflWeVdR1KxCBnquQu2/9wsOYOvoACvy7x V38XLQHQkBoxqkZe16RNSynzYiLKeOtEAdB3uV7vnh2NvJGbrPi9xWRmg0s8ptxrlmwY 2KVev7oL+ZMRsnrQqDMngFOpFMw+nXAjLv/yLUHxo07wekvBLUOELgsOAhKR6RUwUAMN 7hSbL9dn/6rrwMzVPbyxfKBcBF24mXKQwMXNEhvtIr2eQkS96s54KBX/OGN0dydVkG0v pWxy3Y4/0EugFEM30yF1czfAZ7dAiz6FGZzw9tpj6gSTp9FT8eDjwaTfmZ34b5g1CLp/ ulfw== X-Gm-Message-State: ABy/qLbu9X+5mZ7DG3hFHZRMBD34I4jsUJwbEZnZQr6t5sVMXn1vTECH 0FRzKW9Tvj+uRlSLLeWMdTL2c+TeAROXMI6VnWaiLXIaNwcjv8YzuFR8Lw5ta+d5SIDubuqPa+d eNWBaYE8k9+M= X-Received: by 2002:a05:600c:21d0:b0:3f9:b17a:cb61 with SMTP id x16-20020a05600c21d000b003f9b17acb61mr1486944wmj.13.1688649651712; Thu, 06 Jul 2023 06:20:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlGbX6NQkWyT4nncJbuxCqnOti+5GQSVyVlEjHdp0tT3+AV5OP4NtqhX7yZgN6eZGfJ98yWHlg== X-Received: by 2002:a05:600c:21d0:b0:3f9:b17a:cb61 with SMTP id x16-20020a05600c21d000b003f9b17acb61mr1486902wmj.13.1688649651231; Thu, 06 Jul 2023 06:20:51 -0700 (PDT) Received: from ?IPV6:2a09:80c0:192:0:5dac:bf3d:c41:c3e7? ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with ESMTPSA id z16-20020a1c4c10000000b003f8fb02c413sm2138843wmf.8.2023.07.06.06.20.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Jul 2023 06:20:50 -0700 (PDT) Message-ID: Date: Thu, 6 Jul 2023 15:20:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v4 1/2] fork: lock VMAs of the parent process when forking To: Suren Baghdasaryan , akpm@linux-foundation.org Cc: jirislaby@kernel.org, jacobly.alt@gmail.com, holger@applied-asynchrony.com, hdegoede@redhat.com, michel@lespinasse.org, jglisse@google.com, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@techsingularity.net, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, peterz@infradead.org, ldufour@linux.ibm.com, paulmck@kernel.org, mingo@redhat.com, will@kernel.org, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, punit.agrawal@bytedance.com, lstoakes@gmail.com, peterjung1337@gmail.com, rientjes@google.com, chriscli@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, rppt@kernel.org, jannh@google.com, shakeelb@google.com, tatashin@google.com, edumazet@google.com, gthelen@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20230706011400.2949242-1-surenb@google.com> <20230706011400.2949242-2-surenb@google.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20230706011400.2949242-2-surenb@google.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4F91120013 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: gyj6epemzsf4mzk8dmfbrhgyzam7o84g X-HE-Tag: 1688649656-47227 X-HE-Meta: U2FsdGVkX1/C3n09eP8zPfhDBDs0Dc2eBGZ1OWgCL9laStBsj2VzagsqDL/9g4cOehBZpdlYXuJhRnSbS5bMQ7onrO47SE+mtikjdho/RprW8pFU/CBfWuAO611N24x6IKUCEFgRQSrkvOubUUDeU1spy0lUkUBYNwyZW/kiocDSyiD+rB7Xdh+EYL/waJlku0pMl4u94i6IxXVHHT/WSU/i+SCYnC+k86r+3cbrsBcCPdbBax5E+6xuDWAz1Kjt1zxkJzYB4pMPVHXccopR6O+L+mi/mFK639DIWypmbFKklkLgrj+DrMQrqrLXP8o1npBRTbZrFMhESzaTk6p1p3k8dlmx6CaXjjGnJYZXrJ3jV+lB/gLQXUbmjTmIgddRcRrU46W5Q0NERHYe7jl8f06NvLFz5KK14Q1DyIP2c6B/vMmhJhh/B1BLUKchlAp2PV951mh3EnaLFN7byFrZddILK5fHuz0d/N9D7Z8yDYP/X+7UMAcoKzXUWcbu6sCgbP9zvkwWfiGwoAwzC7ILM54KHGI+s99eh7f/9ECjwYnE8SHp7M60XCFhg8NrwRU5y16A6Di1HWULOCWRSxtlRVCbwiRw7PI2oGutsRyH6GkD59raTjC+lWTiP4OrkQ0e1ytuHHvWxZigNYqH3H2ez12xSfy7kf6723jcNBPrhEI792+eTBh4x40EbSu64pbP8Welrk6G8o90i+E0ln6bLti/XJVFKiGofeJW2SArk22+x91A8S2goMFdA2l0RMOqX5kqYu87tKd02eQYQLbLFNGALa2ZPEUAGjN9XokncZT/2Z6yEhXy9q0ekP5A43VcS9iU8zSmNoy7fZVnU1ctSO3WTLZNZ9kg5qowAauNm383tPCmxZ3PIYNaV4moZkyNTHTueI7+pGBkPSuKqszum/H63IB+fJax/YRk7Im55nEqRIP2ZaQT52/tunoSp3Y/LXSiYf8KavnyWNKuMuQ GHf4CqUK AfIBH0YEbwsUSBFGFfZrxxRg+Fu1hh6IMBTZJPauFs5TcfW5dIUpifCjVOxHcQbaFIO21uMGL70J8BMxXd8QfpT2EGPq6as6hZntcrhIBc6ScB9+qQN8Rlp//qZx1NuccoTEh1k/cJJGZ8FRV0YU01oK0D7iXNHfkFxWPPlNMpDgIiLqpl3gnhNmFLTB0NnB0JryUCfV1S1ws5AODk8Vj/ah7ZEID08AmrOdsYlE9Fu2F8EAce+T2RptY472zla3Y/CDy8vEwBXUBC9cBbde38FRY+1Kttt5yQfqx9ciF28lAAgpOClYWNz8E+T9v1BzD4foRFP9rrd1CxiTI/E3C0RfP5/lQXhZC+4rPgg1EKK91aqg/lpZi33R87EStuVLBubVJ52gyBIXf2EFlcrM+DM8aqQt8wIrN+eoDSUGRETMrZDpTUc7uXytoXMoKaDnCruD0BY9mMzX//S0Oyh6hvaY00mUa1XoCY1QItkfij9NinuASFbIZ/R2/vWI+wOphojyuUzkL/pbwXO5Zq3SkQ5jufA5aB4tBBAYSVwlYHYzC2lNndKvgN2s47I3bkr/RlZeFZH2gXNr7TMjrr7sI/fA59BXpwyyxPEAQSTWZg+wkgRaWDPitkMjBJaLvIA7TygKvDPsD8fBNyhZoiZbiKXrdonuJBufXdg2B 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 06.07.23 03:13, Suren Baghdasaryan wrote: > When forking a child process, parent write-protects an anonymous page > and COW-shares it with the child being forked using copy_present_pte(). > Parent's TLB is flushed right before we drop the parent's mmap_lock in > dup_mmap(). If we get a write-fault before that TLB flush in the parent, > and we end up replacing that anonymous page in the parent process in > do_wp_page() (because, COW-shared with the child), this might lead to > some stale writable TLB entries targeting the wrong (old) page. > Similar issue happened in the past with userfaultfd (see flush_tlb_page() > call inside do_wp_page()). > Lock VMAs of the parent process when forking a child, which prevents > concurrent page faults during fork operation and avoids this issue. > This fix can potentially regress some fork-heavy workloads. Kernel build > time did not show noticeable regression on a 56-core machine while a > stress test mapping 10000 VMAs and forking 5000 times in a tight loop > shows ~7% regression. If such fork time regression is unacceptable, > disabling CONFIG_PER_VMA_LOCK should restore its performance. Further > optimizations are possible if this regression proves to be problematic. > > Suggested-by: David Hildenbrand > Reported-by: Jiri Slaby > Closes: https://lore.kernel.org/all/dbdef34c-3a07-5951-e1ae-e9c6e3cdf51b@kernel.org/ > Reported-by: Holger Hoffstätte > Closes: https://lore.kernel.org/all/b198d649-f4bf-b971-31d0-e8433ec2a34c@applied-asynchrony.com/ > Reported-by: Jacob Young > Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217624 > Fixes: 0bff0aaea03e ("x86/mm: try VMA lock-based page fault handling first") > Cc: stable@vger.kernel.org > Signed-off-by: Suren Baghdasaryan Acked-by: David Hildenbrand Feel free to keep my ACK on minor changes. -- Cheers, David / dhildenb