mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Nigel Cunningham <ncunningham@linuxmail.org>,
	Hu Gang <hugang@soulinfo.com>
Subject: Re: [RFC][PATCH] swsusp: do not use higher order allocations on resume [update 2]
Date: Mon, 7 Feb 2005 17:23:16 +0100	[thread overview]
Message-ID: <20050207162316.GA8299@elf.ucw.cz> (raw)
In-Reply-To: <200502071208.50001.rjw@sisk.pl>

Hi!

> The (updated) patch follows.

Okay, few comments...


> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> 
> diff -Nru linux-2.6.11-rc3-mm1-orig/arch/i386/power/swsusp.S linux-2.6.11-rc3-mm1/arch/i386/power/swsusp.S
> --- linux-2.6.11-rc3-mm1-orig/arch/i386/power/swsusp.S	2004-12-24 22:34:31.000000000 +0100
> +++ linux-2.6.11-rc3-mm1/arch/i386/power/swsusp.S	2005-02-05 20:57:03.000000000 +0100
> @@ -28,28 +28,28 @@
>  	ret
>  
>  ENTRY(swsusp_arch_resume)
> -	movl $swsusp_pg_dir-__PAGE_OFFSET,%ecx
> -	movl %ecx,%cr3
> +	movl	$swsusp_pg_dir-__PAGE_OFFSET,%ecx
> +	movl	%ecx,%cr3
>  
> -	movl	pagedir_nosave, %ebx
> -	xorl	%eax, %eax
> -	xorl	%edx, %edx
> +	movl	pagedir_nosave, %edx

move copy_loop: here

> +	testl	%edx, %edx
> +	jz	done
>  	.p2align 4,,7
>  
>  copy_loop:
> -	movl	4(%ebx,%edx),%edi
> -	movl	(%ebx,%edx),%esi
> +	movl	(%edx), %esi
> +	movl	4(%edx), %edi
>  
>  	movl	$1024, %ecx
>  	rep
>  	movsl
>  
> -	incl	%eax
> -	addl	$16, %edx
> -	cmpl	nr_copy_pages,%eax
> -	jb copy_loop
> +	movl	12(%edx), %edx
> +	testl	%edx, %edx
> +	jnz	copy_loop

And do unconditional jump here? Also, 12(%edx)... Could it be handled
using asm-offsets, like on x86-64?

> +static void __init free_eaten_memory(void) {

Please put { at new line.

> +	for_each_pbe(p, pblist)
> +		p->address = 0UL;
> +
> +	for_each_pbe(p, pblist) {
> +		p->address = get_usable_page(GFP_ATOMIC);
> +		if(!p->address)

I'd put space between if and (. And probably do the same for
for_each_pbe... it behaves like a while.

> @@ -966,45 +1018,52 @@
>  					zone->zone_start_pfn));
>  	}
>  
> -	/* Clear orig address */
> +	/* Clear orig addresses */
>  
> -	for(i = 0, p = pagedir_nosave; i < nr_copy_pages; i++, p++) {
> +	for_each_pbe(p, pblist)
>  		ClearPageNosaveFree(virt_to_page(p->orig_address));
> -	}
>  
> -	if (!does_collide_order((unsigned long)old_pagedir, pagedir_order)) {
> -		printk("not necessary\n");
> -		return check_pagedir();
> -	}
> +	tail = pblist + PB_PAGE_SKIP;
>  
> -	while ((m = (void *) __get_free_pages(GFP_ATOMIC, pagedir_order)) != NULL) {
> -		if (!does_collide_order((unsigned long)m, pagedir_order))
> -			break;
> -		eaten_memory = m;
> -		printk( "." ); 
> -		*eaten_memory = c;
> -		c = eaten_memory;
> -	}
> +	/* Relocate colliding pages */
>  
> -	if (!m) {
> -		printk("out of memory\n");
> -		ret = -ENOMEM;
> -	} else {
> -		pagedir_nosave =
> -			memcpy(m, old_pagedir, PAGE_SIZE << pagedir_order);
> +	for_each_pb_page(pbpage, pblist) {
> +		if (does_collide_order((unsigned long)pbpage, 0)) {
> +			m = (void *)get_usable_page(GFP_ATOMIC | __GFP_COLD);
> +			if (!m) {
> +				error = -ENOMEM;
> +				break;
> +			}
> +			memcpy(m, (void *)pbpage, PAGE_SIZE);
> +			if (pbpage == pblist)
> +				pblist = (struct pbe *)m;
> +			else
> +				tail->next = (struct pbe *)m;
> +
> +			free_page((unsigned long)pbpage);

Uh, you free it so that you can allocate it again, and again find out
that it is unusable? It will probably end up on list of unusable
pages, so it is okay, but...

> +			pbpage = (struct pbe *)m;
> +
> +			/* We have to link the PBEs again */
> +
> +			for (p = pbpage ; p < pbpage + PB_PAGE_SKIP ; p++)

I'd avoid " " before ;. 

> +		p = pbe;
> +		pbe += PB_PAGE_SKIP;
> +		do
> +			p->next = p + 1;
> +		while (p++ < pbe);

I've already seen this code somewhere around in different
variant... Perhaps you want to make it inline function?

> +		p->next = NULL;
> +		pr_debug("swsusp: Read %d pages, allocated %d PBEs\n", i, num);
> +		error = (i != swsusp_info.pagedir_pages); /* a sanity check */

If it is sanity check, do BUG_ON().
									

> +	if(!(p = read_pagedir()))
> +		return -EFAULT;

Is the value used? By using pointers instead of normal ints, you kill
possibility of meaningfull error reporting...

> +	if(!(pagedir_nosave = swsusp_pagedir_relocate(p)))
> +		return -ENOMEM;

Same here.
								Pavel
-- 
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!

  parent reply	other threads:[~2005-02-07 16:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-30 23:19 [RFC][PATCH] swsusp: do not use higher order memory allocations on resume Rafael J. Wysocki
2005-01-31 23:19 ` [RFC][PATCH] swsusp: do not use higher order memory allocations [update] Rafael J. Wysocki
2005-02-07 11:08 ` [RFC][PATCH] swsusp: do not use higher order allocations on resume [update 2] Rafael J. Wysocki
2005-02-07 14:27   ` Pavel Machek
2005-02-07 14:45     ` Rafael J. Wysocki
2005-02-07 16:23   ` Pavel Machek [this message]
2005-02-08 18:29     ` Rafael J. Wysocki
2005-02-08 19:10       ` Pavel Machek
2005-02-08 22:28         ` Rafael J. Wysocki
2005-02-08 22:42       ` Pavel Machek
2005-02-08 23:22         ` Rafael J. Wysocki
2005-02-13  5:54           ` hugang
2005-02-13  6:11             ` hugang

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=20050207162316.GA8299@elf.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=hugang@soulinfo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ncunningham@linuxmail.org \
    --cc=rjw@sisk.pl \
    /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

all inboxes | Powered by JetHome®