linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: Dave Hansen <haveblue@us.ibm.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-mm@kvack.org
Subject: Re: [RFC][PATCH] allow bigger PAGE_OFFSET with PAE
Date: Wed, 8 Jan 2003 14:44:45 -0800	[thread overview]
Message-ID: <20030108224445.GE23814@holomorphy.com> (raw)
In-Reply-To: <20030108220533.GD23814@holomorphy.com>

On Tue, Jan 07, 2003 at 12:06:38PM -0800, Dave Hansen wrote:
>>>> Also, this gets the kernel's pagetables right, but neglects 
>>>> userspace's for now.  pgd_alloc() needs to be fixed to allocate 
>>>> another PMD, if the split isn't PMD-alighed.

William Lee Irwin III wrote:
>>> Um, that should be automatic when USER_PTRS_PER_PGD is increased.

On Wed, Jan 08, 2003 at 01:04:23PM -0800, Dave Hansen wrote:
>> Nope, you need a little bit more.  pgd_alloc() relies on its memcpy() 
>> to provide the kernel mappings.  After the last user PMD is allocated, 
>> you still need to copy the kernel-shared part of it in.

On Wed, Jan 08, 2003 at 02:05:33PM -0800, William Lee Irwin III wrote:
> See the bit about rounding up. Then again, the pmd entries don't get
> filled in by any of that...

Okay, basically:

#define __USER_PTRS_PER_PGD	(TASK_SIZE/PGDIR_SIZE)
#define PARTIAL_PGD	(TASK_SIZE > __USER_PTRS_PER_PGD*PGDIR_SIZE ? 1 : 0)
#define PARTIAL_PMD	((TASK_SIZE % PGDIR_SIZE)/PMD_SIZE)
#define USER_PTRS_PER_PGD	(PARTIAL_PGD + __USER_PTRS_PER_PGD)

then


pgd_t *pgd_alloc(struct mm_struct *mm)
{
	int i;
	pgd_t *pgd = kmem_cache_alloc(pae_pgd_cachep, GFP_KERNEL);

	if (pgd) {
		for (i = 0; i < USER_PTRS_PER_PGD; i++) {
			unsigned long pmd = __get_free_page(GFP_KERNEL);
			if (!pmd)
				goto out_oom;
			clear_page(pmd);
			set_pgd(pgd + i, __pgd(1 + __pa(pmd)));
		}

		if (USER_PTRS_PER_PGD < PTRS_PER_PGD)
			memcpy(pgd + USER_PTRS_PER_PGD,
				swapper_pg_dir + USER_PTRS_PER_PGD,
				(PTRS_PER_PGD-USER_PTRS_PER_PGD)*sizeof(pgd_t));

		if (PARTIAL_PGD) {
			pgd_t *kpgd, *upgd;
			pmd_t *kpmd, *upmd;

			kpgd = pgd_offset_k(TASK_SIZE);
			upgd = pgd_offset(mm, TASK_SIZE);
			kpmd = pmd_offset(kpgd, TASK_SIZE);
			upmd = pmd_offset(upgd, TASK_SIZE);

			memcpy(upmd, kpmd, (PTRS_PER_PMD-PARTIAL_PMD)*sizeof(pmd_t));

		}
	}
	return pgd;
out_oom:
	for (i--; i >= 0; i--)
		free_page((unsigned long)__va(pgd_val(pgd[i])-1));
	kmem_cache_free(pae_pgd_cachep, pgd);
	return NULL;
}

etc.
--
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/

      reply	other threads:[~2003-01-08 22:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-07 20:06 Dave Hansen
2003-01-07 23:37 ` William Lee Irwin III
2003-01-08 21:04   ` Dave Hansen
2003-01-08 22:05     ` William Lee Irwin III
2003-01-08 22:44       ` William Lee Irwin III [this message]

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=20030108224445.GE23814@holomorphy.com \
    --to=wli@holomorphy.com \
    --cc=haveblue@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox