Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1303172pxb; Thu, 7 Oct 2021 05:14:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtRQ4GVlySHw1dSm2U/m4MjTfySOLj7lDx8ZxNuz9qFe9FLjKHD4gPYixfWpzEupjSARjz X-Received: by 2002:a17:903:1ca:b0:13e:f367:9361 with SMTP id e10-20020a17090301ca00b0013ef3679361mr3554925plh.3.1633608866721; Thu, 07 Oct 2021 05:14:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633608866; cv=none; d=google.com; s=arc-20160816; b=tRLy10CyNm6XXn87MoSrYLB2OpUAZmqG3rMIsv6MNVS7btlK+uzrYTTVfHdi6uBxNA TTUcMPIdUIArqhEhRRccL8M2c71aPwYkV1v+nwWFXbG2FncOQsmnMIVfNN3iv6bSFyOv X4om2SHgdGAGacKE4G13x+8a+Fx0gZcDOfTMJCowpwD5Oak6H1F0HdB14xoUNVM/z0mf xoL9RZ4PIlxfnmORyH86kBe1Dd9RX6+D6QAQmhzfsPjOtrS/7EYjUea2Y+ZxLmlWL/Mc jHHTLYFrJHFECTQoUmaiGuJXvN4Uobtks4PHphfRQeyNmCnNLsJpcnxeEg2VwDnqkC/q pfUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=lYg3DKnYjpKLFoiMv++O6QIhF4RIhnoeDD7AJ3wTVUk=; b=0OK/BAo6Hmwo2ZkW8tKmdgLVIF4aBL648Cc0cgMzEb4PSmzZaI5l9LwCntNlRmZOh9 /wnC+oA4SDhQkTmNgOBKcIZSh0BeV4AVu4DVbbK7NSShuqphAN4ao8wWKn6sDF20aRWd wSDAxGKevq/6v6Ax9XWpo2fuRdNPaSO05c1QgHrXKQ6MxmJuiGIjvIwLum5WtAXjNp7G ng8sDVgPdAaElX/gr31NvX7M9WumXxeKw0Jh8IIAg7rsoUJjGJvUYSmhdX6PrhZXHZKo J32TT5F9jeO8mI2OF4kC1yohAug2dF9/GJuDBdT1eYvRe4LtLYNqMEGQ/QvV3XH3eeEJ P6Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WlJ9iZK5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si8514504plk.357.2021.10.07.05.14.11; Thu, 07 Oct 2021 05:14:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WlJ9iZK5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241199AbhJGMPN (ORCPT + 99 others); Thu, 7 Oct 2021 08:15:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41390 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241186AbhJGMPM (ORCPT ); Thu, 7 Oct 2021 08:15:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633608798; 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=WlJ9iZK5AR3ogTSnmFaG0ti1/ACCOpEyfHPv6xqAznVer0APJuNx+cItE2vUeLQ5i3jOXC HSQF9z67hmsOdBEh21l/bkyjSyXb5AjM8NwIE831s5nzx66qg+hD6bDI4oob+sCV6JkA/N vAFTR2yNJ13ivzZO8TXpp+Y5cT0mFpk= 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-496-REGPK3QXMc6tPuurgf8Rrg-1; Thu, 07 Oct 2021 08:13:03 -0400 X-MC-Unique: REGPK3QXMc6tPuurgf8Rrg-1 Received: by mail-wr1-f70.google.com with SMTP id l6-20020adfa386000000b00160c4c1866eso4525856wrb.4 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=UhtJAaozlNgQm5lQVl8MS/peOJ/xKHsvkQnFCfiiB3WoUZ/Us1FoZUv9PiNoCYQ4ot 6DKYB15yA5Lw8VKc9LRe5j06g9JzerwCWXWfQLAhg2uucZcF/EOvb3GOuF2MecVsq3Wc u0la3V6PfplxqNRdyK3epjgF10pFIUBS7rHikIWNgbY2aRUiP9601laV/dIRySk5NN7p KllANGrKgsfmN0xXQokbhMuW7FMZam1Y7UoDs7DKSzm6o4YKQsF0Wd3SnYao36BgCoSx i9Ho4pV1pneXdWD2zEoy0UiDJGm9f9JHWPOKBzZMVyy7xM9x7yMdcm/6sxx4OVjiqyb2 mA0w== X-Gm-Message-State: AOAM531AZZ6uPUroEvzczkx0PZzKSCTlNAeWQnxBXlsawmIZSWU59QlH FjD2NOURNyXQ4woxH0h4+g7CBG2zO5CQts971CnCgbNY9RRXbdVzDwf4676Rzjh9gf8zuZDea/c kcQLR9EWXCR8HzWtvdcVb/hsA X-Received: by 2002:a5d:64a6:: with SMTP id m6mr5005161wrp.282.1633608781865; Thu, 07 Oct 2021 05:13:01 -0700 (PDT) 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> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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