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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CF8AC433EF for ; Thu, 7 Oct 2021 12:13:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 225496125F for ; Thu, 7 Oct 2021 12:13:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 225496125F 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 9EB3A6B006C; Thu, 7 Oct 2021 08:13:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 99A936B0071; Thu, 7 Oct 2021 08:13:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 861E9900002; Thu, 7 Oct 2021 08:13:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0158.hostedemail.com [216.40.44.158]) by kanga.kvack.org (Postfix) with ESMTP id 7A9F96B006C for ; Thu, 7 Oct 2021 08:13:21 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2F17D18129449 for ; Thu, 7 Oct 2021 12:13:21 +0000 (UTC) X-FDA: 78669531402.27.212CD3C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id CDD1D700803A for ; Thu, 7 Oct 2021 12:13:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633608800; 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=lYg3DKnYjpKLFoiMv++O6QIhF4RIhnoeDD7AJ3wTVUk=; b=LwbMpvOS8FGuFu4STfDkY0TqyPK2q8hJj/ncpVYdUcX0ftZqBv+/T067iiz9duWOkhzvo1 4OIISsRZ+dRfU2DDorgHzWxyQ5q+qq40ztdbKM3HFdNdI3FFV0Q32UpXf42YySYj/mRjNx n41aBB7oIlPM1W3ZrEpWB/AR3W6KLZc= 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-550-KnALINr_PQmcGpAozt1_IQ-1; Thu, 07 Oct 2021 08:13:03 -0400 X-MC-Unique: KnALINr_PQmcGpAozt1_IQ-1 Received: by mail-wr1-f70.google.com with SMTP id h11-20020adfa4cb000000b00160c791a550so4347949wrb.6 for ; Thu, 07 Oct 2021 05:13:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=lYg3DKnYjpKLFoiMv++O6QIhF4RIhnoeDD7AJ3wTVUk=; b=nvAslGnye8mbla/emoRttlS+dKttgh+assOHkC5Xx/ujI+Yg448o7mjXorqOvfLuUb 6UVpc7pO1f4fRvdmpZAybNvM5YIj2/m6oC9kRNX5YG87ExEyJ8Z5yHLj7hNtJmSDcc9z tb0FKpcfiQ1ETFuQFwtSoBgsbwdGwIw6XKErCkYLohj5MYgBTPnetdzXySQQyRYjvlxB IbuGpMeXlojL63s1A8OlibyJKThA0ru05GWEkVMgUf/OjMBRaHoQssJ2WT0mkdWO0B+A qG4A+syrm0as2iZvl7qYJ7/G4+M4e0N2lArHsWa5svMWBYboBnDPVI6ojcn1ac0ySIOg gODQ== X-Gm-Message-State: AOAM533pQAzsddMuf/4i5/j8cldLgIFL+8GKDcZlhZqFZ27lFMPR997f K/wy2kGn4NuJlHDgzGVVPOBAfLm90l3u9zSYkm2JMyziQAXh7YI6mpHrOl5A9IESqNS9dnnITgZ uI/EmBs1l38Y= X-Received: by 2002:a5d:64a6:: with SMTP id m6mr5005178wrp.282.1633608781914; Thu, 07 Oct 2021 05:13:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1+G511oTofFcZIavyp24Pc9rD74REUvRo1Zz07AsPo9+OrEizszsrDH3N7xzVcvvCViKnSQ== X-Received: by 2002:a5d:64a6:: with SMTP id m6mr5005133wrp.282.1633608781695; Thu, 07 Oct 2021 05:13:01 -0700 (PDT) Received: from [192.168.3.132] (p5b0c6886.dip0.t-ipconnect.de. [91.12.104.134]) by smtp.gmail.com with ESMTPSA id v16sm2403012wrq.39.2021.10.07.05.13.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 07 Oct 2021 05:13:01 -0700 (PDT) Subject: Re: [PATCH 2/2] mm/mprotect: do not flush on permission promotion To: Nadav Amit , Andrew Morton Cc: LKML , Linux-MM , Peter Xu , Nadav Amit , Andrea Arcangeli , Andrew Cooper , Andy Lutomirski , Dave Hansen , Peter Zijlstra , Thomas Gleixner , Will Deacon , Yu Zhao , Nick Piggin , x86@kernel.org References: <20210925205423.168858-1-namit@vmware.com> <20210925205423.168858-3-namit@vmware.com> From: David Hildenbrand Organization: Red Hat Message-ID: <5485fae5-3cd6-9dc3-0579-dc8aab8a3de1@redhat.com> Date: Thu, 7 Oct 2021 14:13:00 +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: <20210925205423.168858-3-namit@vmware.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: CDD1D700803A X-Stat-Signature: egditocrt9xarsqu87muhwnn85sq6kkd Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LwbMpvOS; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf27.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com X-HE-Tag: 1633608800-559770 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 25.09.21 22:54, Nadav Amit wrote: > From: Nadav Amit > > Currently, using mprotect() to unprotect a memory region or uffd to > unprotect a memory region causes a TLB flush. At least on x86, as > protection is promoted, no TLB flush is needed. > > Add an arch-specific pte_may_need_flush() which tells whether a TLB > flush is needed based on the old PTE and the new one. Implement an x86 > pte_may_need_flush(). > > For x86, PTE protection promotion or changes of software bits does > require a flush, also add logic that considers the dirty-bit. Changes to > the access-bit do not trigger a TLB flush, although architecturally they > should, as Linux considers the access-bit as a hint. Is the added LOC worth the benefit? IOW, do we have some benchmark that really benefits from that? -- Thanks, David / dhildenb