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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D540C433EF for ; Mon, 20 Jun 2022 04:18:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232394AbiFTEOo (ORCPT ); Mon, 20 Jun 2022 00:14:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231775AbiFTEOk (ORCPT ); Mon, 20 Jun 2022 00:14:40 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A4E23655D for ; Sun, 19 Jun 2022 21:14:39 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 273441042; Sun, 19 Jun 2022 21:14:39 -0700 (PDT) Received: from [192.168.0.110] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 92A4F3F7D7; Sun, 19 Jun 2022 21:14:36 -0700 (PDT) Message-ID: <8da7bf08-0234-2d57-afb0-012b94fd8889@arm.com> Date: Mon, 20 Jun 2022 09:44:27 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH V3 2/2] mm/mmap: Drop generic protection_map[] array Content-Language: en-US To: "hch@infradead.org" , Christophe Leroy Cc: "linux-mm@kvack.org" , Andrew Morton , "linux-kernel@vger.kernel.org" , kernel test robot , Christoph Hellwig References: <20220616040924.1022607-1-anshuman.khandual@arm.com> <20220616040924.1022607-3-anshuman.khandual@arm.com> <7cf922f4-2367-e173-0280-cb498391d9f7@csgroup.eu> <7c72a97f-d7d4-db27-faa5-fec01673cca7@arm.com> <43205917-0517-4e45-6fbf-4fc849fb0325@csgroup.eu> From: Anshuman Khandual In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/17/22 13:30, hch@infradead.org wrote: > On Fri, Jun 17, 2022 at 05:48:11AM +0000, Christophe Leroy wrote: >> Is it a good idea to duplicate vm_get_page_prot() in each architecture ? > > It is a completely trivial array index. And I really like the idea > of not having the protection_map in common code - it really is an > implementation detail. But what we could do is something like > > #define DECLARE_VM_GET_PAGE_PROT \ > pgprot_t vm_get_page_prot(unsigned long vm_flags) \ > { \ > return protection_map[vm_flags & \ > (VM_READ | VM_WRITE | VM_EXEC | VM_SHARED)]; \ > } \ > EXPORT_SYMBOL(vm_get_page_prot); > > as a helper for the architectures. Agreed, this will ensure the exact same implementation for all platforms (except those custom vm_get_page_prot), without deviations and mistakes.