All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Dave Hansen <dave@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Gleb Natapov <gleb@redhat.com>, Avi Kivity <avi@redhat.com>,
	Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org, Marcelo Tosatti <mtosatti@redhat.com>
Subject: Re: [RFCv3][PATCH 1/3] create slow_virt_to_phys()
Date: Tue, 15 Jan 2013 11:46:28 -0800	[thread overview]
Message-ID: <50F5B214.5060604@zytor.com> (raw)
In-Reply-To: <20130109185904.DD641DCE@kernel.stglabs.ibm.com>

On 01/09/2013 10:59 AM, Dave Hansen wrote:
> +	switch (level) {
> +	case PG_LEVEL_4K:
> +		psize = PAGE_SIZE;
> +		pmask = PAGE_MASK;
> +		break;
> +	case PG_LEVEL_2M:
> +		psize = PMD_PAGE_SIZE;
> +		pmask = PMD_PAGE_MASK;
> +		break;
> +#ifdef CONFIG_X86_64
> +	case PG_LEVEL_1G:
> +		psize = PUD_PAGE_SIZE;
> +		pmask = PUD_PAGE_MASK;
> +		break;
> +#endif
> +	default:
> +		BUG();
> +	}

I object to this switch statement.  If we are going to create new 
primitives, let's create a primitive that embody this and put it in 
pgtypes_types.h, especially since it is simply an algorithmic operation:

static inline unsigned long page_level_size(int level)
{
	return (PAGE_SIZE/PGDIR_SIZE) << (PGDIR_SHIFT*level);
}
static inline unsigned long page_level_shift(int level)
{
	return (PAGE_SHIFT-PGDIR_SHIFT) + (PGDIR_SHIFT*level);
}

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: "H. Peter Anvin" <hpa@zytor.com>
To: Dave Hansen <dave@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Gleb Natapov <gleb@redhat.com>, Avi Kivity <avi@redhat.com>,
	Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org, Marcelo Tosatti <mtosatti@redhat.com>
Subject: Re: [RFCv3][PATCH 1/3] create slow_virt_to_phys()
Date: Tue, 15 Jan 2013 11:46:28 -0800	[thread overview]
Message-ID: <50F5B214.5060604@zytor.com> (raw)
In-Reply-To: <20130109185904.DD641DCE@kernel.stglabs.ibm.com>

On 01/09/2013 10:59 AM, Dave Hansen wrote:
> +	switch (level) {
> +	case PG_LEVEL_4K:
> +		psize = PAGE_SIZE;
> +		pmask = PAGE_MASK;
> +		break;
> +	case PG_LEVEL_2M:
> +		psize = PMD_PAGE_SIZE;
> +		pmask = PMD_PAGE_MASK;
> +		break;
> +#ifdef CONFIG_X86_64
> +	case PG_LEVEL_1G:
> +		psize = PUD_PAGE_SIZE;
> +		pmask = PUD_PAGE_MASK;
> +		break;
> +#endif
> +	default:
> +		BUG();
> +	}

I object to this switch statement.  If we are going to create new 
primitives, let's create a primitive that embody this and put it in 
pgtypes_types.h, especially since it is simply an algorithmic operation:

static inline unsigned long page_level_size(int level)
{
	return (PAGE_SIZE/PGDIR_SIZE) << (PGDIR_SHIFT*level);
}
static inline unsigned long page_level_shift(int level)
{
	return (PAGE_SHIFT-PGDIR_SHIFT) + (PGDIR_SHIFT*level);
}

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


  parent reply	other threads:[~2013-01-15 19:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-09 18:59 [RFCv3][PATCH 1/3] create slow_virt_to_phys() Dave Hansen
2013-01-09 18:59 ` Dave Hansen
2013-01-09 18:59 ` [RFCv3][PATCH 2/3] fix kvm's use of __pa() on percpu areas Dave Hansen
2013-01-09 18:59   ` Dave Hansen
2013-01-15 18:38   ` Rik van Riel
2013-01-15 18:38     ` Rik van Riel
2013-01-09 18:59 ` [RFCv3][PATCH 3/3] make DEBUG_VIRTUAL work earlier in boot Dave Hansen
2013-01-09 18:59   ` Dave Hansen
2013-01-15 17:04 ` [RFCv3][PATCH 1/3] create slow_virt_to_phys() Rik van Riel
2013-01-15 19:46 ` H. Peter Anvin [this message]
2013-01-15 19:46   ` H. Peter Anvin
2013-01-15 22:50   ` Dave Hansen
2013-01-15 22:50     ` Dave Hansen
2013-01-15 23:46     ` H. Peter Anvin
2013-01-15 23:46       ` H. Peter Anvin

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=50F5B214.5060604@zytor.com \
    --to=hpa@zytor.com \
    --cc=avi@redhat.com \
    --cc=dave@linux.vnet.ibm.com \
    --cc=gleb@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.