linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Ira Weiny <ira.weiny@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
	"Edgecombe, Rick P" <rick.p.edgecombe@intel.com>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/5] x86/pkeys: Standardize on u8 for pkey type
Date: Tue, 15 Mar 2022 09:03:26 -0700	[thread overview]
Message-ID: <5b5ae505-84c7-1a46-832a-68bdfd8fd61c@intel.com> (raw)
In-Reply-To: <YjC2jcn7kJKdHrf3@iweiny-desk3>

On 3/15/22 08:53, Ira Weiny wrote:
> On Mon, Mar 14, 2022 at 04:49:12PM -0700, Dave Hansen wrote:
>> On 3/10/22 16:57, ira.weiny@intel.com wrote:
>>> From: Ira Weiny <ira.weiny@intel.com>
>>>
>>> The number of pkeys supported on x86 and powerpc are much smaller than a
>>> u16 value can hold.  It is desirable to standardize on the type for
>>> pkeys.  powerpc currently supports the most pkeys at 32.  u8 is plenty
>>> large for that.
>>>
>>> Standardize on the pkey types by changing u16 to u8.
>>
>> How widely was this intended to "standardize" things?  Looks like it may
>> have missed a few spots.
> 
> Sorry I think the commit message is misleading you.  The justification of u8 as
> the proper type is that no arch has a need for more than 255 pkeys.
> 
> This specific patch was intended to only change x86.  Per that goal I don't see
> any other places in x86 which uses u16 after this patch.
> 
> $ git grep u16 arch/x86 | grep key
> arch/x86/events/intel/uncore_discovery.c:	const u16 *type_id = key;
> arch/x86/include/asm/intel_pconfig.h:	u16 keyid;
> arch/x86/include/asm/mmu.h:	u16 pkey_allocation_map;
> arch/x86/include/asm/pkeys.h:	u16 all_pkeys_mask = ((1U << arch_max_pkey()) - 1);

I was also looking at the generic mm code.

>> Also if we're worried about the type needing to changY or with the wrong
>> type being used, I guess we could just to a pkey_t typedef.
> 
> I'm not 'worried' about it.  But I do think it makes the code cleaner and more
> self documenting.

Yeah, consistency is good.  Do you mind taking a look at how a pkey_t
would look, and also seeing how much core mm code should use it?

  reply	other threads:[~2022-03-15 16:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11  0:57 [PATCH 0/5] Pkey User clean up patches ira.weiny
2022-03-11  0:57 ` [PATCH 1/5] x86/pkeys: Clean up arch_set_user_pkey_access() declaration ira.weiny
2022-03-11  0:57 ` [PATCH 2/5] x86/pkeys: Remove __arch_set_user_pkey_access() declaration ira.weiny
2022-03-11  0:57 ` [PATCH 3/5] powerpc/pkeys: Properly type pkey in init_{i}amr() ira.weiny
2022-03-11  0:57 ` [PATCH 4/5] mm/pkeys: Make pkey unsigned in arch_set_user_pkey_access() ira.weiny
2022-03-11  0:57 ` [PATCH 5/5] x86/pkeys: Standardize on u8 for pkey type ira.weiny
2022-03-14 23:49   ` Dave Hansen
2022-03-15 15:53     ` Ira Weiny
2022-03-15 16:03       ` Dave Hansen [this message]
2022-03-15 16:57         ` Ira Weiny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5b5ae505-84c7-1a46-832a-68bdfd8fd61c@intel.com \
    --to=dave.hansen@intel.com \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=rick.p.edgecombe@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).