From: Matthew Dobson <colpatch@us.ibm.com>
To: kernel-janitors@lists.osdl.org
Cc: manfred@colorfullife.com, Pekka J Enberg <penberg@cs.Helsinki.FI>,
linux-kernel@vger.kernel.org
Subject: [PATCH 3/9] Fix alloc_percpu's args
Date: Thu, 10 Nov 2005 15:59:48 -0800 [thread overview]
Message-ID: <4373DEF4.60100@us.ibm.com> (raw)
In-Reply-To: <4373DD82.8010606@us.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 86 bytes --]
alloc_percpu takes an 'align' argument that is completely ignored. Remove it.
-Matt
[-- Attachment #2: alloc_percpu.patch --]
[-- Type: text/x-patch, Size: 3212 bytes --]
__alloc_percpu and alloc_percpu both take an 'align' argument which is
completely ignored. snmp6_mib_init() in net/ipv6/af_inet6.c attempts to
use it, but it will be ignored. Therefore, remove the 'align' argument
and fixup the lone caller.
Also, remove an unnecessary cpu_possible check in the oom_unwind loop since
kfree() is happy to ignore NULL pointers passed to it.
Signed-off-by: Matthew Dobson <colpatch@us.ibm.com>
Index: linux-2.6.14+slab_cleanup/include/linux/percpu.h
===================================================================
--- linux-2.6.14+slab_cleanup.orig/include/linux/percpu.h 2005-11-10 11:09:37.549880584 -0800
+++ linux-2.6.14+slab_cleanup/include/linux/percpu.h 2005-11-10 11:43:40.218347776 -0800
@@ -33,14 +33,14 @@ struct percpu_data {
(__typeof__(ptr))__p->ptrs[(cpu)]; \
})
-extern void *__alloc_percpu(size_t size, size_t align);
+extern void *__alloc_percpu(size_t size);
extern void free_percpu(const void *);
#else /* CONFIG_SMP */
#define per_cpu_ptr(ptr, cpu) (ptr)
-static inline void *__alloc_percpu(size_t size, size_t align)
+static inline void *__alloc_percpu(size_t size)
{
void *ret = kmalloc(size, GFP_KERNEL);
if (ret)
@@ -55,7 +55,6 @@ static inline void free_percpu(const voi
#endif /* CONFIG_SMP */
/* Simple wrapper for the common case: zeros memory. */
-#define alloc_percpu(type) \
- ((type *)(__alloc_percpu(sizeof(type), __alignof__(type))))
+#define alloc_percpu(type) ((type *)(__alloc_percpu(sizeof(type))))
#endif /* __LINUX_PERCPU_H */
Index: linux-2.6.14+slab_cleanup/mm/slab.c
===================================================================
--- linux-2.6.14+slab_cleanup.orig/mm/slab.c 2005-11-10 11:43:36.926848160 -0800
+++ linux-2.6.14+slab_cleanup/mm/slab.c 2005-11-10 11:43:40.223347016 -0800
@@ -2957,12 +2957,11 @@ EXPORT_SYMBOL(__kmalloc);
* Objects should be dereferenced using the per_cpu_ptr macro only.
*
* @size: how many bytes of memory are required.
- * @align: the alignment, which can't be greater than SMP_CACHE_BYTES.
*/
-void *__alloc_percpu(size_t size, size_t align)
+void *__alloc_percpu(size_t size)
{
int i;
- struct percpu_data *pdata = kmalloc(sizeof(*pdata), GFP_KERNEL);
+ struct percpu_data *pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return NULL;
@@ -2989,11 +2988,8 @@ void *__alloc_percpu(size_t size, size_t
return (void *)(~(unsigned long) pdata);
unwind_oom:
- while (--i >= 0) {
- if (!cpu_possible(i))
- continue;
+ while (--i >= 0)
kfree(pdata->ptrs[i]);
- }
kfree(pdata);
return NULL;
}
Index: linux-2.6.14+slab_cleanup/net/ipv6/af_inet6.c
===================================================================
--- linux-2.6.14+slab_cleanup.orig/net/ipv6/af_inet6.c 2005-11-10 11:09:37.550880432 -0800
+++ linux-2.6.14+slab_cleanup/net/ipv6/af_inet6.c 2005-11-10 11:43:40.224346864 -0800
@@ -596,11 +596,11 @@ snmp6_mib_init(void *ptr[2], size_t mibs
if (ptr == NULL)
return -EINVAL;
- ptr[0] = __alloc_percpu(mibsize, mibalign);
+ ptr[0] = __alloc_percpu(mibsize);
if (!ptr[0])
goto err0;
- ptr[1] = __alloc_percpu(mibsize, mibalign);
+ ptr[1] = __alloc_percpu(mibsize);
if (!ptr[1])
goto err1;
next prev parent reply other threads:[~2005-11-10 23:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-10 23:53 [PATCH 0/9] Cleanup mm/slab.c v2 Matthew Dobson
2005-11-10 23:56 ` [PATCH 1/9] CodingStyle-ify mm/slab.c Matthew Dobson
2005-11-10 23:58 ` [PATCH 2/9] Use 'nid' Matthew Dobson
2005-11-13 20:15 ` Pavel Machek
2005-11-10 23:59 ` Matthew Dobson [this message]
2005-11-11 0:01 ` [PATCH 4/9] Create helper for /proc/slabinfo Matthew Dobson
2005-11-11 0:03 ` [PATCH 5/9] Create helper for kmem_cache_create() Matthew Dobson
2005-11-11 0:04 ` [PATCH 6/9] Cleanup kmem_cache_create() Matthew Dobson
2005-11-11 8:10 ` Ingo Oeser
2005-11-11 18:28 ` Matthew Dobson
2005-11-11 0:05 ` [PATCH 7/9] Cleanup cache_reap() Matthew Dobson
2005-11-11 0:06 ` [PATCH 8/9] Cleanup slabinfo_write() Matthew Dobson
2005-11-11 0:07 ` [PATCH 9/9] Cleanup a loop in set_slab_attr() Matthew Dobson
2005-11-11 7:29 ` [PATCH 0/9] Cleanup mm/slab.c v2 Pekka J Enberg
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=4373DEF4.60100@us.ibm.com \
--to=colpatch@us.ibm.com \
--cc=kernel-janitors@lists.osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.com \
--cc=penberg@cs.Helsinki.FI \
/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