From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Linus Torvalds <torvalds@linux-foundation.org>,
Nick Piggin <npiggin@suse.de>, Jens Axboe <jens.axboe@oracle.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Ingo Molnar <mingo@elte.hu>,
Rusty Russell <rusty@rustcorp.com.au>
Cc: linux-kernel@vger.kernel.org, Oleg Nesterov <oleg@redhat.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [PATCH 2/2] generic-smp: remove kmalloc usage
Date: Thu, 12 Feb 2009 23:32:02 +0100 [thread overview]
Message-ID: <20090212223750.384627915@chello.nl> (raw)
In-Reply-To: 20090212223200.979433820@chello.nl
[-- Attachment #1: smp-remove-kmalloc.patch --]
[-- Type: text/plain, Size: 4120 bytes --]
Now that there is no strict need for kmalloc anymore, and nobody seems to
rely on the queueing behaviour, remove it.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
kernel/smp.c | 79 ++++++++++++++++++-----------------------------------------
1 file changed, 25 insertions(+), 54 deletions(-)
Index: linux-2.6/kernel/smp.c
===================================================================
--- linux-2.6.orig/kernel/smp.c
+++ linux-2.6/kernel/smp.c
@@ -31,8 +31,7 @@ static struct {
enum {
CSD_FLAG_WAIT = 0x01,
- CSD_FLAG_ALLOC = 0x02,
- CSD_FLAG_LOCK = 0x04,
+ CSD_FLAG_LOCK = 0x02,
};
struct call_function_data {
@@ -102,15 +101,6 @@ static void generic_exec_single(int cpu,
csd_flag_wait(data);
}
-static void rcu_free_call_data(struct rcu_head *head)
-{
- struct call_function_data *data;
-
- data = container_of(head, struct call_function_data, rcu_head);
-
- kfree(data);
-}
-
/*
* Invoked by arch to handle an IPI for call function. Must be called with
* interrupts disabled.
@@ -162,12 +152,6 @@ void generic_smp_call_function_interrupt
smp_wmb();
data->csd.flags &= ~CSD_FLAG_LOCK;
}
- if (data->csd.flags & CSD_FLAG_ALLOC) {
- if (busy)
- call_rcu(&data->rcu_head, rcu_free_call_data);
- else
- kfree(data);
- }
}
put_cpu();
@@ -217,8 +201,7 @@ void generic_smp_call_function_single_in
} else if (data_flags & CSD_FLAG_LOCK) {
smp_wmb();
data->flags &= ~CSD_FLAG_LOCK;
- } else if (data_flags & CSD_FLAG_ALLOC)
- kfree(data);
+ }
}
/*
* See comment on outer loop
@@ -263,13 +246,11 @@ int smp_call_function_single(int cpu, vo
/*
* We are calling a function on a single CPU
* and we are not going to wait for it to finish.
- * We first try to allocate the data, but if we
- * fail, we fall back to use a per cpu data to pass
- * the information to that CPU. Since all callers
- * of this code will use the same data, we must
- * synchronize the callers to prevent a new caller
- * from corrupting the data before the callee
- * can access it.
+ * We use a per cpu data to pass the information to
+ * that CPU. Since all callers of this code will
+ * use the same data, we must synchronize the
+ * callers to prevent a new caller from corrupting
+ * the data before the callee can access it.
*
* The CSD_FLAG_LOCK is used to let us know when
* the IPI handler is done with the data.
@@ -279,15 +260,10 @@ int smp_call_function_single(int cpu, vo
* will make sure the callee is done with the
* data before a new caller will use it.
*/
- data = kmalloc(sizeof(*data), GFP_ATOMIC);
- if (data)
- data->flags = CSD_FLAG_ALLOC;
- else {
- data = &per_cpu(csd_data, me);
- while (data->flags & CSD_FLAG_LOCK)
- cpu_relax();
- data->flags = CSD_FLAG_LOCK;
- }
+ data = &per_cpu(csd_data, me);
+ while (data->flags & CSD_FLAG_LOCK)
+ cpu_relax();
+ data->flags = CSD_FLAG_LOCK;
} else {
data = &d;
data->flags = CSD_FLAG_WAIT;
@@ -376,25 +352,20 @@ void smp_call_function_many(const struct
return;
}
- data = kmalloc(sizeof(*data), GFP_ATOMIC);
- if (data)
- data->csd.flags = CSD_FLAG_ALLOC;
- else {
- data = &per_cpu(cfd_data, me);
- /*
- * We need to wait for all previous users to go away.
- */
- while (data->csd.flags & CSD_FLAG_LOCK)
- cpu_relax();
- /*
- * Then we need to wait for the queue to pass through a
- * quiesent state, so that no other cpus can observe the
- * element anymore.
- */
- while (data->stamp == call_function.quiesent)
- cpu_relax();
- data->csd.flags = CSD_FLAG_LOCK;
- }
+ data = &per_cpu(cfd_data, me);
+ /*
+ * We need to wait for all previous users to go away.
+ */
+ while (data->csd.flags & CSD_FLAG_LOCK)
+ cpu_relax();
+ /*
+ * Then we need to wait for the queue to pass through a
+ * quiesent state, so that no other cpus can observe the
+ * element anymore.
+ */
+ while (data->stamp == call_function.quiesent)
+ cpu_relax();
+ data->csd.flags = CSD_FLAG_LOCK;
spin_lock_init(&data->lock);
if (wait)
--
next prev parent reply other threads:[~2009-02-12 22:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-12 22:32 [PATCH 0/2] generic smp helpers vs kmalloc Peter Zijlstra
2009-02-12 22:32 ` [PATCH 1/2] generic-smp: remove single ipi fallback for smp_call_function_many() Peter Zijlstra
2009-02-14 14:41 ` [PATCH 1.5/2] generic-smp: fix initial quiesent count Peter Zijlstra
2009-02-14 14:46 ` Peter Zijlstra
2009-02-14 21:14 ` Peter Zijlstra
2009-02-14 23:29 ` Ingo Molnar
2009-02-12 22:32 ` Peter Zijlstra [this message]
2009-02-14 14:46 ` [PATCH 2.5/2] generic-smp: remove cfd rcu_head Peter Zijlstra
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=20090212223750.384627915@chello.nl \
--to=a.p.zijlstra@chello.nl \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=npiggin@suse.de \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rusty@rustcorp.com.au \
--cc=torvalds@linux-foundation.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.