Skip to contentSkip to conversation

Replacing memset(<addr>,0,PAGE_SIZE) with clear_page() in kernel/kexec.c

PATCH In review Shani Moideen 7 participants 7 messages May 8, 2007 – Jul 10, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Replacing memset(<addr>,0,PAGE_SIZE) with clear_page() in kernel/kexec.c

Hi,

Replacing memset(<addr>,0,PAGE_SIZE) with clear_page() in kernel/kexec.c

----

thanks.

kernel/kexec.c +1 -1
index 2a59c8a..1a1afdd 100644
@@ -787,7 +787,7 @@ static int kimage_load_normal_segment(struct kimage *image,
 
                ptr = kmap(page);
                /* Start with a clear page */
-               memset(ptr, 0, PAGE_SIZE);
+               clear_page(ptr);
                ptr += maddr & ~PAGE_MASK;
                mchunk = PAGE_SIZE - (maddr & ~PAGE_MASK);
                if (mchunk > mbytes)
Signature · 1 line
Shani 
#2 lore raw
Quoted 3 lines · Shani Moideen
Quoted 3 lines
                ptr = kmap(page);
kernel/kexec.c +1 -1
-               memset(ptr, 0, PAGE_SIZE);
+               clear_page(ptr);
Quoted 1 line · Michael Tokarev

I wonder if it's worth to invent kzmap() or something like that... ;)

I am counting 59 kmap + memset pairs in the kernel, so perhaps it is worth it to reduce kernel text size.
_______________________________________________
Kernel-janitors mailing list [email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

#3 lore raw
Quoted 10 lines · Pekka Enberg
Quoted 3 lines · Shani Moideen
Quoted 3 lines
                ptr = kmap(page);
kernel/kexec.c +1 -1
-               memset(ptr, 0, PAGE_SIZE);
+               clear_page(ptr);
Quoted 1 line · Michael Tokarev

I wonder if it's worth to invent kzmap() or something like that... ;)

I am counting 59 kmap + memset pairs in the kernel, so perhaps it is worth it to reduce kernel text size.

Stuff of the sort already exists. Look for clear_highpage(), clear_user_highpage() and memclear_highpage_flush (recently renamed to zero_user_page, see -mm). But they all use kmap_atomic() -- kmap() variants would have to be added. Also, they're all inlines, so I'm not sure you'd be able to cut down text size, but still getting rid of open-coding is always good.
_______________________________________________
Kernel-janitors mailing list [email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

#4 lore raw
Quoted 12 lines · Satyam Sharma
Quoted 10 lines · Pekka Enberg
Quoted 3 lines · Shani Moideen
Quoted 3 lines
                ptr = kmap(page);
kernel/kexec.c +1 -1
-               memset(ptr, 0, PAGE_SIZE);
+               clear_page(ptr);
Quoted 1 line · Michael Tokarev

I wonder if it's worth to invent kzmap() or something like that... ;)

I am counting 59 kmap + memset pairs in the kernel, so perhaps it is worth it to reduce kernel text size.

Quoted 6 lines

Stuff of the sort already exists. Look for clear_highpage(), clear_user_highpage() and memclear_highpage_flush (recently renamed to zero_user_page, see -mm). But they all use kmap_atomic() -- kmap() variants would have to be added. Also, they're all inlines, so I'm not sure you'd be able to cut down text size, but still getting rid of open-coding is always good.

In this instance a clear_page variant should be ok. The combined variants are likely not because I use the mapping after it is cleared.

Eric

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

#5 lore raw

[KJ] Re: [KJ PATCH] Replacing memset(<addr>, 0,

In reply to Michael Tokarev

Regards,

Steve Newberger
QLogic Corporation
[email protected]

Please visit our web @
http://support.qlogic.com/

---- Original Message ----
From: [email protected]
Sent: 17-Jun-2007 22:33:56
To: [email protected]
Cc: [email protected]; [email protected]
Subject: [KJ PATCH] Replacing memset(&lt;addr&gt;,0,PAGE_SIZE) with clear_page(&lt;addr&gt;) in drivers/infiniband/hw/ipath/ipath_driver.c

Replacing memset(<addr>,0,PAGE_SIZE) with clear_page(<addr>) in drivers/infiniband/hw/ipath/ipath_driver.c

----

drivers/infiniband/hw/ipath/ipath_driver.c +1 -1
index e3a2232..417e3ca 100644
@@ -1509,7 +1509,7 @@ int ipath_create_rcvhdrq(struct ipath_devdata *dd,
 
 	/* clear for security and sanity on each use */
 	memset(pd->port_rcvhdrq, 0, pd->port_rcvhdrq_size);
-	memset(pd->port_rcvhdrtail_kvaddr, 0, PAGE_SIZE);
+	clear_page(pd->port_rcvhdrtail_kvaddr);
 
 	/*
 	 * tell chip each time we init it, even if we are re-using previous
Signature · 8 lines
Shani 


The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
 
www.wipro.com

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

#6 lore raw

[KJ] Re: [KJ PATCH] Replacing memset(<addr>, 0,

In reply to Michael Tokarev

thanks, I applied both mthca patches as one commit.
_______________________________________________
REMINDER: this mailing list moved to vger.kernel.org and current one will be discontinued soon. To resubscribe, send email to [email protected] with
&quot;subscribe kernel-janitors&quot; in message body and follow instructions.

Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors